How do I press 2 keys at a time using pyautogui?
Question:
I want to press control + left arrow on my mac to swipe my screen.
This is what I tried:
import pyautogui
pyautogui.press(["ctrl" ,"left"])
it does not work.
Answers:
For this you can use pyautogui.hotkey(). In your example you would run :
pyautogui.hotkey('ctrl', 'left')
the code seems correct. the problem might be because you are running the code in your IDE, and you might have clicked on the text or something like that (it happended to me before). Try adding a for loop.
import pyautogui
for i in range(5):
pyautogui.press(["ctrl" ,"left"])
if it works then consider making a simple prompt with a button to do it.
import pyautogui
while True:
result = pyautogui.confirm('click "swipe" to swipe', buttons = ["swipe", "no"])
if result == "swipe":
pyautogui.press(["ctrl" ,"left"])
I want to press control + left arrow on my mac to swipe my screen.
This is what I tried:
import pyautogui
pyautogui.press(["ctrl" ,"left"])
it does not work.
For this you can use pyautogui.hotkey(). In your example you would run :
pyautogui.hotkey('ctrl', 'left')
the code seems correct. the problem might be because you are running the code in your IDE, and you might have clicked on the text or something like that (it happended to me before). Try adding a for loop.
import pyautogui
for i in range(5):
pyautogui.press(["ctrl" ,"left"])
if it works then consider making a simple prompt with a button to do it.
import pyautogui
while True:
result = pyautogui.confirm('click "swipe" to swipe', buttons = ["swipe", "no"])
if result == "swipe":
pyautogui.press(["ctrl" ,"left"])