Skip to content

Commit 3c95d29

Browse files
authored
v1.1.3
1 parent 7c3ed27 commit 3c95d29

File tree

1 file changed

+63
-28
lines changed

1 file changed

+63
-28
lines changed

EC-Autoclicker.ahk

Lines changed: 63 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
;@Ahk2Exe-SetCompanyName Expertcoderz
77
;@Ahk2Exe-SetDescription EC Autoclicker
8-
;@Ahk2Exe-SetVersion 1.1.2
8+
;@Ahk2Exe-SetVersion 1.1.3
99

1010
FILE_EXT := ".ac-profile"
1111
REG_KEY_PATH := "HKCU\Software\Expertcoderz\Autoclicker"
@@ -155,7 +155,7 @@ HelpMenu.Add SZ_TABLE.Menu_Help_OnlineHelp
155155
HelpMenu.Add SZ_TABLE.Menu_Help_Report
156156
, (*) => Run("https://github.com/Expertcoderz/EC-Autoclicker/issues/new/choose")
157157
HelpMenu.Add SZ_TABLE.Menu_Help_Update
158-
, (*) => CheckForNewerVersion(true)
158+
, (*) => CheckForUpdates(true)
159159
if !A_IsCompiled
160160
HelpMenu.Disable SZ_TABLE.Menu_Help_Update
161161
HelpMenu.Add
@@ -320,7 +320,6 @@ add_log(text) {
320320
showGuiAtAutoclickerGuiPos(gui) {
321321
local posX, posY
322322
AutoclickerGui.GetPos &posX, &posY
323-
global always_on_top
324323
gui.Opt (always_on_top ? "+" : "-") "AlwaysOnTop"
325324
gui.Show "x" posX " y" posY
326325
}
@@ -521,7 +520,7 @@ Hotkeys_ClearAllHotkeys(*) {
521520
Hotkeys_updateHotkeyBindings
522521
}
523522

524-
profileNamePrompt(title, text, callback) {
523+
profileNamePrompt(title, text, callback, owner := AutoclickerGui) {
525524
static currentCallback
526525
static ProfileNamePromptGui
527526
if !IsSet(ProfileNamePromptGui) {
@@ -570,12 +569,18 @@ profileNamePrompt(title, text, callback) {
570569
ProfileNamePromptGui["PromptText"].Text := text
571570
ProfileNamePromptGui["ProfileNameEdit"].Value := ""
572571
ProfileNamePromptGui.Opt "-Disabled"
573-
showGuiAtAutoclickerGuiPos ProfileNamePromptGui
572+
owner.Opt "+Disabled"
573+
if owner = AutoclickerGui
574+
showGuiAtAutoclickerGuiPos ProfileNamePromptGui
575+
else {
576+
local posX, posY
577+
owner.GetPos &posX, &posY
578+
ProfileNamePromptGui.Opt (always_on_top ? "+" : "-") "AlwaysOnTop"
579+
ProfileNamePromptGui.Show "x" posX " y" posY
580+
}
574581
}
575582

576583
ProfileCreate(*) {
577-
AutoclickerGui.Opt "+Disabled"
578-
579584
profileNamePrompt "Create/Update Profile"
580585
, "The current autoclicker configuration will`nbe saved with the following profile name:"
581586
, SubmitPrompt
@@ -658,10 +663,11 @@ ProfileManage(*) {
658663

659664
ProfileRename(*) {
660665
local selectedProfileName := ProfilesGui["ProfileList"].GetText(ProfilesGui["ProfileList"].GetNext())
661-
profileNamePrompt("Rename Profile"
666+
667+
profileNamePrompt "Rename Profile"
662668
, "The profile '" selectedProfileName "' will be renamed to:"
663669
, SubmitPrompt
664-
)
670+
665671
SubmitPrompt(newProfileName) {
666672
Loop Reg REG_KEY_PATH "\Profiles", "K" {
667673
if A_LoopRegName = selectedProfileName {
@@ -739,20 +745,32 @@ ProfileManage(*) {
739745

740746
RegCreateKey REG_KEY_PATH "\Profiles\" profileName
741747

742-
Loop Parse FileRead(fileLocation), "`n" {
743-
if !A_LoopField
744-
continue
745-
local configMatch
746-
RegExMatch A_LoopField, "^(?P<Name>\w+?)=(?P<Value>.+)$", &configMatch
747-
add_log "Read: " configMatch["Name"] " = " configMatch["Value"]
748-
if configMatch["Name"] = "Hotkeys"
749-
RegWrite StrReplace(configMatch["Value"], "`t", "`n"), "REG_MULTI_SZ"
750-
, REG_KEY_PATH "\Profiles\" profileName, "Hotkeys"
751-
else
752-
RegWrite configMatch["Value"], configMatch["Name"] ~= "DateTime" ? "REG_SZ" : "REG_DWORD"
753-
, REG_KEY_PATH "\Profiles\" profileName, configMatch["Name"]
748+
local e
749+
try {
750+
Loop Parse FileRead(fileLocation), "`n" {
751+
if !A_LoopField
752+
continue
753+
local configMatch
754+
RegExMatch A_LoopField, "^(?P<Name>\w+?)=(?P<Value>.+)$", &configMatch
755+
add_log "Read: " configMatch["Name"] " = " configMatch["Value"]
756+
if configMatch["Name"] = "Hotkeys"
757+
RegWrite StrReplace(configMatch["Value"], "`t", "`n"), "REG_MULTI_SZ"
758+
, REG_KEY_PATH "\Profiles\" profileName, "Hotkeys"
759+
else
760+
RegWrite configMatch["Value"], configMatch["Name"] ~= "DateTime" ? "REG_SZ" : "REG_DWORD"
761+
, REG_KEY_PATH "\Profiles\" profileName, configMatch["Name"]
762+
}
763+
} catch as e {
764+
add_log "Import Profile error: " e.Message
765+
MsgBox Format("
766+
(
767+
An error occurred whilst importing the profile '{}' from {}.
768+
This is likely due to corrupt data.
769+
770+
Message: {}
771+
)", profileName, fileLocation, e.Message), "Import Profile", "Iconx 8192"
772+
return
754773
}
755-
756774
refreshProfileList profileName
757775

758776
add_log "Finished importing profile '" profileName "'"
@@ -810,9 +828,16 @@ ProfileLoad(profileName, *) {
810828
}
811829
}
812830
add_log "Configuration GUI updated from profile"
813-
} catch as e
814-
MsgBox "An error occurred whilst loading the profile '" profileName "'. This is likely due to corrupt data.`n`nMessage: " e.Message
815-
, "Load Profile", "Iconx 8192"
831+
} catch as e {
832+
add_log "Load Profile error: " e.Message
833+
MsgBox Format("
834+
(
835+
An error occurred whilst loading the profile '{}'.
836+
This is likely due to corrupt data.
837+
838+
Message: {}
839+
)", profileName, e.Message), "Load Profile", "Iconx 8192"
840+
}
816841
return
817842
}
818843
}
@@ -1016,8 +1041,18 @@ Close(*) {
10161041
ExitApp
10171042
}
10181043

1019-
CheckForNewerVersion(isManual) {
1020-
add_log "Checking for newer version"
1044+
CheckForUpdates(isManual) {
1045+
if !DllCall("Wininet.dll\InternetGetConnectedState", "Str", "0x40", "Int", 0) {
1046+
add_log "No internet connection; not checking for updates"
1047+
if isManual
1048+
MsgBox "
1049+
(
1050+
EC Autoclicker is unable to check for updates as there is currently no internet connection.
1051+
Please connect to the internet and try again.
1052+
)", "Update", "Icon! 262144"
1053+
return
1054+
}
1055+
add_log "Checking for updates"
10211056

10221057
local oHttp := ComObject("WinHttp.Winhttprequest.5.1")
10231058
oHttp.open "GET", "https://api.github.com/repos/Expertcoderz/EC-Autoclicker/releases/latest"
@@ -1092,7 +1127,7 @@ if A_IsCompiled {
10921127
, "Update", "Iconi 262144"
10931128
} else if RegRead(REG_KEY_PATH, "AutoUpdate", true) && A_NowUTC - RegRead(REG_KEY_PATH, "LastUpdateCheck", 0) >= 604800 {
10941129
add_log "Automatically checking for newer version"
1095-
CheckForNewerVersion false
1130+
CheckForUpdates false
10961131
}
10971132
}
10981133

0 commit comments

Comments
 (0)