User
User

Reputation: 53

How to repeat triggering a script in AutoHotkey by holding down a key?

I am trying to write a script in autohotkey so that, when I hold i for every one seconds it trigger a specific script for each of the one seconds. for example when I hold this key for 7 seconds something be done 7 times, or when I hold it for 8.3 seconds it to the same thing 8 times. and when I just press that key ( which takes less than one second) it type that letter.

 $i:: 
 KeyWait,i,T0.25 
 If (ErrorLevel) 
 {
    Click, 768,192,10
    KeyWait,i 
 }
    Else
    {
        Send, i
    }    
return

By running this script it just do the process once when I hold the key more than one seconds and to do it again I should hold the button again. I'm not sure how to achieve my goal. I added Loop{} but the result was typing " i " repeatedly.

Upvotes: 0

Views: 1069

Answers (1)

Lifeweaver
Lifeweaver

Reputation: 1042

You were fairly close:

$i::
KeyWait, i, T1
If (ErrorLevel) {
    Loop 10
        Click, 768,192
} else {
    Send, i
}
return

Upvotes: 2

Related Questions