How i can send the commands from keyboards using python. I am trying to automate mac app (GUI)

前端 未结 2 604
一个人的身影
一个人的身影 2021-01-27 04:58

I am trying to automate a app using python. I need help to send keyboard commands through python. I am using powerBook G4.

相关标签:
2条回答
  • 2021-01-27 05:24

    To the best of my knowledge, python does not contain the ability to simulate keystrokes. You can however use python to call a program which has the functionality that you need for OS X. You could also write said program using Objective C most likely.

    Or you could save yourself the pain and use Automator. Perhaps if you posted more details about what you were automating, I could add something further.

    0 讨论(0)
  • 2021-01-27 05:34

    You could call AppleScript from your python script with osascript tool:

    import os
    cmd = """
    osascript -e 'tell application "System Events" to keystroke "m" using {command down}' 
    """
    # minimize active window
    os.system(cmd)
    
    0 讨论(0)
提交回复
热议问题