Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a simple AHK script as follows:

Loop, 10
{  
    Click 745,664
    SetMouseDelay, 100
    Click 345,635
    SetMouseDelay, 25
    Click 878,471
    SetMouseDelay, 25
    Click 772,557
    SetMouseDelay, 25
    Click 552,387
    SetMouseDelay, 25
    Click 578,516
    SetMouseDelay, 150
}

What I want to be able to do is just add in some way of being able to stop the loop such as pressing certain keys but any example that I have tried hasn't been successful for me.

It is probably very simple but I have only just started using AHK and I am still getting used to it.

share|improve this question
up vote 1 down vote accepted

You can exit the loop using GetKeyState() and break like so:

Loop, 10
{  
    Click 745,664
    SetMouseDelay, 100
    Click 345,635
    SetMouseDelay, 25
    Click 878,471
    SetMouseDelay, 25
    Click 772,557
    SetMouseDelay, 25
    Click 552,387
    SetMouseDelay, 25
    Click 578,516
    SetMouseDelay, 150
    if GetKeyState("Shift", "P") ; Looks to see if Shift is pressed
        break  ; exits Loop
}
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .