AHK - 如何暂停绑定和按暂停绑定

AHK - How to bind on hold and bind on a press to pause

我有要升级的 AHK 脚本。脚本在屏幕中央显示一个红点。我想知道当你切换一些键或鼠标按钮时如何让它工作。以及如何在单击任何按钮时暂停它。

; reddot
x = 840
y = 525
w = 3
h = 3
Color = 0xFF0000
WS_EX_TRANSPARENT := 0x20
WS_EX_LAYERED := 0x80000
Gui, +AlwaysOnTop -Caption +ToolWindow +LastFound
Gui, Color, % Color
Gui, Show, x%x% y%y% w%w% h%h% NA
WinSet, ExStyle, % "+" WS_EX_LAYERED|WS_EX_TRANSPARENT

将此附加到您现有的脚本中:

state:=True

;the 'q' key
q::
state^=1 ;Basically just inverts the value of the 'state' variable
if(state)
    Gui, Show
else
    Gui, Hide
return

;Shift + the 'Esc' Key
+Esc::Suspend, Toggle

请参阅 Hotkeys 的 AHK 文档,了解如何重新映射哪个键(或组合键)将触发这些效果。

最终/合并代码:

; reddot
x = 840
y = 525
w = 3
h = 3
Color = 0xFF0000
WS_EX_TRANSPARENT := 0x20
WS_EX_LAYERED := 0x80000
Gui, +AlwaysOnTop -Caption +ToolWindow +LastFound
Gui, Color, % Color
Gui, Show, x%x% y%y% w%w% h%h% NA
WinSet, ExStyle, % "+" WS_EX_LAYERED|WS_EX_TRANSPARENT

state:=True

;the 'q' key
q::
state^=1
if(state)
    Gui, Show
else
    Gui, Hide
return

;Shift + the 'Esc' Key
+Esc::Suspend, Toggle

如果您还需要什么,请联系我们