On Pycharm in Mac, I am using Pyautogui to perform simple operation of Select all with Command+A using hotkey() function.
The code works in scenario:
import pyautogui
pyautogui.press("b")
pyautogui.hotkey("command", "a")
# Cursor here: b
with all text selected. But does not work in the scenario:
import pyautogui
pyautogui.hotkey("command", "a")
# Cursor here: a
where it simply prints the second key in the hotkey which is a
Same thing happens when I do it in Atom. Can someone explain what’s wrong?
In mac os, actually you need to press command key first before any key for the hotkey, so you need to add interval between them.
pyautogui.hotkey("command", "a", interval=0.25 )
pyautogui.hotkey("command", "r", interval=0.25 ) #to refresh page
pyautogui.hotkey("command", "t", interval=0.25 ) #new tab
etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With