Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I press 2 keys at a time using pyautogui?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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"])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading