Skip to content

Commit 8accadd

Browse files
committed
Add Simplified View feature
- New option under the Options menu to toggle Simplified View - Improve profiles refresh functionality to support Simplified View
1 parent e110337 commit 8accadd

File tree

1 file changed

+67
-19
lines changed

1 file changed

+67
-19
lines changed

EC-Autoclicker.ahk

Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ GITHUB_REPO := "Expertcoderz/EC-Autoclicker"
1111

1212
FILE_EXT := ".ac-profile"
1313
REG_KEY_PATH := "HKCU\Software\Expertcoderz\Autoclicker"
14-
RegCreateKey REG_KEY_PATH "\Profiles"
1514

1615
SZ_TABLE := {
1716
; Menus
@@ -27,6 +26,7 @@ SZ_TABLE := {
2726
Menu_Profiles_Create: "&Save...",
2827
Menu_Profiles_Manage: "&Manage",
2928
; Options Menu
29+
Menu_Options_SimplifiedView: "&Simplified View",
3030
Menu_Options_AlwaysOnTop: "&Always On Top",
3131
Menu_Options_MinButtonVisible: "&Minimize Button Visible",
3232
Menu_Options_EscToClose: "&ESC To Close",
@@ -60,6 +60,7 @@ SZ_TABLE := {
6060

6161
program_logs := []
6262
is_autoclicking := false
63+
is_simplified_view_on := false
6364
is_always_on_top_on := true
6465

6566
configured_hotkeys := []
@@ -106,22 +107,16 @@ FileMenu.Add(SZ_TABLE.Menu_File_Logs, LogsOpen)
106107
FileMenu.Add(SZ_TABLE.Menu_File_Exit, Close)
107108

108109
ProfilesMenu := Menu()
109-
setupProfiles() {
110-
ProfilesMenu.Delete()
111-
ProfilesMenu.Add(SZ_TABLE.Menu_Profiles_Create, ProfileCreate)
112-
ProfilesMenu.Add(SZ_TABLE.Menu_Profiles_Manage, ProfileManage)
113-
ProfilesMenu.Add()
114-
115-
Loop Reg REG_KEY_PATH "\Profiles", "K"
116-
ProfilesMenu.Add(A_LoopRegName, ProfileLoad)
117-
118-
add_log("Loaded profiles")
119-
}
120-
setupProfiles()
121110

122111
OptionsMenu := Menu()
123112

124113
PersistentOptions := [
114+
{
115+
ValueName: "SimplifiedView",
116+
Default: false,
117+
Text: SZ_TABLE.Menu_Options_SimplifiedView,
118+
Toggler: toggleSimplifiedView
119+
},
125120
{
126121
ValueName: "AlwaysOnTop",
127122
Default: true,
@@ -334,6 +329,9 @@ AutoclickerGui.AddButton("yp wp vHotkeys_ClearAllHotkeys_Button", "&Clear All")
334329

335330
AutoclickerGui["Tab"].UseTab()
336331

332+
AutoclickerGui.AddText("xm ym vSimplifiedViewHeaderText Hidden", "Select a profile:")
333+
AutoclickerGui.AddListBox("xp yp+20 w248 h188 vSimplifiedViewListBox Hidden Sort 0x100")
334+
337335
AutoclickerGui.AddButton("xm w121 vStartButton Default", "START")
338336
.OnEvent("Click", Start)
339337
AutoclickerGui.AddButton("yp wp vStopButton Disabled", "STOP")
@@ -353,6 +351,39 @@ add_log(text) {
353351
program_logs.RemoveAt(1)
354352
}
355353

354+
refreshProfileSelectionLists() {
355+
ProfilesMenu.Delete()
356+
ProfilesMenu.Add(SZ_TABLE.Menu_Profiles_Create, ProfileCreate)
357+
ProfilesMenu.Add(SZ_TABLE.Menu_Profiles_Manage, ProfileManage)
358+
ProfilesMenu.Add()
359+
360+
if is_simplified_view_on
361+
ProfilesMenu.Disable(SZ_TABLE.Menu_Profiles_Create)
362+
else
363+
ProfilesMenu.Enable(SZ_TABLE.Menu_Profiles_Create)
364+
365+
AutoclickerGui["SimplifiedViewListBox"].Delete()
366+
367+
local numProfiles := 0
368+
Loop Reg REG_KEY_PATH "\Profiles", "K" {
369+
numProfiles++
370+
ProfilesMenu.Add(A_LoopRegName, ProfileLoad)
371+
AutoclickerGui["SimplifiedViewListBox"].Add([A_LoopRegName])
372+
}
373+
374+
if numProfiles < 1 {
375+
if is_simplified_view_on
376+
AutoclickerGui["StartButton"].Enabled := false
377+
else
378+
AutoclickerGui["StartButton"].Enabled := !is_autoclicking
379+
} else {
380+
AutoclickerGui["SimplifiedViewListBox"].Value := 1
381+
AutoclickerGui["StartButton"].Enabled := !is_autoclicking
382+
}
383+
384+
add_log("Loaded " numProfiles " profile(s)")
385+
}
386+
356387
setupOptionsMenu() {
357388
for optionInfo in PersistentOptions {
358389
OptionsMenu.Add(optionInfo.Text, OptionsMenuItemCallbackWrapper)
@@ -662,7 +693,11 @@ ProfileCreate(*) {
662693

663694
for ctrlName, value in currentConfig.OwnProps() {
664695
if !InStr(ctrlName, "_")
696+
; Ignore any controls (e.g. SimplifiedViewListBox) that lack
697+
; underscores in their names since they are not part of the
698+
; profile configuration.
665699
continue
700+
666701
RegWrite value
667702
, ctrlName ~= "DateTime" ? "REG_SZ" : "REG_DWORD"
668703
, REG_KEY_PATH "\Profiles\" profileName
@@ -680,7 +715,7 @@ ProfileCreate(*) {
680715

681716
add_log("Wrote configuration data to registry")
682717

683-
setupProfiles()
718+
refreshProfileSelectionLists()
684719
hideOwnedGui(ProfileNamePromptGui)
685720
}
686721
}
@@ -715,7 +750,7 @@ ProfileManage(*) {
715750
ProfilesGui["ProfileList"].Add(A_LoopRegName = selectProfileName ? "+Focus +Select" : "", A_LoopRegName)
716751

717752
ProfileListSelectionChanged()
718-
setupProfiles()
753+
refreshProfileSelectionLists()
719754
}
720755

721756
ProfileListSelectionChanged(*) {
@@ -787,14 +822,12 @@ ProfileManage(*) {
787822
ProfilesGui.Opt("-Disabled")
788823
WinActivate "ahk_id " ProfilesGui.Hwnd
789824
refreshProfileList(profileNewName)
790-
setupProfiles()
791825
return
792826
}
793827
}
794828
MsgBox "The profile '" selectedProfileName "' does not exist or has been deleted.", "Error", "Iconx 8192"
795829
ProfileRenamePromptGui.Opt("-Disabled")
796830
refreshProfileList()
797-
setupProfiles()
798831
}
799832

800833
CancelPrompt(*) {
@@ -903,7 +936,7 @@ ProfileLoad(profileName, *) {
903936
add_log("Loading profile '" profileName "'")
904937

905938
if !assertProfileExists(profileName) {
906-
setupProfiles()
939+
refreshProfileSelectionLists()
907940
return
908941
}
909942

@@ -1000,6 +1033,15 @@ LogsOpen(*) {
10001033
}
10011034
}
10021035

1036+
toggleSimplifiedView(optionInfo) {
1037+
global is_simplified_view_on := optionInfo.CurrentSetting
1038+
AutoclickerGui["Tab"].Visible := !is_simplified_view_on
1039+
AutoclickerGui["SimplifiedViewHeaderText"].Visible := is_simplified_view_on
1040+
AutoclickerGui["SimplifiedViewListBox"].Visible := is_simplified_view_on
1041+
1042+
refreshProfileSelectionLists()
1043+
}
1044+
10031045
toggleAlwaysOnTop(optionInfo) {
10041046
global is_always_on_top_on := optionInfo.CurrentSetting
10051047
AutoclickerGui.Opt((is_always_on_top_on ? "+" : "-") "AlwaysOnTop")
@@ -1076,6 +1118,9 @@ Start(*) {
10761118
AutoclickerGui["StopButton"].Enabled := true
10771119
AutoclickerGui["StopButton"].Focus()
10781120

1121+
if is_simplified_view_on
1122+
ProfileLoad(AutoclickerGui["SimplifiedViewListBox"].Text)
1123+
10791124
local currentConfig := AutoclickerGui.Submit(false)
10801125

10811126
local buttonClickData := { 1: "L", 2: "R", 3: "M" }.%currentConfig.General_MouseButton_Radio%
@@ -1232,7 +1277,7 @@ Your current version is {}. Would you like to update now?
12321277
}
12331278
}
12341279

1235-
setupOptionsMenu()
1280+
RegCreateKey REG_KEY_PATH "\Profiles"
12361281

12371282
if A_Args.Length > 0 && A_Args[1] = "/profile" {
12381283
add_log("Detected /profile switch")
@@ -1250,6 +1295,9 @@ if A_Args.Length > 0 && A_Args[1] = "/profile" {
12501295
Close()
12511296
}
12521297

1298+
refreshProfileSelectionLists()
1299+
setupOptionsMenu()
1300+
12531301
AutoclickerGui.Show("x0")
12541302
add_log("Showed main GUI")
12551303

0 commit comments

Comments
 (0)