2014-10-07 158 views
1

因此,我剛開始使用autohotkey,並且使這個腳本在稱爲流放路徑的遊戲中發出了垃圾郵件交易聊天,它工作得很好,但我不能得到它停止時,我按F1再次,我已經試過countles倍,但環是不會停止如何使用您啓動它的鑰匙停止autohotkey中的死循環

#MaxThreads 2 
wintitle=Path of Exile 
SetTitleMatchMode,2 
DetectHiddenWindows,On 
setkeydelay,2500,0 
f1:: 
toggle:=!toggle 
Loop 
{ 
    if toggle 
    controlsend,,{enter}{up}{enter}, %wintitle% 
    else 
    break 
} 
return 

回答

0

使用MaxThreadsPerHotkey

#MaxThreadsPerHotkey 2 
wintitle=Path of Exile 
SetTitleMatchMode,2 
DetectHiddenWindows,On 
setkeydelay,2500,0 
return 

f1:: 
toggle:=!toggle 
Loop 
{ 
if toggle 
controlsend,,{enter}{up}{enter}, %wintitle% 
else 
break 
} 
return 
+0

感謝您的答覆,我試過,但它仍然沒有工作 - 循環不停地再次按F1 – 2014-10-07 04:07:57

2

我認爲你最好使用SetTimer爲了這。當涉及到切換時,循環不太容易處理。

i := 0 
toggle := 0 
F1:: 
    toggle := !toggle 
    if (toggle) { 
     SetTimer, Timer_Spam, 10 
    } else { 
     SetTImer, Timer_Spam, Off 
    } 
return 

Timer_Spam: 
    TrayTip, Counter, %i% 
    i++ 
return 

之所以你的循環是不工作的,因爲一旦你進入循環程序被卡在那裏,所以要得到你所需要從循環內工作。

你可以用GetKeyState()來做到這一點,但是你不能使用同一個鍵來打開和關閉它,因爲它一開始就會關閉,除非你在那裏添加Sleep命令,這種情況反而變得不可靠。

但是,您可以使用單獨的鍵來停止循環,如下所示。

toggle := 0 
i := 0 
F1:: 
    toggle := !toggle 
    if (toggle) { 
     Loop { 
      if (GetKeyState("F2", "P")) { 
       toggle := !toggle 
       break 
      } 

      TrayTip, Counter, %i% 
      i++ 
     } 
    } 
return 

但正如我上面所說的,SetTimer以更穩定的方式達到了相同的結果。所以我願意這樣做。

+0

感謝您的幫助的人去後,我真的很感激它,你的第二個代碼工作,我所有必須做的是持有f2 – 2014-10-08 01:17:33

0

此代碼你想要做什麼:

#MaxThreads 2 
wintitle=Path of Exile 
SetTitleMatchMode,2 
DetectHiddenWindows,On 
setkeydelay,2500,0 

return 
F1:: 
    Loop 
    { 

     CheckLButton1: 
     if (GetKeyState("F1")) 
     { 
      Goto, CheckLButton1 
     } 

     Docode: 
     controlsend,,{enter}{up}{enter}, %wintitle% 
     ;ToolTip, 1 


     if (!(GetKeyState("F1"))) 
     { 
      Goto, Docode 
     } 

     CheckLButton2: 
     if (!(GetKeyState("F1"))) 
     { 
      return 
     } 
     else 
     { 
      Goto, CheckLButton2 
     } 
    } 
return 

如果需要解釋,看看在這裏我的帖子:http://ahkscript.org/boards/viewtopic.php?f=5&t=4613#p26298

此外,經常使用的AutoHotkey和http://ahkscript.org/其documenatation(當前UPTODATE版本,新的官方網站)! autohotkey.com及其來自autohotkey.com的文檔已過時,您可能在使用它們時遇到一些問題!

0

我的策略是這樣的, 使用這個命令:

v:: 
loop 
{ 
click 
if (GetKeyState("b")) { 
break 
    } 
} 
return 

(其簡單AutoClicker)

0

與循環命令工作示例。然而這麼簡單。

#Persistent 
#MaxThreadsPerHotkey 2 
toggle := False 

f1 UP:: 
toggle := !toggle 

Loop { 
    If (!toggle) { 
     break 
    } 
    ; Spam commands here 
} 
Return