I am making an auto clicker everything is working, but I have one problem. When I start the auto clicker, I have no way to exit it because my cursor is focused on a different window. This isn't ideal because when debugging it I might input a large value and then have to wait for it to finish before I can do anything else. Is there someway I could make it so when I hit a key the script stops even if I'm not focused on the window?
The full code can be seen here but the minimal example is:
def click(x, y, z):
for i in range(z):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
time.sleep(.03)
click(0,0,10000) #for example