
With a simple AutoHotkey script, you can tell your computer to launch different programs on startup with different combinations of the Caps Lock, Num Lock and Scroll Lock functions turned on.
If you like to start up a bunch of programs when you log in, it can be a pain to click them all manually. And, if you have a few different combinations of programs you want to launch depending on the situation (say, a set of programs for work and a set of programs for personal use), you can’t just set them to launch at login, since your computer only allows you to specify one set of login items.
Using the open-source scripting language AutoHotkey, reader Scott created a script that checks the status of the Caps Lock, Num Lock and Scroll Lock keys and launches programs based on the combination of locks that are turned on. Just copy and paste this script into a new text file:
; Auto-Execute:
GoTo CheckKeyboardStatus
; On startup, this script checks the status of Numlock, Capslock, and Scrolllock.
; Depending on the unique combination of these 3 variables, 1 of 8 commands will be executed.
; The status is then reset (Numlock on, Capslock off, Scrolllock off)
;
; To use this script, place it in your startup folder.
; Then, every time you power up your computer, toggle the keyboard status
; to specify which apps you want to run at startup.
NumOffCapsOffScrollOff: ; Looks like: . . .
Run Notepad.exe
Run firefox.exe
Return
NumOnCapsOffScrollOff: ; Looks like: o . . (Default)
Run firefox.exe
Return
NumOffCapsOnScrollOff: ; Looks like: . o .
Run iexplore.exe
Return
NumOnCapsOnScrollOff: ; Looks like: o o .
Return
NumOffCapsOffScrollOn: ; Looks like: . . o
Return
NumOnCapsOffScrollOn: ; Looks like: o . o
Return
NumOffCapsOnScrollOn: ; Looks like: . o o
Return
NumOnCapsOnScrollOn: ; Looks like: o o o
Return
Save the text file as loginitems.ahk in your Startup folder (or call it whatever you want), and you’re set to go. You can customise the script to your liking by adding the name of your desired programs under a listed combination.
Now, when you turn on your computer, you can hit any combination of lock keys to specify which apps start. For example, the above script will launch Notepad and Firefox when you log into Windows with no locks enabled. Powering up with Num Lock turned on, however, launches just Firefox. With three lock keys at your disposal, you have up to eight combinations of programs that you can launch at login — more than enough for any digital workspace you may want to create. It will also reset the lock keys after it starts up the correct programs, so you don’t go start typing in Caps Lock by accident.



















noobie
Thursday, September 30, 2010 at 10:11 AMthe goto command is asking for a label which doesnt seem to exist in the code above, and therefore the script doesn’t seem to work. is the code missing a section or something?
i am an incredible code noob so help would be appreciated :)
Cedwa
Thursday, September 30, 2010 at 11:11 AMHey noobie,
While I’m no programmer a label in AutoHotKey is usually defined by the Label: command.
I would assume that the above program would work if you added a CheckKeyboardStatus: above the following line
NumOffCapsOffScrollOff: ; Looks like: . . .
But I make no promises. I only use autohotkey for automation on windows while I’m at work. So I don’t dabble with goto and gosub commands to often.
Damien
Thursday, September 30, 2010 at 12:21 PMI may also be wrong, but it appears like the whole function “CheckKeyboardStatus” is missing. This should do the actual check of the status of NumLock, CapsLock an ScrollLock and THAT should then call the appropriate labels as listed above. I’m at work so don’t have time to suss out how it would work (nested if’s?)
David
Thursday, September 30, 2010 at 7:05 PMHere I have fixed the code =] use this instead
; Auto-Execute:
GoTo CheckKeyboardStatus
; On startup, this script checks the status of Numlock, Capslock, and Scrolllock.
; Depending on the unique combination of these 3 variables, 1 of 8 commands will be executed.
; The status is then reset (Numlock on, Capslock off, Scrolllock off)
;
; To use this script, place it in your startup folder.
; Then, every time you power up your computer, toggle the keyboard status
; to specify which apps you want to run at startup.
NumOffCapsOffScrollOff: ; Looks like: . . .
Run Notepad.7exe
Run firefox.exe
Return
NumOnCapsOffScrollOff: ; Looks like: o . . (Default)
Run firefox.exe
Return
NumOffCapsOnScrollOff: ; Looks like: . o .
Run iexplore.exe
Return
NumOnCapsOnScrollOff: ; Looks like: o o .
Return
NumOffCapsOffScrollOn: ; Looks like: . . o
Return
NumOnCapsOffScrollOn: ; Looks like: o . o
Return
NumOffCapsOnScrollOn: ; Looks like: . o o
Return
NumOnCapsOnScrollOn: ; Looks like: o o o
Return
CheckKeyboardStatus:
_Capslock := GetKeyState(“Capslock”, “T”)
_Numlock := GetKeyState(“Numlock”, “T”)
_Scrolllock := GetKeyState(“ScrollLock”, “T”)
if ( Not _Numlock and Not _Capslock and Not _Scrolllock )
GoTo, NumOffCapsOffScrollOff
else if ( _Numlock and Not _Capslock and Not _Scrolllock )
GoTo, NumOnCapsOffScrollOff
else if ( Not _Numlock and _Capslock and Not _Scrolllock )
GoTo, NumOffCapsOnScrollOff
else if ( _Numlock and _Capslock and Not _Scrolllock )
GoTo, NumOnCapsOnScrollOff
else if ( Not _Numlock and Not _Capslock and _Scrolllock )
GoTo, NumOffCapsOffScrollOn
else if ( _Numlock and Not _Capslock and _Scrolllock )
GoTo, NumOnCapsOffScrollOn
else if ( Not _Numlock and _Capslock and _Scrolllock )
GoTo, NumOffCapsOnScrollOn
else if ( _Numlock and _Capslock and _Scrolllock )
GoTo, NumOnCapsOnScrollOn
return