From 267b82c41f47fa8cfdbed62ebe7a335b3032a9a9 Mon Sep 17 00:00:00 2001 From: GenesisFR <3614449+GenesisFR@users.noreply.github.com> Date: Sat, 22 May 2021 20:00:01 -0400 Subject: [PATCH] + added a debug setting to close the script (ALT+F10) and reload it (ALT+F11) - keys are now only released when suspending the script --- KeyToggles.ahk | 24 ++++++++++++++++++++++-- KeyToggles.ini | 4 ++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/KeyToggles.ahk b/KeyToggles.ahk index 8ee7f3b..02c3ce8 100644 --- a/KeyToggles.ahk +++ b/KeyToggles.ahk @@ -235,7 +235,7 @@ IsMouseOverWindow(pHwnd) return pHwnd == mouseWindowID } -; Disable toggles on focus lost and optionally restore them on focus +; Hook the window and register hotkeys if necessary, disable toggles on focus lost and optionally restore them on focus OnFocusChanged() { global @@ -281,6 +281,7 @@ OnFocusChanged() else { OutputDebug, %A_ThisFunc%::saveToggleStates(%bRestoreAiming%, %bRestoreCrouching%, %bRestoreSprinting%) + bRestoreAiming := bAiming bRestoreCrouching := bCrouching bRestoreSprinting := bSprinting @@ -323,6 +324,9 @@ ReadConfigFile() IniRead, crouchAutofireKey, %configFileName%, Keys, crouchAutofireKey, F2 IniRead, sprintAutofireKey, %configFileName%, Keys, sprintAutofireKey, F3 + ; Debug + IniRead, bDebugMode, %configFileName%, Debug, debugMode, 0 + if (sWindowName == "put_window_name_here") ExitWithErrorMessage("You must specify a window name! The script will now exit.") } @@ -565,13 +569,30 @@ else return #IfWinActive +#If bDebugMode +; Exit script +!F10:: ; ALT+F10 +Suspend, Permit +ExitApp +return + +; Reload script +!F11:: ; ALT+F11 +Suspend, Permit +Reload +return +#If + ; Suspend script (useful when in menus) !F12:: ; ALT+F12 Suspend ; Single beep when suspended if (A_IsSuspended) +{ SoundBeep, 1000 + ReleaseAllKeys() +} ; Double beep when resumed else { @@ -579,5 +600,4 @@ else SoundBeep, 1000 } -ReleaseAllKeys() return diff --git a/KeyToggles.ini b/KeyToggles.ini index 0712e43..7b99db3 100644 --- a/KeyToggles.ini +++ b/KeyToggles.ini @@ -61,3 +61,7 @@ sprintKey=LShift aimAutofireKey=F1 crouchAutofireKey=F2 sprintAutofireKey=F3 + +[Debug] +; Enable debug functions such as closing (ALT+F10) or reloading (ALT+F11) the script (1 to enable) +debugMode=0 \ No newline at end of file