bubyoz
bubyoz

Reputation: 25

Send command after Keywait, but only if the given time is right?

So this sequence resets itself after 1.5 sec (t:=1500) which means if i dont hit the left mouse button for 1.5 sec it always sends A. Otherwise it sends the next letter after each click.

I want to further tweak this code with these other functions which are:

The zero key is a function in the game thats why i need after LMB keywait! .

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


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]
}


*LButton::
        Send % Seqkeys("A","B")
        KeyWait, LButton
        Send, 0
Return
*0::
      c := 1
      s := 0
Return

Upvotes: 0

Views: 227

Answers (1)

Eli
Eli

Reputation: 192

Is this what you want?

#NoEnv
#Warn
#SingleInstance Force
#UseHook
SetWorkingDir %A_ScriptDir%
SendMode Input

Global nCount := 1, nTimeOut := 1500

Seqkeys(params*) {
    Local
    Global nCount, nTimeOut
    If ( (A_TimeSincePriorHotkey > 300) and (A_TimeSincePriorHotkey < nTimeOut) ) {
        sChar := params[nCount]
        nCount := (nCount == params.MaxIndex()) ? 1 : (nCount + 1)
        return sChar
    }
    return 0
}


*LButton::
KeyWait, LButton
Send % Seqkeys("A","B","C")
Return

If not, you should try to rephrase your question, because it's not easy to understand. I have no idea what you want in your last paragraph, for example.

Upvotes: 1

Related Questions