Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有点小bug #17

Open
peakgao opened this issue May 1, 2022 · 1 comment
Open

有点小bug #17

peakgao opened this issue May 1, 2022 · 1 comment

Comments

@peakgao
Copy link

peakgao commented May 1, 2022

def get_text(hwnd):
length = ctypes.windll.user32.SendMessageW(hwnd, win32con.WM_GETTEXTLENGTH)
buf = ctypes.create_unicode_buffer(length + 1)
ctypes.windll.user32.SendMessageW(hwnd, win32con.WM_GETTEXT, length, ctypes.byref(buf)) # 这里的length改成length+1,否则中文存在切断变成一个问号
return buf.value

def hot_key(keys):
time.sleep(sleep_time)
for key in keys:
win32api.keybd_event(VK_CODE[key], 0, 0, 0)
# 这里插入一个小的延时,否则有时候两次键盘虚拟事件太快,导致失效
time.sleep(0.01)
for key in reversed(keys):
win32api.keybd_event(VK_CODE[key], 0, win32con.KEYEVENTF_KEYUP, 0)

@mengshangxun
Copy link

mengshangxun commented May 1, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants