【问题标题】:How do you include a loop with modifiers?如何包含带有修饰符的循环?
【发布时间】:2019-05-03 23:49:55
【问题描述】:

我试图让 AHK 继续按“2”,直到第二次按“2”。如果按住 alt、ctrl 或 shift,它会在按住时发送 ^2、+2、!2,然后在释放修饰键后返回垃圾邮件“2”。

到目前为止,这段代码可以使用修饰符,我只需要弄清楚如何添加循环。

; Disable Alt+Tab
!Tab::Return

; Disable Windows Key + Tab
#Tab::Return

#ifWinActive World of Warcraft
{
$2::
$^2::
$+2::
$!2::
Loop
{
if not GetKeyState("2", "P")
break
if GetKeyState("LCtrl", "P")
Send ^2
else if GetKeyState("LShift", "P")
Send +2
else if GetKeyState("LAlt", "P")
Send !2
else
Send 2
sleep 135
}
return
}

【问题讨论】:

    标签: autohotkey


    【解决方案1】:

    我建议您在循环中使用SetTimer 并能够打开和关闭它。请查看以下内容是否适合您:

    $2::
    $<^2::
    $<+2::
    $<!2::
    SetTimer , label_TwoLoop , % ( bT := !bT ) ? "135" : "Off"
    Return
    
    label_TwoLoop:
    If GetKeyState( "LCtrl" , "P" )
        Send , ^2
    Else If GetKeyState( "LShift" , "P" )
        Send , +2
    Else If GetKeyState( "LAlt" , "P" )
        Send , !2
    Else
        Send , 2
    Return
    

    https://autohotkey.com/docs/commands/SetTimer.htm

    请注意,我将&lt; 添加到热键定义中,因为循环部分仅查找左侧修饰键。我认为这是预期的行为。

    【讨论】:

      猜你喜欢
      • 2017-11-11
      • 1970-01-01
      • 1970-01-01
      • 2017-08-27
      • 2022-09-27
      • 2017-03-07
      • 2022-05-28
      • 1970-01-01
      • 2016-06-03
      相关资源
      最近更新 更多