0

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
8
  • I think you need the solution from here Commented Mar 9, 2016 at 20:29
  • 1
    Please paste your code into the body of the question itself. Commented Mar 9, 2016 at 20:29
  • 1
    the top of provided link says "# This is copied directly from StackOverflow" could you provide a link to the original source? Commented Mar 9, 2016 at 20:30
  • @TadhgMcDonald-Jensen Lol forgot about that. Here Commented Mar 9, 2016 at 20:52
  • @TadhgMcDonald-Jensen only part I copied was the click, everything else is mine Commented Mar 9, 2016 at 20:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.