I got it to work the way I want it but I'm not sure if the script is very efficient.
Code: Select all
#NoEnv
#SingleInstance Force
; SendMode Input
; SetBatchLines -1
Gui Switcher: New, +AlwaysOnTop +HwndhSwitcher, Keymap Switcher
Gui Add, Text, xm ym, Keymap #:
Gui Add, Text, ym +HwndhKeymapLabel
Gui Add, Radio, xm gRadioEventHandler vRadioSelection Checked Group, 1
Gui Add, Radio, gRadioEventHandler, 2
Gui Add, Radio, gRadioEventHandler, 3
Gui Add, Radio, gRadioEventHandler, 4
Gui Add, Radio, gRadioEventHandler, 5
Gui Show, xCenter yCenter w300 h150 NoActivate
Gosub RadioEventHandler
Return
Esc::
SwitcherGuiClose:
SwitcherGuiEscape:
ExitApp
Return
RadioEventHandler:
Gui Switcher: Submit, NoHide
swapKeymap(RadioSelection)
GuiControl Text, % hKeymapLabel, % RadioSelection
Return
swapKeymap(i) {
static Keymap := {"b": [Func("function1"), "yuo", "1_three", "1_four", "1_five"]
, "g": ["", "azet", "2_three", "2_four", "2_five"]}
for key, SendMsg in Keymap
{
if SendMsg[i] = & !IsFunc(SendMsg[i])
{
Hotkey % key, Off, UseErrorLevel
if ErrorLevel in 5
return
return
}
else
{
fn := Func("customSend").Bind(SendMsg[i])
Hotkey % key, % fn
}
}
}
customSend(msg) {
key := A_ThisHotkey
while(GetKeyState(key))
{
if IsFunc(msg) {
msg.Call()
} else {
Send % msg
Sleep 2
}
}
}
function1()
{
Send r
Sleep 400
Send t
Sleep 220
Send f
Sleep 310
}
I can now add the few multi-line macro's I have as functions while keeping the rest as they are. Also in addition I can opt for an empty string "" if I don't want to make a macro for a certain key. (first radiobutton g-key for example, will work as a normal "g" instead of a hotkey).
This now works as I want it to work. If there's any improvements I can make, let me know. Special thanks to swagfag for guiding me towards my solution.