windows 如何将一些字符串粘贴到 Python 中的活动窗口?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3048307/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I paste some string to the active window in Python?
提问by Bruno 'Shady'
Possible Duplicate:
How do I copy a string to the clipboard on Windows using Python?
Can someone make me an example or explain to me how can I paste something to the active window with Python?
有人可以给我举个例子或向我解释如何使用 Python 将某些内容粘贴到活动窗口吗?
I've edited because I didn't know that paste to the clipboard doesnt paste to the active window...
我进行了编辑,因为我不知道粘贴到剪贴板不会粘贴到活动窗口...
回答by jma
since you haven't accepted the duplicate as an answer may i suggest:
由于您尚未接受重复作为答案,我建议:
import win32com.client
shell = win32com.client.Dispatch("WScript.Shell")
shell.SendKeys('keys to send to active window...')
from:
从:
and if you need to find out about keys like Backspace go to
如果您需要了解 Backspace 之类的键,请访问