Scripting 每秒钟重复一次按键

Scripting 每秒钟重复一次按键,scripting,autohotkey,Scripting,Autohotkey,我已经在AutoHotkey中编写了以下内容,以应对特定游戏端口到PC的非常烦人的“冲刺”操作: #SingleInstance,Force #NoEnv CoordMode,Mouse,Screen DetectHiddenWindows,On StringTrimRight,applicationname,A_ScriptName,4 OnExit,EXIT Gosub,TRAYMENU ; Set the first run to turn on the loops breakera =

我已经在AutoHotkey中编写了以下内容,以应对特定游戏端口到PC的非常烦人的“冲刺”操作:

#SingleInstance,Force
#NoEnv
CoordMode,Mouse,Screen
DetectHiddenWindows,On
StringTrimRight,applicationname,A_ScriptName,4
OnExit,EXIT
Gosub,TRAYMENU

; Set the first run to turn on the loops
breakera = 0
loopa = 1
breakerw = 0
loopw = 1

Shift & LAlt::
IfWinExist,Bully
    {
        If loopa = 0
            {
                loopa := !loopa
                breakera := !breakera
            }
            else
            {
                loopa := !loopa
                breakera := !breakera
                Loop
                    {
                        Send {LAlt}
                        Sleep, 1000
                        if breakera = 1
                            {
                                break
                            }
                    }
            }
    }
    else
        { 
            Gosub,BULLYERROR
        }
Return

Shift & W::
IfWinExist,Bully
    {
        If loopw = 0
            {
                loopw := !loopw
                breakerw := !breakerw
            }
            else
            {
                loopw := !loopw
                breakerw := !breakerw
                Loop
                    {
                        Send {w}
                        Sleep, 1000
                        if breakerw = 1
                            {
                                break
                            }
                    }
            }
    }
    else
        { 
            Gosub,BULLYERROR
        }
Return

BULLYERROR:
Gui,97:Destroy
Gui,97:Margin,20,20
Gui,97:Font
Gui,97:Add,Text,y+10 yp+10,Bully is not running!
Gui,97:Show,,Error
Return
我意识到这段代码并不十分有效,但它看起来仍然应该可以工作,不过,它并不担心缺少的sub,只是一个片段

我的意图是,当您按下Shift+键时,它每秒重复一次键,直到您再次按下Shift+键


有什么想法吗?谢谢

使用类似的方法

Shift & LAlt::
  If AltRepeating = true
  {
    SetTimer, RepeatAlt, Off
    AltRepeating = false
  }
  Else
  {
    Send, {lAlt}
    SetTimer, RepeatAlt, 1000
    AltRepeating = true
  }


RepeatAlt:
  Send, {LAlt}
Return