How to simulate string keyboard input using Python?

前端 未结 1 1374
栀梦
栀梦 2021-01-16 16:58

I\'m using windows 8 and have the windows api module

I am trying to create a method:

TypeInput(argument) #argument is a string

with the

相关标签:
1条回答
  • 2021-01-16 17:42

    You want to use SendInput, rather than keybd_event, and make sure that the KEYBDINPUT.dwFlags field has the KEYEVENTF_UNICODE flag set. If you're not using KEYEVENTF_UNICODE, then you have to make sure to set both the scan code and the key code; otherwise you will get app-specific failures.

    There is a Python wrapper for SendInput, so that will help too.

    0 讨论(0)
提交回复
热议问题