@@ -412,41 +412,50 @@ Positioning_ChangedModeSelection(radio, *) {
412
412
413
413
Hotkeys_updateHotkeyBindings () {
414
414
AutoclickerGui[" Hotkeys_HotkeyList_ListView" ].Delete ()
415
+
415
416
local hotkeyData
416
417
for hotkeyData in configured_hotkeys {
417
418
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"
419
423
, hotkeyData.Scope = 1 ? " Yes" : " No"
420
424
, hotkeyData.HotkeyText
421
425
)
422
426
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
425
430
426
- getHotkeyData (hotkey ) {
431
+ HotkeyEvent (hotkey ) {
432
+ local hotkeyData
427
433
local hDat
428
434
for hDat in configured_hotkeys {
429
- if hDat.Hotkey = hotkey
430
- return hDat
435
+ if hDat.Hotkey = hotkey {
436
+ hotkeyData := hDat
437
+ break
438
+ }
431
439
}
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
+
446
441
if hotkeyData.Scope = 2 && ! WinActive (" ahk_id " AutoclickerGui.Hwnd)
447
442
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
+ }
450
459
}
451
460
}
452
461
}
@@ -469,11 +478,13 @@ Hotkeys_AddHotkey(*) {
469
478
KeyBinderGui.AddDropDownList " x54 yp w180 vHotkeyScopeDropDownList"
470
479
, [" Globally" , " Only when Autoclicker is focused" ]
471
480
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"
475
486
476
- KeyBinderGui.AddButton(" ys+6 w80 Default" , " OK" )
487
+ KeyBinderGui.AddButton(" ys+43 w80 Default" , " OK" )
477
488
.OnEvent(" Click" , Submit )
478
489
KeyBinderGui.AddButton(" xp wp" , " Cancel" )
479
490
.OnEvent(" Click" , (* ) => hideOwnedGui(KeyBinderGui))
@@ -483,7 +494,7 @@ Hotkeys_AddHotkey(*) {
483
494
484
495
KeyBinderGui[" Hotkey" ].Value := " ^F2"
485
496
KeyBinderGui[" HotkeyScopeDropDownList" ].Choose(1 )
486
- KeyBinderGui[" HotkeyActionRadio " ].Value := 1
497
+ KeyBinderGui[" HotkeyActionStartRadio " ].Value := 1
487
498
showGuiAtAutoclickerGuiPos KeyBinderGui
488
499
KeyBinderGui[" Hotkey" ].Focus()
489
500
@@ -494,7 +505,7 @@ Hotkeys_AddHotkey(*) {
494
505
495
506
local hotkeyData
496
507
for hotkeyData in configured_hotkeys {
497
- if KeyBinderGui[" Hotkey" ].Value = hotkeyData.Hotkey {
508
+ if " ~ " KeyBinderGui[" Hotkey" ].Value = hotkeyData.Hotkey {
498
509
if MsgBox (" The hotkey '" hotkeyText " ' is already in use. Would you like to overwrite it?"
499
510
, " Overwrite Hotkey" , " YesNo Iconi 8192"
500
511
) = " Yes"
@@ -509,7 +520,10 @@ Hotkeys_AddHotkey(*) {
509
520
Hotkey : " ~" KeyBinderGui[" Hotkey" ].Value,
510
521
HotkeyText: hotkeyText,
511
522
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
513
527
}
514
528
add_log " Added hotkey: " hotkeyText
515
529
Hotkeys_updateHotkeyBindings
@@ -776,7 +790,7 @@ ProfileManage(*) {
776
790
777
791
RegCreateKey REG_KEY_PATH " \Profiles\" profileName
778
792
779
- local e
793
+ local err
780
794
try {
781
795
Loop Parse FileRead (fileLocation), " `n" {
782
796
if ! A_LoopField
@@ -791,16 +805,16 @@ ProfileManage(*) {
791
805
RegWrite configMatch[" Value" ], configMatch[" Name" ] ~ = " DateTime" ? " REG_SZ" : " REG_DWORD"
792
806
, REG_KEY_PATH " \Profiles\" profileName, configMatch[" Name" ]
793
807
}
794
- } catch as e {
795
- add_log " Import Profile error: " e .Message
808
+ } catch as err {
809
+ add_log " Import Profile error: " err .Message
796
810
try RegDeleteKey REG_KEY_PATH " \Profiles\" profileName
797
811
MsgBox Format ("
798
812
(
799
813
An error occurred whilst importing the profile '{}' from {}.
800
814
This is usually due to the file's data being corrupt or invalid.
801
815
802
816
Message: {}
803
- )" , profileName, fileLocation, e .Message), " Import Profile" , " Iconx 8192 "
817
+ )" , profileName, fileLocation, err .Message), " Import Profile" , " Iconx 8192 "
804
818
return
805
819
}
806
820
@@ -823,6 +837,7 @@ ProfileLoad(profileName, *) {
823
837
824
838
add_log " Configuration imported"
825
839
840
+ local err
826
841
try {
827
842
local name, value
828
843
for name, value in currentConfig.OwnProps() {
@@ -861,15 +876,15 @@ ProfileLoad(profileName, *) {
861
876
}
862
877
}
863
878
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
866
881
MsgBox Format ("
867
882
(
868
883
An error occurred whilst loading the profile '{}'.
869
884
This is likely due to corrupt data.
870
885
871
886
Message: {}
872
- )" , profileName, e .Message), " Load Profile" , " Iconx 8192 "
887
+ )" , profileName, err .Message), " Load Profile" , " Iconx 8192 "
873
888
}
874
889
return
875
890
}
@@ -1045,7 +1060,7 @@ Start(*) {
1045
1060
add_log " Stopping automatically"
1046
1061
Stop
1047
1062
switch currentConfig.Scheduling_PostStopAction_DropDownList {
1048
- case 2 : ExitApp
1063
+ case 2 : Close()
1049
1064
case 3 :
1050
1065
if WinExist (" A" )
1051
1066
WinClose
@@ -1124,10 +1139,11 @@ Your current version is {}. Would you like to update now?
1124
1139
1125
1140
add_log " Downloading file"
1126
1141
1142
+ local err
1127
1143
try Download " https://github.com/" GITHUB_REPO " /releases/latest/download/EC-Autoclicker.exe"
1128
1144
, 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
1131
1147
, " Update" , " Iconx 262144"
1132
1148
else {
1133
1149
add_log(" File downloaded" )
@@ -1136,7 +1152,7 @@ Your current version is {}. Would you like to update now?
1136
1152
. 'Rename - Item - LiteralPath " ' downloadFilePath '" - NewName " ' A_ScriptName '" ;'
1137
1153
. 'Start- Process - FilePath " ' A_ScriptDir '\EC-Autoclicker.exe /updated" '
1138
1154
, , " Hide"
1139
- ExitApp
1155
+ Close()
1140
1156
}
1141
1157
}
1142
1158
}
@@ -1153,7 +1169,7 @@ OptionsMenu.Add
1153
1169
OptionsMenu.Add SZ_TABLE.Menu_Options_ResetToDefault, ResetOptionsToDefault
1154
1170
1155
1171
AutoclickerGui.Show " x0"
1156
- add_log " Welcome to EC Autoclicker "
1172
+ add_log " Showed main GUI "
1157
1173
1158
1174
if A_IsCompiled {
1159
1175
if A_Args.Length > 0 && A_Args[1 ] = " /updated" {
0 commit comments