79144111

Date: 2024-10-31 09:26:57
Score: 2
Natty:
Report link

I'm a beginner with pyautogui and I had same issue that pyautogui.hotkey not working as expected but I found out that you can do pretty much the same thing with keyDown and keyUp

# Press Windows + Up Arrow
pyautogui.keyDown("winleft")   # Press Windows key
pyautogui.press("up")          # Press Up Arrow key
pyautogui.keyUp("winleft")     # Release Windows key

and then you can write your own hotkey function

# my hotkey function
def press_hotkey(key1, key2):
    pyautogui.keyDown(key1)        # Press first key
    pyautogui.press(key2)          # Press second key
    pyautogui.keyUp(key1)          # Release first key
Reasons:
  • RegEx Blacklisted phrase (2): I'm a beginner
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Ahmed Salah