How to generate keyboard events in Python?

后端 未结 11 1222
有刺的猬
有刺的猬 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:31

    For both python3 and python2 you can use pyautogui (pip install pyautogui)

    from pyautogui import press, typewrite, hotkey
    
    press('a')
    typewrite('quick brown fox')
    hotkey('ctrl', 'w')
    

    It's also crossplatform with Windows, OSX, and Ubuntu LTS.

提交回复
热议问题