Is there a sendKey for Mac in Python?

后端 未结 5 1503

In Mac 10.6, I want to cause an active application to become de-active, or minimized by Python

I know I could use sendKey in Windows with Python, then what about in

5条回答
  •  无人及你
    2020-12-02 22:07

    In addition to Yinan, which will send the keystroke to the currently active application, you can send it to a specific application as follows. Pass the following to osascript as before, or save it to a file and pass the file to osascript

    tell application "Safari"
        activate
        tell application "System Events" to keystroke "r" using {command down}
    end tell
    

    This will send Cmd + r to Safari after bringing it to the foreground

提交回复
热议问题