如何在AutoHotKey中的热键后检测下一个按键

问题描述 投票:2回答:1

我想制作一个AutoHotKey脚本,其中发生以下事情,按下Win + Space时。

  • 录制Win + Space后的下一次击键
  • 如果是g则谷歌将被打开
  • 如果是Esc则计算机被锁定
  • (比上面两个更多的条件)

我知道如何做所有这些事情,除了在Win + Space之后检测下一次击键。

autohotkey keyboard-events
1个回答
2
投票

您可以使用内置变量A_PriorHotKey和A_TimeSincePriorHotkey来检测Win + Space之后的下一次击键,并检查最近是否按下了热键(否则可能会在几小时后激活):

#Space:: return

; The #If directive creates context-sensitive hotkeys:

#If (A_PriorHotKey = "#Space" AND A_TimeSincePriorHotkey < 2000)

    ; If the hotkey was pressed recently (2 seconds)
    ; and g is pressed, then open google:

    g:: Run https://www.google.com ; open google (duh)


#If ; turn of context sensitivity

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

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.