-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hotkeys.ahk
35 lines (33 loc) · 996 Bytes
/
Hotkeys.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
Extended library for Hotkeys.
(c) 2022-2024 Ken Verdadero
2022-11-11
*/
/**
* Sets a hotkey with an optional HotIf
* @param keyName the hotkey to set
* @param callback the function to call when the hotkey is pressed
* @param {String} options
* @param {String} hotIf the HotIf to use
* @param {String} hotIfValue the value to use for the HotIf
*/
HotkeySet(keyName, callback, options := '', hotIf := '', hotIfValue := '') {
if !StrLen(hotIf) {
Hotkey(keyName, callback, options)
return
}
switch StrLower(hotIf) {
case "a": HotIfWinactive(hotIfValue)
case "na": HotIfWinNotactive(hotIfValue)
case "x": HotIfWinExist(hotIfValue)
case "nx": HotIfWinNotExist(hotIfValue)
}
Hotkey(keyName, callback, options)
switch StrLower(hotIf) {
case "a": HotIfWinactive('')
case "na": HotIfWinNotactive('')
case "x": HotIfWinExist('')
case "nx": HotIfWinNotExist('')
}
return
}