按键精灵9 If key 的组合键按法

2025-03-30 09:29:27
推荐回答(1个)
回答1:

1.并没有直接提供检测组合键的方法 可以是用下面代码

Private Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vKey As Long) As Integer //声明调用一个API函数 用于检测按键状态

While true //循环检测(这是死循环 自己修改一下循环条件)

If WaitKey = 49 and GetAsyncKeyState(18) > 0 Then //满足条件弹出提示 否则继续检测
MsgBox "ALT+1 按下"
End If
Delay 100
Wend

2. 可以通过 Rem 来做标记定义某行 然后通过 goto跳转。 不过这样做会破坏程序结构,不建议这么用 下面给出示例按 数字键1跳出

While True //制造一个死循环
key = GetLastKey()
If key = 49 Then //检测数字键1
Goto EndLoop
End If
Wend
Rem EndLoop
MsgBox "已跳出死循环你按的键是:"+chr(key)