@@ -412,41 +412,50 @@ Positioning_ChangedModeSelection(radio, *) {
412412
413413Hotkeys_updateHotkeyBindings () {
414414 AutoclickerGui[" Hotkeys_HotkeyList_ListView" ].Delete ()
415+
415416 local hotkeyData
416417 for hotkeyData in configured_hotkeys {
417418 AutoclickerGui[" Hotkeys_HotkeyList_ListView" ].Add(
418- , hotkeyData.Action = 1 ? " Start" : " Stop"
419+ , hotkeyData.Action = 1 ? " Start"
420+ : hotkeyData.Action = 2 ? " Stop"
421+ : hotkeyData.Action = 3 ? " Toggle"
422+ : " Close"
419423 , hotkeyData.Scope = 1 ? " Yes" : " No"
420424 , hotkeyData.HotkeyText
421425 )
422426
423- Hotkey hotkeyData.Hotkey , hotkeyData.Action = 1 ? Hotkey_start : Hotkey_stop
424- , are_hotkeys_active ? " On" : " Off"
427+ #MaxThreadsPerHotkey 2 ; needed for Toggle Autoclicker to work
428+ Hotkey hotkeyData.Hotkey , HotkeyEvent, are_hotkeys_active ? " On" : " Off"
429+ #MaxThreadsPerHotkey
425430
426- getHotkeyData (hotkey ) {
431+ HotkeyEvent (hotkey ) {
432+ local hotkeyData
427433 local hDat
428434 for hDat in configured_hotkeys {
429- if hDat.Hotkey = hotkey
430- return hDat
435+ if hDat.Hotkey = hotkey {
436+ hotkeyData := hDat
437+ break
438+ }
431439 }
432- }
433- Hotkey_start (hotkey ) {
434- static hotkeyData
435- if ! IsSet(hotkeyData)
436- hotkeyData := getHotkeyData(hotkey )
437- if hotkeyData.Scope = 2 && ! WinActive (" ahk_id " AutoclickerGui.Hwnd)
438- return
439- if ! is_autoclicking
440- Start()
441- }
442- Hotkey_stop (hotkey ) {
443- static hotkeyData
444- if ! IsSet(hotkeyData)
445- hotkeyData := getHotkeyData(hotkey )
440+
446441 if hotkeyData.Scope = 2 && ! WinActive (" ahk_id " AutoclickerGui.Hwnd)
447442 return
448- if is_autoclicking
449- Stop()
443+
444+ switch hotkeyData.Action {
445+ case 1 :
446+ if ! is_autoclicking
447+ Start()
448+ case 2 :
449+ if is_autoclicking
450+ Stop()
451+ case 3 :
452+ if is_autoclicking
453+ Stop()
454+ else
455+ Start()
456+ case 4 :
457+ Close()
458+ }
450459 }
451460 }
452461}
@@ -469,11 +478,13 @@ Hotkeys_AddHotkey(*) {
469478 KeyBinderGui.AddDropDownList " x54 yp w180 vHotkeyScopeDropDownList"
470479 , [" Globally" , " Only when Autoclicker is focused" ]
471480
472- KeyBinderGui.AddGroupBox " xm w134 Section" , " Action"
473- KeyBinderGui.AddRadio " xp+10 yp+20 vHotkeyActionRadio" , " Start Autoclicker"
474- KeyBinderGui.AddRadio " xp" , " Stop Autoclicker"
481+ KeyBinderGui.AddGroupBox " xm w134 r4 Section" , " Action"
482+ KeyBinderGui.AddRadio " xp+10 yp+20 vHotkeyActionStartRadio" , " Start Autoclicker"
483+ KeyBinderGui.AddRadio " xp vHotkeyActionStopRadio" , " Stop Autoclicker"
484+ KeyBinderGui.AddRadio " xp vHotkeyActionToggleRadio" , " Toggle Autoclicker"
485+ KeyBinderGui.AddRadio " xp" , " Close Autoclicker"
475486
476- KeyBinderGui.AddButton(" ys+6 w80 Default" , " OK" )
487+ KeyBinderGui.AddButton(" ys+43 w80 Default" , " OK" )
477488 .OnEvent(" Click" , Submit )
478489 KeyBinderGui.AddButton(" xp wp" , " Cancel" )
479490 .OnEvent(" Click" , (* ) => hideOwnedGui(KeyBinderGui))
@@ -483,7 +494,7 @@ Hotkeys_AddHotkey(*) {
483494
484495 KeyBinderGui[" Hotkey" ].Value := " ^F2"
485496 KeyBinderGui[" HotkeyScopeDropDownList" ].Choose(1 )
486- KeyBinderGui[" HotkeyActionRadio " ].Value := 1
497+ KeyBinderGui[" HotkeyActionStartRadio " ].Value := 1
487498 showGuiAtAutoclickerGuiPos KeyBinderGui
488499 KeyBinderGui[" Hotkey" ].Focus()
489500
@@ -494,7 +505,7 @@ Hotkeys_AddHotkey(*) {
494505
495506 local hotkeyData
496507 for hotkeyData in configured_hotkeys {
497- if KeyBinderGui[" Hotkey" ].Value = hotkeyData.Hotkey {
508+ if " ~ " KeyBinderGui[" Hotkey" ].Value = hotkeyData.Hotkey {
498509 if MsgBox (" The hotkey '" hotkeyText " ' is already in use. Would you like to overwrite it?"
499510 , " Overwrite Hotkey" , " YesNo Iconi 8192"
500511 ) = " Yes"
@@ -509,7 +520,10 @@ Hotkeys_AddHotkey(*) {
509520 Hotkey : " ~" KeyBinderGui[" Hotkey" ].Value,
510521 HotkeyText: hotkeyText,
511522 Scope: KeyBinderGui[" HotkeyScopeDropDownList" ].Value,
512- Action: KeyBinderGui[" HotkeyActionRadio" ].Value = 1 ? 1 : 2
523+ Action: KeyBinderGui[" HotkeyActionStartRadio" ].Value = 1 ? 1
524+ : KeyBinderGui[" HotkeyActionStopRadio" ].Value = 1 ? 2
525+ : KeyBinderGui[" HotkeyActionToggleRadio" ].Value = 1 ? 3
526+ : 4
513527 }
514528 add_log " Added hotkey: " hotkeyText
515529 Hotkeys_updateHotkeyBindings
@@ -776,7 +790,7 @@ ProfileManage(*) {
776790
777791 RegCreateKey REG_KEY_PATH " \Profiles\" profileName
778792
779- local e
793+ local err
780794 try {
781795 Loop Parse FileRead (fileLocation), " `n" {
782796 if ! A_LoopField
@@ -791,16 +805,16 @@ ProfileManage(*) {
791805 RegWrite configMatch[" Value" ], configMatch[" Name" ] ~ = " DateTime" ? " REG_SZ" : " REG_DWORD"
792806 , REG_KEY_PATH " \Profiles\" profileName, configMatch[" Name" ]
793807 }
794- } catch as e {
795- add_log " Import Profile error: " e .Message
808+ } catch as err {
809+ add_log " Import Profile error: " err .Message
796810 try RegDeleteKey REG_KEY_PATH " \Profiles\" profileName
797811 MsgBox Format ("
798812 (
799813An error occurred whilst importing the profile '{}' from {}.
800814This is usually due to the file's data being corrupt or invalid.
801815
802816Message: {}
803- )" , profileName, fileLocation, e .Message), " Import Profile" , " Iconx 8192 "
817+ )" , profileName, fileLocation, err .Message), " Import Profile" , " Iconx 8192 "
804818 return
805819 }
806820
@@ -823,6 +837,7 @@ ProfileLoad(profileName, *) {
823837
824838 add_log " Configuration imported"
825839
840+ local err
826841 try {
827842 local name, value
828843 for name, value in currentConfig.OwnProps() {
@@ -861,15 +876,15 @@ ProfileLoad(profileName, *) {
861876 }
862877 }
863878 add_log " Configuration GUI updated from profile"
864- } catch as e {
865- add_log " Load Profile error: " e .Message
879+ } catch as err {
880+ add_log " Load Profile error: " err .Message
866881 MsgBox Format ("
867882 (
868883An error occurred whilst loading the profile '{}'.
869884This is likely due to corrupt data.
870885
871886Message: {}
872- )" , profileName, e .Message), " Load Profile" , " Iconx 8192 "
887+ )" , profileName, err .Message), " Load Profile" , " Iconx 8192 "
873888 }
874889 return
875890 }
@@ -1045,7 +1060,7 @@ Start(*) {
10451060 add_log " Stopping automatically"
10461061 Stop
10471062 switch currentConfig.Scheduling_PostStopAction_DropDownList {
1048- case 2 : ExitApp
1063+ case 2 : Close()
10491064 case 3 :
10501065 if WinExist (" A" )
10511066 WinClose
@@ -1124,10 +1139,11 @@ Your current version is {}. Would you like to update now?
11241139
11251140 add_log " Downloading file"
11261141
1142+ local err
11271143 try Download " https://github.com/" GITHUB_REPO " /releases/latest/download/EC-Autoclicker.exe"
11281144 , downloadFilePath
1129- catch as e
1130- MsgBox " An error occurred in attempting to download the latest version of EC Autoclicker.`n`nMessage: " e .Message
1145+ catch as err
1146+ MsgBox " An error occurred in attempting to download the latest version of EC Autoclicker.`n`nMessage: " err .Message
11311147 , " Update" , " Iconx 262144"
11321148 else {
11331149 add_log(" File downloaded" )
@@ -1136,7 +1152,7 @@ Your current version is {}. Would you like to update now?
11361152 . 'Rename - Item - LiteralPath " ' downloadFilePath '" - NewName " ' A_ScriptName '" ;'
11371153 . 'Start- Process - FilePath " ' A_ScriptDir '\EC-Autoclicker.exe /updated" '
11381154 , , " Hide"
1139- ExitApp
1155+ Close()
11401156 }
11411157 }
11421158}
@@ -1153,7 +1169,7 @@ OptionsMenu.Add
11531169OptionsMenu.Add SZ_TABLE.Menu_Options_ResetToDefault, ResetOptionsToDefault
11541170
11551171AutoclickerGui.Show " x0"
1156- add_log " Welcome to EC Autoclicker "
1172+ add_log " Showed main GUI "
11571173
11581174if A_IsCompiled {
11591175 if A_Args.Length > 0 && A_Args[1 ] = " /updated" {
0 commit comments