为什么按b后按a不发送消息框?

问题描述 投票:0回答:1
a::
 if GetKeyState(b) {
   MsgBox, Enter key is pressed!
}

为什么按b后按a不发送消息框?这不是 GetKeyState() 的工作原理吗?

autohotkey
1个回答
0
投票

if GetKeyState(b)
是错误的语法。

GetKeyState() 是一个 函数,其参数必须列在括号中。 如果参数是文字字符串,则应将其括在双引号中

按住 B 的同时按 A 时发送消息框:

$a::
    if GetKeyState("b") {
        MsgBox, A is pressed while holding B!
    }
return

按B后按A时发送消息框:

#InstallKeybdHook

$a::
    If (A_PriorKey = "b") {
        MsgBox, A is pressed after pressing B!
    }
return

请参阅 A_PriorKey$ 前缀

© www.soinside.com 2019 - 2024. All rights reserved.