AutohotKey start/stop 相同的按键

AutohotKey start/stop same key press

此脚本假设在按下某个键时 start/stop。我希望那是同一个键。示例 我按 F3 开始,然后再次按 F3 停止。它会慢慢地从 0000 数到 9999,并会在您停止循环时记住您所在的位置。出于某种原因,它会启动,但当我再次按 F3 时,它不会停止。按照这个例子 http://www.autohotkey.com/docs/FAQ.htm#repeat 我究竟做错了什么?

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

start = 0000
Run = false

F3::                       
SetFormat, Float, 04.0
current = %start%

if Run {
    Run := false
    return 
}

Run := true
Loop, 9999{
    Send e                      
    Sleep, 760 

    TrayTip, PinCode BruteForce, %current%, , 16
    Send %current%                  
    current += 1.0
    start += 1.0
    Sleep, 700

    if(current = 10000){
        Break
    }

    if (not Run){
        Break
    }
}

Run := false
return

您错过了可以在您发布的 link 处找到的 #MaxThreadsPerHotkey。它的默认值是 1,所以一旦你按下 F3,它就不能再被触发。增加它,这样热键就可以按照你想要的方式自行中断。

以下是停止执行操作的其他三种方法:

  • 使用 timer 而不是循环并切换其状态
  • 使用 pause 命令
  • 使用 goto 命令