如何使用 shell.SendKeys 选择并删除所有内容(ctrl + shift + left arrow + del)?
嘿,我在这里遇到了一些麻烦...
如何使用 sendkeys 从字段中删除整个文本?
如何发送按住 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)
这部分选择一个字段并粘贴名字信息(就像宏一样),但我想在粘贴删除字段内容的信息之前执行一些操作(如果有)一个……
卡佩切?
Hey, I'm having some trouble here...
How can I delete an entire text from a field with the sendkeys ?
How can I send the ctrl+shift pressed with the left arrow and delete key after?
edit:
for example, I have this part of the code
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)
This part select a field and paste the firstname information (just like a macro), but I want to do something before paste the information that deletes the content of the field, if it has one...
capiche?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道 Sendkeys,但我知道你可以使用 ctypes 发送击键。
以下是如何通过发送 CTRL+A 和 BACK 来删除文本:
您需要发送 Windows 虚拟键代码。有关完整列表,请参阅此处。
它可能与 SendKeys 类似
我希望它有帮助
I don't know with Sendkeys but I know that you can send keystrokes with ctypes.
Here is how to remove a text by sending CTRL+A and BACK:
You need to send the windows virtual key code. See here for the full list.
It may be similar with SendKeys
I hope it helps
可能想用 Ctrl+A 代替?
您能给出一个不适合您的代码的简短示例吗?
根据 SendKeys 的实现,它可能不会一次接受所有这些。它可能需要多次 SendKeys 调用。您可以尝试在单独的 SendKeys 调用中一次执行一项操作。
编辑:
http://msdn.microsoft.com /en-us/library/8c6yea83.aspx
在我看来你应该能够做到这一点:
Might want to do Ctrl+A instead?
Can you give a short example of the code that isn't working for you?
Depending on the implementation of SendKeys, it might not accept all those at once. It might require multiple SendKeys invocations. You could try doing one at a time, in separate calls to SendKeys.
Edit:
http://msdn.microsoft.com/en-us/library/8c6yea83.aspx
It seems to me you should be able to do this: