【发布时间】:2017-02-04 03:27:49
【问题描述】:
我定义了很多小热键,比如:
; Open CMD
#c::
Run, cmd.exe
WinWait, ahk_exe cmd.exe
WinActivate
Return
我想构建一个带有 exe 和热键的函数,它会将应用程序与该热键绑定。到目前为止,这是我所拥有的:
bind_exe_to_hotkey(exe,hotkey)
{
run_label:
Run, %exe%
WinWait, ahk %exe%
WinActivate
Return
HotKey, %hotkey%, run_label
}
bind_exe_to_hotkey("cmd.exe","#c")
但是,这只会打开一个命令窗口。我究竟做错了什么?有没有更简单/更好的方法来实现这一点?
【问题讨论】:
-
您的函数只是打开一个命令窗口,因为它在“HotKey”执行之前返回。 “run_label”什么都不做;它只是一个类似 goto 的入口指针。执行 Run、WinWait 和 WinActivate 语句,然后函数在到达 HotKey 语句之前返回。
标签: autohotkey