2014-01-05 192 views
1

即時尋找諮詢來調整附加的腳本。AHK中斷循環上發佈,並繼續按鍵

當xbutton2被按下循環執行和重複罰款,但我停止循環像我想要掙扎。

理想我希望儘可能快停止循環儘可能xbutton2被釋放時。

另外我想如果同時仍保持xbutton2被按壓某個鍵(或多個密鑰的指定範圍)的環跳到開始。

xbutton2向下= 1-(400毫秒)-2-(400毫秒)-3-(400毫秒)-4-(750毫秒)-5-(500毫秒) - 等

xbutton2向下和釋放之後發送3 = 1-(400毫秒)-2-(400毫秒)-3 - xbutton2釋放

xbutton2向下和x被按下後發送3 = 1-(400毫秒)-2-(400毫秒)-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 

回答

0

你可以嘗試從01這個例子開始:

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 
+0

謝謝您的意見,我喜歡這個主意。處理可變睡眠定時器的最佳方式是什麼,因爲發送命令之間的定時會有所不同。 – user3162672

+0

爲什麼不遵循相同的模式? 'otherlist = 400,200,730,10',然後是'stringsplit,otherlist,otherlist,'''和'Sleep otherlist%counter%'? – Dane