How to generate keyboard events in Python?

后端 未结 11 1168
有刺的猬
有刺的猬 2020-11-22 14:55

short summary:

I am trying to create a program that will send keyboard events to the computer that for all purposes the simulated events should be t

11条回答
  •  悲&欢浪女
    2020-11-22 15:19

    Windows only: You can either use Ironpython or a library that allows cPython to access the .NET frameworks on Windows. Then use the sendkeys class of .NET or the more general send to simulate a keystroke.

    OS X only: Use PyObjC then use use CGEventCreateKeyboardEvent call.

    Full disclosure: I have only done this on OS X with Python, but I have used .NET sendkeys (with C#) and that works great.

提交回复
热议问题