'Python autoclicker doesn't work on another window
here's my problem : I made an autoclicker to automate some stuffs and it perfectly work on app like Opera or just my os. But I want it to work on a special app "Wabbajack", and when I have this app in foreground, my script doesn't work anymore : nothing happen like a freeze during i'm on this app. Do you know how i can fix this issue ?
PS : it is probably a security from the app but don't worry i'm not cheating, stealing or do anything who would be illegal, i'm just trying to automate a boring installation
Here's my code
import time
import threading
from pynput.mouse import Button, Controller
from pynput.keyboard import Listener, KeyCode
start_stop_key = KeyCode(char='s')
exit_key = KeyCode(char='e')
position_vortex0 = (1080, 620)
position_vortex1 = (1080, 655)
position_vortex2 = (1080, 690)
class ClickMouse(threading.Thread):
def __init__(self):
super(ClickMouse, self).__init__()
self.short_delay = 1
self.delay = 4
self.button = Button.left
self.running = False
self.program_running = True
def start_clicking(self):
self.running = True
def stop_clicking(self):
self.running = False
def exit(self):
self.stop_clicking()
self.program_running = False
def click(self, position):
mouse.position = position
time.sleep(0.2)
mouse.click(self.button)
time.sleep(self.short_delay)
def run(self):
while self.program_running:
while self.running:
self.click(position_vortex0)
self.click(position_vortex1)
self.click(position_vortex2)
time.sleep(0.1)
mouse = Controller()
click_thread = ClickMouse()
click_thread.start()
def on_press(key):
if key == start_stop_key:
if click_thread.running:
click_thread.stop_clicking()
else:
click_thread.start_clicking()
elif key == exit_key:
click_thread.exit()
listener.stop()
with Listener(on_press=on_press) as listener:
listener.join()
This code is suppose to click on installation button who appear at random time. It perfectly work on others app and just click on 3 position before loop at "while self.running" who is True when I press "s"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|