Created
December 14, 2015 23:04
-
-
Save stevereich/d20146e307803098bee5 to your computer and use it in GitHub Desktop.
Boss Key Autohotkey Script - Minimize or Lock Windows with one click on tray icon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Auto Execute Section Starts Here;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;Allow only one instance to run | |
#SingleInstance force | |
#Persistent | |
;Set tray tip and tray menu | |
Menu, MySubmenu, Add, Minimize Windows, setDefaultAction | |
Menu, MySubmenu, Add, Lock Workstation, setDefaultAction | |
Menu, Tray, NoStandard | |
Menu, Tray, Tip, Windows Key. | |
Menu, Tray, Add, Execute, launchDefault | |
Menu, Tray, Add ;draw a line | |
Menu, Tray, Add, Set Default Action, :MySubmenu | |
Menu, Tray, Add, Run on Startup`?, startUpReg | |
Menu, Tray, Add, Exit, exitMe | |
Menu, Tray, Default, Execute | |
Menu, Tray, Click, 1 | |
defaultBossAction := 0 | |
; set default boss key action | |
RegRead, setDefault, HKCU, SOFTWARE\BossKey, defaultAction | |
if (ErrorLevel <> 1) { | |
if (setDefault = "boss") { | |
RegWrite, REG_SZ, HKCU, SOFTWARE\BossKey, defaultAction, boss | |
Menu, MySubmenu, Check, Minimize Windows | |
Menu, MySubmenu, UnCheck, Lock Workstation | |
defaultBossAction := 0 | |
} | |
else if (setDefault = "lock") { | |
RegWrite, REG_SZ, HKCU, SOFTWARE\BossKey, defaultAction, lock | |
Menu, MySubmenu, UnCheck, Minimize Windows | |
Menu, MySubmenu, Check, Lock Workstation | |
defaultBossAction := 1 | |
} | |
} | |
else{ | |
RegWrite, REG_SZ, HKCU, SOFTWARE\BossKey, defaultAction, boss | |
Menu, MySubmenu, Check, Minimize Windows | |
Menu, MySubmenu, UnCheck, Lock Workstation | |
} | |
; check menu status of start up option | |
RegRead, startUp, HKCU, SOFTWARE\Microsoft\Windows\CurrentVersion\Run, BossKey | |
if (ErrorLevel <> 1) { | |
Menu, Tray, Check, Run on Startup`? | |
} | |
return | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Start Scripts;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;set registry key to run at startup | |
startUpReg: | |
RegRead, startUp, HKCU, SOFTWARE\Microsoft\Windows\CurrentVersion\Run, BossKey | |
if ErrorLevel { | |
RegWrite, REG_SZ, HKCU, SOFTWARE\Microsoft\Windows\CurrentVersion\Run, BossKey, %A_ScriptFullPath% | |
Menu, Tray, Check, %A_ThisMenuItem% | |
} | |
else{ | |
RegDelete, HKCU, SOFTWARE\Microsoft\Windows\CurrentVersion\Run, BossKey | |
if errorlevel { | |
reload | |
} | |
Menu, Tray, Uncheck, %A_ThisMenuItem% | |
} | |
setDefaultAction: | |
intent = %A_ThisMenuItem% | |
if(intent = "Minimize Windows"){ | |
RegWrite, REG_SZ, HKCU, SOFTWARE\BossKey, defaultAction, boss | |
Menu, MySubmenu, Check, Minimize Windows | |
Menu, MySubmenu, UnCheck, Lock Workstation | |
defaultBossAction := 0 | |
} | |
else if(intent = "Lock Workstation"){ | |
RegWrite, REG_SZ, HKCU, SOFTWARE\BossKey, defaultAction, lock | |
Menu, MySubmenu, UnCheck, Minimize Windows | |
Menu, MySubmenu, Check, Lock Workstation | |
defaultBossAction := 1 | |
} | |
return | |
launchDefault: | |
if(defaultBossAction = 1){ | |
DllCall("LockWorkStation") | |
return | |
} | |
else{ | |
send, #d | |
return | |
} | |
exitMe: | |
sayBye() | |
return | |
sayBye(){ | |
ExitApp | |
} | |
ExitApp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment