MouseClick method invisible for GetKeystate, send Lclick while Lbutton is presses python

I am trying to write autoclicker for windows system. The app should spam clicks while left mouse botton is pressed, but the problem is that loop ends when the script simulate mouse. Is any way to ignore simulated clicks? Or check if button is pshycily pressed? May exists some better solution than my loop. Any ideas?

from pynput import keyboard import threading from time import sleep import win32gui, win32api, win32con from pynput.mouse import Button, Controller  mouse = Controller() power = 0 delay = 0.10   def click_l(x, y):     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)     sleep(0.01)     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)   def clicker():     while 1 == 1:     #while win32api.GetAsyncKeyState(0x01) != 0:         y = win32api.GetKeyState(0x01)  # ord('f')         print(y)         #mouse.press(Button.left)         #mouse.release(Button.left)         click_l(0,0)         print("after", y)         sleep(0.2)    def on_press(key):     global power     if key == keyboard.Key.esc:         return False  # stop listener     try:         k = key.char  # single-char keys     except:         k = key.name  # other keys      if k in ['f4']:  # skeys of interest         power = 0 if power == 1 else 1      if k in ['F', 'f']:         x = threading.Thread(target=clicker)         x.start()   listener = keyboard.Listener(on_press=on_press) listener.start()  # start to listen on a separate thread listener.join()  # remove if main thread is polling self.keys  
Professor Asked on October 18, 2020 in Android langue,   Python.
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.