bubyoz
bubyoz

Reputation: 25

Change a key function for x amount of time?

So thanks to this user i have got this working code, but i want to further tweak it if its posibble. :D

Here is the code:

global s:=0, c:=0, t:=1500, t2:=380

*lbutton::
    send % Seqkeys("5","6")
    KeyWait, lbutton
    If (A_TickCount-s < t2)
        c := 0
    Send, 7
return

Seqkeys(params*) { 
    global s, c, t
    max := params.MaxIndex()
    (A_TickCount-s<=t && (c+=1)<=max) ? c : c:=1
    s := A_TickCount
    return params[c]
}

What i want to implement is that if i hit the right mouse button (Rbutton), the original lbutton seqkeys code changes to this code for 1 second

*lbutton::
    send, 8
    KeyWait, lbutton
    Send, 7
return

than when the 1 sec is over the code is revert back to the original seqkeys state.

I got this code sample but its not working properly for several reasons, when i hit the Rbutton it does override the original Seqkeys function, but it never resets back to the seqkeys one. I put it here maybe it helps

*rbutton::
toggle:=true
return

#If Toggle
*lbutton::
    send, 8
    KeyWait, lbutton
    Send, 7
return
toggle:=false
Return
#If

Thx again! :)

Upvotes: 0

Views: 76

Answers (1)

akshif
akshif

Reputation: 191

The reason why it never reset back to Seqkeys(params*) after toggle is that toggle:=false is outside the toggled lbutton hotkey. Putting it inside toggle lbutton hotkey before the return statement fixes the issue.

#If Toggle
*lbutton::
    send, 8
    KeyWait, lbutton
    Send, 7
    toggle:=false
return

Upvotes: 1

Related Questions