AHK Break Loop on Release并继续按下按键

时间:2014-01-05 14:56:57

标签: loops release autohotkey break continue

我正在寻找调整附加脚本的建议。

当按下xbutton2时,循环被执行并重复正常,但我很想停止循环,就像我想要的那样。

理想情况下,当xbutton2被释放时,我想尽可能快地停止循环。

此外,如果在按住xbutton2的同时按下某个键(或指定范围的键),我希望循环跳转到开头。

xbutton2 down = 1-(400ms)-2-(400ms)-3-(400ms)-4-(750ms)-5-(500ms) - 等

xbutton2 down并在发送3 = 1-(400ms)-2-(400ms)-3 - xbutton2发布后释放

xbutton2 down和x在发送3 = 1-(400ms)-2-(400ms)-3 -X - 1-(400ms)-2-(400ms)等后被按下

SetNumlockState, Alwayson
#MaxThreadsPerHotkey 3


$*XButton2::

loop
    {
if not GetKeyState("XButton2", "P")
        break
Send {Blind} {1}
sleep 400
 if (not GetKeyState("XButton2", "P")or GetKeyState("x", "P"))
        continue
Send {Blind} {2}
sleep 400    
 if (not GetKeyState("XButton2", "P")or GetKeyState("x", "P"))
        continue
Send {Blind} {3} 
sleep 400 
 if (not GetKeyState("XButton2", "P")or GetKeyState("x", "P"))
        continue
Send {Blind} {4}
    sleep 750
 if (not GetKeyState("XButton2", "P")or GetKeyState("x", "P"))
        continue
Send {Blind} {5}
sleep 500
}

return

1 个答案:

答案 0 :(得分:0)

您可以尝试从AHK forums

中的此示例开始
list=a,b,c,{enter},string{click}    ; the list of keys and combos. comma separated. 
stringsplit, list, list,`,
Counter = 0

$F8::
    While GetKeyState("F8","P"){
        Counter := (Counter=list0) ? (1) : (Counter+1)
        Send % list%counter%
        Sleep 50
    }
return

您可以使用其他热键将计数器重置为“0”。我认为以下内容可能适合您:

list={Blind}{1},{Blind}{2},{Blind}{3},{Blind}{4},{Blind}{5}
stringsplit, list, list,`,
Counter = 0

$*XButton2::
    While GetKeyState("XButton2","P"){
        Counter := (Counter=list0) ? (1) : (Counter+1)
        Send % list%counter%
        Sleep 400
    }
return

x::Counter = 0