Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.