I use an on-screen keyboard to type math notes. I defined some of its buttons as hotkey combos, effectively creating touch-screen macros like this:
^!2::send tan
^!3::send cos
^!4::send, sin
^!5::send csc
^!6::send sec
^!0::send cot
I need to toggle these hotkeys ON when (and only when) clicking the left mouse button, to make sure the correct macros on the touch screen keyboard are sent (and my normal keys on the keyboard are active at any other time.)
The following code worked, except for one macro that toggles device management software that I use (DevManView). That software toggle only works reliably when the script is not suspended.
Suspend, on
~LButton::suspend, off
~lbutton up::
sleep, 50
suspend, on
return
So I am looking for another way to toggle these macros without suspending the entire script. It will also teach me a thing or two about loop parsing.
keys:="^!,¢^!\¢^!1¢^!8¢^!`¢^!2¢^!3¢^!4¢^!5¢^!6¢^!0¢^!.¢@¢^@¢^#¢^$¢^+5¢^^¢^*¢^`"
Loop,Parse,keys, ¢ ;create the hotkeys
Hotkey,$%A_loopField%,MEOK_MACROS
Loop,Parse,keys ;turn them off
Hotkey,$%A_loopField%,Off
~LButton::
sleep, 50
Loop,Parse,keys ;toggle hotkeys
Hotkey,$%A_loopField%,Toggle
return
MEOK_MACROS:
Send % InStr(keys,SubStr(A_ThisHotkey,0))
return
I want to put all the control+alt+(key) & control+(key) macros I created into one string, then toggle them on and off with ~LButton. Can you point out where I went wrong here?