python中PostMessage组合键操作的问题
from ctypes import windllfrom ctypes.wintypes import HWND
handle= win32gui.FindWindowEx(win32gui.FindWindow('Notepad',None),None,'Edit',None)
windll.user32.PostMessageW(handle, WM_KEYDOWN, 0x10, 0)
windll.user32.PostMessageW(handle, WM_KEYDOWN, 0x32, 0)
windll.user32.PostMessageW(handle, WM_KEYUP, 0x32, 0)
windll.user32.PostMessageW(handle, WM_KEYUP, 0x10, 0)
看到论坛里之前有类似问题
但是我需求的是其实是要输入一个 @ .
shift的编码是0x10 2的编码是0x32
上面的代码是行不通的.
求解. handle = windll.user32.FindWindowW(None, "无标题 - 记事本")
lparam = MapVirtualKeyW(0x32, 0) << 16 | 1
PostMessageW(handle, WM_KEYDOWN, 0x32, lparam)
即使我这样写也依旧返回的是2而不是shift+2,也就是@ 消息不支持组合键 功能键的状态需要使用keybd_event函数设置
页:
[1]