Skip to content

Commit b9080eb

Browse files
committed
Add tray icon support with headless mode integration
- Added the "Collapse to tray" menu item. - Toggle/stop hotkeys in headless operation mode now function as expected. "Collapse to tray" is also equivalent to entering headless mode.
1 parent 7fcb892 commit b9080eb

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

src/AutoclickerGui.ahk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ if A_IsAdmin {
3737
FileMenu.Disable(SZ_TABLE.Menu_File_RunAsAdmin)
3838
FileMenu.Rename(SZ_TABLE.Menu_File_RunAsAdmin, "Running as administrator")
3939
}
40+
FileMenu.Add(SZ_TABLE.Menu_File_Collapse, Collapse)
4041
FileMenu.Add(SZ_TABLE.Menu_File_Logs, LogsOpen)
4142
FileMenu.Add(SZ_TABLE.Menu_File_Exit, Close)
4243

src/EC-Autoclicker.ahk

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
;@Ahk2Exe-SetDescription EC Autoclicker
88
;@Ahk2Exe-SetVersion 1.2.3
99

10+
A_IconTip := "EC Autoclicker"
11+
1012
GITHUB_REPO := "Expertcoderz/EC-Autoclicker"
1113

1214
FILE_EXT := ".ac-profile"
@@ -23,13 +25,20 @@ are_hotkeys_active := true
2325
; This dictionary stores text used for GUI controls that may (potentially) be
2426
; referenced after the controls' creation, e.g. as in MenuBar.Disable().
2527
SZ_TABLE := {
28+
; Tray Menu
29+
TrayMenu_Start: "&Start",
30+
TrayMenu_Stop: "Sto&p",
31+
TrayMenu_Open: "&Open GUI",
32+
TrayMenu_Exit: "E&xit",
33+
2634
; Menus
2735
Menu_File: "&File",
2836
Menu_Profiles: "&Profiles",
2937
Menu_Options: "&Options",
3038
Menu_Help: "&Help",
3139
; File Menu
3240
Menu_File_RunAsAdmin: "Run As &Administrator",
41+
Menu_File_Collapse: "&Collapse to tray",
3342
Menu_File_Logs: "View &Logs",
3443
Menu_File_Exit: "E&xit",
3544
; Profiles Menu
@@ -71,6 +80,22 @@ SZ_TABLE := {
7180
RadioGroups := {}
7281
Checkables := {}
7382

83+
Collapse(*) {
84+
A_IconHidden := false
85+
AutoclickerGui.Hide()
86+
}
87+
Expand(*) {
88+
A_IconHidden := true
89+
AutoclickerGui.Show()
90+
}
91+
92+
A_TrayMenu.Delete()
93+
A_TrayMenu.Add(SZ_TABLE.TrayMenu_Start, Start)
94+
A_TrayMenu.Add(SZ_TABLE.TrayMenu_Stop, Stop)
95+
A_TrayMenu.Add()
96+
A_TrayMenu.Add(SZ_TABLE.TrayMenu_Open, Expand)
97+
A_TrayMenu.Add(SZ_TABLE.TrayMenu_Exit, Close)
98+
7499
; The order in which script files are included is important.
75100
#Include AutoclickerGui.ahk
76101
#Include Util.ahk
@@ -79,10 +104,6 @@ Checkables := {}
79104
#Include Profiles.ahk
80105
#Include Options.ahk
81106
#Include About.ahk
82-
83-
AutoclickerGui.Show("x0")
84-
add_log("Showed main GUI")
85-
86107
#Include Updater.ahk
87108

88109
Loop {

src/Profiles.ahk

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,8 @@ Message: {}
413413
}
414414
}
415415

416+
refreshProfileSelectionLists()
417+
416418
RegCreateKey REG_KEY_PATH "\Profiles"
417419

418420
if A_Args.Length > 0 && A_Args[1] = "/profile" {
@@ -425,10 +427,10 @@ if A_Args.Length > 0 && A_Args[1] = "/profile" {
425427

426428
if !assertProfileExists(A_Args[2])
427429
ExitApp
430+
431+
Collapse()
428432

429433
ProfileLoad(A_Args[2])
430434
Start()
431-
ExitApp
432-
}
433-
434-
refreshProfileSelectionLists()
435+
} else
436+
AutoclickerGui.Show()

0 commit comments

Comments
 (0)