我使用下面的方法来获取应用程序的窗口句柄,并将其作为焦点。我想在应用程序中键入一个字符串。但是使用win32api.keybd_事件,我只能键入单个字符?有没有办法输入一串字符
例如,“我很高兴”
多谢各位
import win32gui
import win32api
import win32con
hld = win32gui.FindWindow (None, "UNTITLED") # Returns the handle of the window titled UNTITLED
if hld>0:
win32gui.SetForegroundWindow(hld)
win32api.keybd_event(0x46, 0, ) # F
您可以使用^{} 函数来实现这一点。通过此函数将需要发送到相应窗口的字符串发送一次
我创建了一个示例,如下所示:
此示例实现将字符串“hello”发送到记事本。这对我来说很好
相关问题 更多 >
编程相关推荐