Skip to content

Instantly share code, notes, and snippets.

@mekefly
Created October 20, 2022 05:56
Show Gist options
  • Save mekefly/2b39c9b7c685b5cbdfc7bdb7f2f2d5b6 to your computer and use it in GitHub Desktop.
Save mekefly/2b39c9b7c685b5cbdfc7bdb7f2f2d5b6 to your computer and use it in GitHub Desktop.
AutoHotKey脚本KeyWaitAny.md

🧲 相关:

[[AutoHotkey]]

🗓️ 创建日期: [[2022-10-20#12:55]]


概要

这个脚本会等待 keys 中的任意按键按下后,继续执行,是一个同步函数

MsgBox % keyWaitAny("{All}")
上面代码当你在键盘上点哪个按钮,就会直接弹框显示对应的按钮
## 源码

源码

KeyWaitAny(keys,Options:="V")

{

  ih := InputHook(Options)

  if !InStr(Options, "V")

    ih.VisibleNonText := false

  ih.KeyOpt(keys, "E") ; 结束

  ih.Start()

  ErrorLevel := ih.Wait() ; 将 EndReason 存储在 ErrorLevel 中

  return ih.EndKey ; 返回按键名称

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment