嘿,我在这里遇到了一些麻烦......
如何使用发送键从字段中删除整个文本?
如何发送按下左箭头的 ctrl+shift 键和之后的删除键?
编辑:
比如我有这部分代码
ctypes.windll.user32.SetCursorPos(910,475)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0)
time.sleep(0.1)
shell.SendKeys(inf_firstname)
这部分选择一个字段并粘贴名字信息(就像一个宏),但我想在粘贴删除该字段内容的信息之前做一些事情,如果有的话......
花花公子?
请您参考如下方法:
我不知道 Sendkeys,但我知道你可以用 ctypes 发送击键。
以下是如何通过发送 CTRL+A 和 BACK 来删除文本:
ctypes.windll.user32.keybd_event(0x11, 0, 0, 0) #CTRL is down
ctypes.windll.user32.keybd_event(ord("A"), 0, 0, 0) #A is down
ctypes.windll.user32.keybd_event(ord("A"), 0, 0x0002, 0) #A is up
ctypes.windll.user32.keybd_event(0x11, 0, 0x0002, 0) #CTRL is up
ctypes.windll.user32.keybd_event(0x08, 0, 0, 0) #BACK is down
ctypes.windll.user32.keybd_event(0x08, 0, 0x0002, 0) #BACK is up
您需要发送 windows 虚拟键码。参见 here查看完整列表。
可能与SendKeys类似
希望对你有帮助
