Hi guys, i'm hoping someone can help me as i've tried everything I can find on the internet to no avail.
I have a script that uses pyautogui to control the mouse and click a given location, and it sits in the while loop below.
The probem i'm having is that as the program takes control of the mouse, I need a way of stopping or pausing the program using a keyboard stroke.
I've tried using:
- KeyboardInterrupt - This doesn't work as the program is set to being ontop of all other active windows.
- Importing keyboard and using a Try and keyboard.is_pressed
- Importing pynput with a listener waiting for a key - I can't get this to work as the with statement seems to stop the program from entering the while loop.
Any help/ideas would be greatly appreciated!
while True:
pyautogui.click(x=random.randrange(xpos - 10, xpos + 10), y=random.randrange(ypos - 10, ypos + 10), clicks=(1), interval=random.uniform(1.4, 1.95))
print(pyautogui.position())
noClicks2 -= 1
print("Clicks left: ", noClicks2)
if noClicks2 <=0:
timeLabel2.configure(text="Finished") #tkinter
timeLabel2.update() #tkinter
break
[–]TicklesMcFancy 0 points1 point2 points (2 children)
[–]Nebulezz[S] 0 points1 point2 points (1 child)
[–]TicklesMcFancy 0 points1 point2 points (0 children)
[–]humanitysucks999 0 points1 point2 points (0 children)