Jun-29-2017, 02:02 AM
I want to start off by saying that I am new to Python so I am sorry if this question is going to sound stupid to you.
I am just looking for an easy way to trigger a function whenever I press the left click of my mouse. Could anyone illustrate me how to achieve this? Examples are greatly appreciated.
My code now:
That's what I've done so far, but that doesn't work as python starts clicking thousands times per second.
I am just looking for an easy way to trigger a function whenever I press the left click of my mouse. Could anyone illustrate me how to achieve this? Examples are greatly appreciated.
My code now:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import win32api import win32con import time from random import randint #import pygame #pygame.init() def mouseClick(): win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0 , 0 , 0 , 0 ) time.sleep( 0.005 ) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0 , 0 , 0 , 0 ) while True : if win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0 , 0 , 0 , 0 ): time.sleep( 0.03 ) mouseClick() time.sleep( 0.3 ) |