0
votes

I've got a script running which binds numpad numbers to inline numbers (in order to easily add Unicode chars on the fly because I'm on a laptop without the numpad) and that also binds Home and End to Ctrl+Left and Ctrl+Right respectively. Now, the whole script can be paused by pressing the Apps key, but I'd like the numpad bindings to be the only part toggled and keep Ctrl+Arrows binding always running instead. How can I modify this script to do that?

#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

^Left::Send {Home}
+^Left::Send {LShift down}{Home}{LShift up}
^Right::Send {End}
+^Right::Send {LShift down}{End}{LShift up}

0::Numpad0
1::Numpad1
2::Numpad2
3::Numpad3 
4::Numpad4
5::Numpad5
6::Numpad6
7::Numpad7
8::Numpad8
9::Numpad9

Appskey::
Suspend,Toggle
return
1

1 Answers

1
votes
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance Force

 ; These hotkeys are always active (even if the script is suspended):

^Left::
    Suspend Toggle
    Send {Home}
    Suspend Toggle
return

+^Left::
    Suspend Toggle
    Send {LShift down}{Home}{LShift up}
    Suspend Toggle
return

^Right::
    Suspend Toggle
    Send {End}
    Suspend Toggle
return

+^Right::
    Suspend Toggle
    Send {LShift down}{End}{LShift up}
    Suspend Toggle
return

Appskey:: Suspend,Toggle


; These hotkeys are inactive if the script is suspended:

0::Numpad0
1::Numpad1
2::Numpad2
3::Numpad3
4::Numpad4
5::Numpad5
6::Numpad6
7::Numpad7
8::Numpad8
9::Numpad9

https://autohotkey.com/docs/commands/Suspend.htm#Remarks:

Any hotkey/hotstring subroutine whose very first line is Suspend (except Suspend On) will be exempt from suspension. In other words, the hotkey will remain enabled even while suspension is ON. This allows suspension to be turned off via such a hotkey.