Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; This old script is here to archive and a quick reference for me ;
- ; a rewrite is in the works ;
- ; This script toggles hotkeys and/or suspends AutoHotkey scripts and;
- ; programs by hotkeys or by system tray. ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- _title:="AutoHotkey Script Toggler"
- Menu,Tray,NoStandard
- Menu, Tray, Add, %_title%, TitleInfo
- Menu, Tray, Add
- Menu, Tray, Add, Suspend Hotkeys, Hotkeys
- Menu, Tray, Add, Pause Scripts, Scripts
- Menu, Tray, Add, Toggle Both All Scripts, Both
- Menu, Tray, Add
- Menu, Tray, Add, Help, Help
- Menu, Tray, Add
- Menu, Tray, Add, Exit, Close
- If A_IsCompiled
- Menu, Tray, Icon, %_title%, %A_ScriptFullPath%,1
- Else
- Menu, Tray, Icon, %_title%, shell32.dll, 138
- Menu, Tray, Icon, Help, shell32.dll, 24
- Menu, Tray, Icon, Suspend Hotkeys, shell32.dll, 216
- Menu, Tray, Icon, Pause Scripts, shell32.dll, 216
- Menu, Tray, Icon, Toggle Both All Scripts, shell32.dll, 216
- Menu, Tray, Icon, Exit,shell32.dll, 216
- SetBatchLines,-1
- #ScrollLock::Gosub, Scripts
- #Pause::Gosub, Hotkeys
- #PrintScreen::Gosub, Both
- ToggleScripts(state:="Pause",name:=0,exception:=0){
- mode:=(name And exception)?2:name?1:0
- If ! state:=(InStr(state,"pause") Or state=65306)?65306
- :(InStr(state,"suspend") Or state=65305)?65305
- :0 {
- MsgBox,16,%A_ThisFunc% Error, % "Improper toggle state passed into variable: state"
- . "`nE.g.: " A_ThisFunc "() - defaults to " A_ThisFunc "(""Pause"")"
- . "`n`nPossible options: "
- . "`nPause script/s:" A_Tab """Pause"" or 65306"
- . "`nSuspend script/s:" A_Tab """Suspend"" or 65305"
- Return
- }
- DetectHiddenWindows On
- WinGet, id_list, List, ahk_class AutoHotkey
- Loop, %id_list%
- {
- this_id := id_list%A_Index%
- If (mode=2) {
- WinGetTitle,this_title,ahk_id %this_id%
- If IsObject(name){
- For index, fname in name {
- If InStr(this_title,fname) {
- nBreak:=1
- Break
- } Else nBreak:=0
- }
- } Else {
- If InStr(this_title,name) {
- nBreak:=1
- } Else nBreak:=0
- }
- }
- If nBreak
- Continue
- If (mode=1) {
- WinGetTitle,this_title,ahk_id %this_id%
- If IsObject(name){
- For index, fname in name {
- If InStr(this_title,fname)
- PostMessage, 0x111, %state%,,, ahk_id %this_id%
- }
- } Else {
- If InStr(this_title,name)
- PostMessage, 0x111, %state%,,, ahk_id %this_id%
- }
- }
- Else
- PostMessage, 0x111, %state%,,, ahk_id %this_id%
- }
- DetectHiddenWindows, Off
- }
- TitleInfo:
- MsgBox,64,%_title% Info,%_title% by Ian Pride 2017`naka Lateralus138 aka FluxApex
- Return
- Hotkeys:
- ToggleScripts("Suspend",A_ScriptName,1)
- If tog:=!tog {
- If A_IsCompiled
- Menu, Tray, Icon, Suspend Hotkeys, %A_ScriptFullPath%,1
- Else
- Menu, Tray, Icon, Suspend Hotkeys, shell32.dll, 138
- Menu, Tray, Rename, Suspend Hotkeys,Resume Hotkeys
- } Else {
- Menu, Tray, Icon, Resume Hotkeys, shell32.dll, 216
- Menu, Tray, Rename,Resume Hotkeys, Suspend Hotkeys
- }
- Return
- Scripts:
- ToggleScripts(,A_ScriptName,1)
- If tog2:=!tog2 {
- If A_IsCompiled
- Menu, Tray, Icon, Pause Scripts, %A_ScriptFullPath%,1
- Else
- Menu, Tray, Icon, Pause Scripts, shell32.dll, 138
- Menu, Tray, Rename, Pause Scripts,Un-Pause Scripts
- } Else {
- Menu, Tray, Icon, Un-Pause Scripts, shell32.dll, 216
- Menu, Tray, Rename,Un-Pause Scripts, Pause Scripts
- }
- Return
- Both:
- Gosub,Hotkeys
- Gosub,Scripts
- Return
- Help:
- MsgBox,64,%_title% Help, % "Disable/enable script and hotkeys in all other AutoHotkey"
- . "`nprograms and scripts."
- . "`n`nHotkeys:"
- . "`nWindows Key+ScrollLock:" A_Tab "Suspend/Resume Hotkeys"
- . "`nWindows Key+Pause:" A_Tab "Pause/Un-Pause Scripts"
- . "`nWindows Key+PrintScreen:" A_Tab "Toggle Both For all"
- . "`n`nCan also be toggled from the system tray menu."
- Return
- Close:
- ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement