The pyautogui hotkey('ctrl', 'shift', '2') is working on Windows but not on Mac (Big Sur, iMac with M1-chip). Can't figure out why that is. (The hotkey should open up a form in a program called PhraseExpress). I have added the Terminal in Privacy->Accessibility. I use the latest Python. I open the py file in the Terminal.
def hotkey() -> None:
"""function to open the corresponding phraseexpress form (with a hotkey)"""
if foo == "Note 2":
if platform == "darwin":
print("Test before hotkey")
pyautogui.hotkey('ctrl', 'shift', '2')
if platform == "win32":
pyautogui.hotkey('ctrl', 'shift', '2')
print("You opened PhraseExpress for note 2")
The output is:
Test before hotkey
You opened PhraseExpress for note 2
And nothing else happens. The hotkey is not working on Mac.
It seems like the browser window does not have focus. I need to change focus for it, then the hotkeys will work. How can I change focus to the browser? I am using tkinter and when the script runs it seems like tkinter has the focus, hence the hotkeys will not work