'Trying to make mouse click again on click(python)
I have been trying to make a python script that left clicks again when you do, though it keeps turning into an auto clicker because the click that the script made was detected again and so on. what have I tried?: 1. Just clicking again on click: obv. didnt work. 2. Adding 1 to a counter and only clicking on odd/even numbers: turned into an autoclicker(I have no idea why) Here is the code of the second option:
import pynput
import pyautogui
import keyboard
import time
import threading
import multiprocess
import multiprocessing
from multiprocessing import Process
from threading import Thread
from pynput import keyboard
from pynput import mouse
current = set()
y = 0
def on_click(x, y, button, pressed):
time.sleep(1)
if button == mouse.Button.left:
y = y+1
if (y % 2) == 0:
pyautogui.click()
else:
return
with mouse.Listener(
on_click=on_click) as listener:
try:
listener.join()
except MyException as e:
print('{0} was clicked'.format(e.args[0]))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
