0

我在 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

我意识到这段代码效率不高,但看起来它仍然应该可以工作,但是它没有(不要担心丢失的 subs,只是一个片段)。

我的目的是让当你按下Shift+时它每秒Key重复一次,直到你再次按下+ 。KeyShiftKey

有任何想法吗?谢谢!

4

1 回答 1

0

使用这样的东西。

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


RepeatAlt:
  Send, {LAlt}
Return
于 2011-01-27T20:37:56.370 回答