(AHK) 创建变量热键,从脚本的 2 个字符文件名中获取键名
(AHK) Creating variable hotkeys that gets the key names from a 2 char file name of a script
我正在尝试为我们的员工制作一些东西,这样他们就不必更改脚本本身来定义热键。这可能只适用于可以由单个字符定义的热键,但这很好,因为可以用它们进行多种组合,而且它们很容易记住。该脚本只会查看工作目录中 2 个字符的 AHK 文件(如果必须包含扩展名,则为 6 个)。它要搜索的变量可以用 RegEx 定义,所以对于第一个热键,它看起来像 ^。然后第二个看起来像 .(?=.) 一旦找到匹配项,它就会简单地启动匹配的文件。以前做过这样的事情吗?看起来很简单,但我似乎找不到任何东西。
编辑:Elliot 让我注意到了这一点:http://autohotkey.com/board/topic/60630-easy-editmanage-hotkeyshotstrings-plugin-ahk-l/
这是一个简洁的脚本管理器,非常有用,但它不是我想要的。
我不想要额外的界面。我希望能够使用文件名更改热键。
#Persistent
SetTimer, FindNewHotkeys, 2000
FindNewHotkeys:
Loop, %A_ScriptDir%\*
{
RegExMatch(A_LoopFileName, "^(.)(.).ahk$", hk)
If (hk)
Hotkey, ~%hk1% & ~%hk2%, HotkeyLabel
}
Return
HotkeyLabel:
MsgBox, A hotkey has been pressed!
Return
基于 。增加对应ahk脚本的执行。
#Persistent
SetTimer, FindNewHotkeys, 2000
FindNewHotkeys:
Loop, %A_ScriptDir%\*
{
RegExMatch(A_LoopFileName, "^(.)(.).ahk$", hk)
If (hk)
{
Hotkey, ~%hk1% & ~%hk2%, HotkeyLabel
}
}
Return
HotkeyLabel:
RegExMatch(A_ThisHotkey, "~(.) & ~(.)", hk)
run, %hk1%%hk2%.ahk
Return
我正在尝试为我们的员工制作一些东西,这样他们就不必更改脚本本身来定义热键。这可能只适用于可以由单个字符定义的热键,但这很好,因为可以用它们进行多种组合,而且它们很容易记住。该脚本只会查看工作目录中 2 个字符的 AHK 文件(如果必须包含扩展名,则为 6 个)。它要搜索的变量可以用 RegEx 定义,所以对于第一个热键,它看起来像 ^。然后第二个看起来像 .(?=.) 一旦找到匹配项,它就会简单地启动匹配的文件。以前做过这样的事情吗?看起来很简单,但我似乎找不到任何东西。
编辑:Elliot 让我注意到了这一点:http://autohotkey.com/board/topic/60630-easy-editmanage-hotkeyshotstrings-plugin-ahk-l/
这是一个简洁的脚本管理器,非常有用,但它不是我想要的。
我不想要额外的界面。我希望能够使用文件名更改热键。
#Persistent
SetTimer, FindNewHotkeys, 2000
FindNewHotkeys:
Loop, %A_ScriptDir%\*
{
RegExMatch(A_LoopFileName, "^(.)(.).ahk$", hk)
If (hk)
Hotkey, ~%hk1% & ~%hk2%, HotkeyLabel
}
Return
HotkeyLabel:
MsgBox, A hotkey has been pressed!
Return
基于
#Persistent
SetTimer, FindNewHotkeys, 2000
FindNewHotkeys:
Loop, %A_ScriptDir%\*
{
RegExMatch(A_LoopFileName, "^(.)(.).ahk$", hk)
If (hk)
{
Hotkey, ~%hk1% & ~%hk2%, HotkeyLabel
}
}
Return
HotkeyLabel:
RegExMatch(A_ThisHotkey, "~(.) & ~(.)", hk)
run, %hk1%%hk2%.ahk
Return