Matheus Ferrer
Matheus Ferrer

Reputation: 1

Pyautogui press keyboard and mouse same time

i'm developing a pyautogui program in a game and need to press CTRL + MouseLeftButton

pyautogui.press('ctrl')
pyautogui.click()

can you help me to do this at the same time

I know that I can do 2 press in keyboard using

pyautogui.press('key1', 'key2')

but cant find how to do this with mouse and keyboard

Upvotes: 0

Views: 74

Answers (1)

5rod
5rod

Reputation: 454

You can use threading to do both things at the same time.

Snippet of code:

from threading import Thread
import pyautogui

def press():
    pyautogui.press('ctrl')

def click():
    pyautogui.click()

Thread(target = press).start()
Thread(target = click).start()

and this might work. I do know that there is something going on with the multiprocessing module, but I don't know how to use it, but it might be useful for you to check it out.

Upvotes: -1

Related Questions