WOW :!:
This script is getting both shorter and better at the same time!
Now, let's dig in a little. All the low hanging apples have been picked.
I will sit down and spend some serious time following the script, and give my advice.
The first piece is
Gui, Default.
It shouldn't melt your brain at all!
Consider this:
Gui, 2: Add, Text,, hi
Gui, 2: Add, Button,, Bye
Gui, 2: Add, Edit, vEdit, Hello!
; ... MANY more lines all starting with Gui, 2:
; The above is the same as the below in functionality.
[color=red]Gui 2: Default[/color]
Gui, Add, Text,, hi
Gui, Add, Button,, Bye
Gui, Add, Edit, vEdit, Hello!
; ... MANY more lines, all MUCH more readable now that they are all just 'Gui'
________________________________________________________
The next item is organization. You are doing fairly well. However, I notice some inconsistencies. Inconsistencies are fine in small scripts. However, in a large script, they can be frustrating once a bug pops up.
Your number one inconsistency is
functions vs subroutines. If you want to be a purist, Functions do not change state and return a value. Subroutines change state (e.g., modify variables/modify Gui, etc) and do not return a value.
(In AutoHotkey, you can only pass parameters to functions, so we use them also when parameters need to be passed, instead of something like 'Param := false' then 'GoSub, some_sub_which_uses_Param_var')So, you should
(imo) do one of two things:
[*:sfkky45w]Do things the way described above, changing things like CheckCakeWalkKey() to GoSub CheckCakeWalkKey
[*:sfkky45w]Change everything to functions.
(Not to subs; they can't receive params)________________________________________________________
I lied! there is a low hanging apple!
Your ButtonInfo sub looks like
ButtonInfo: ; Creates button "Info" which opens misc\info.html instructions page
SoundPlay, misc\shot.wav ; Plays this sound when Info button pressed
FileAppend, %A_Hour%`:%A_Min% - Displayed Instructions`n, %LogFile% ; Writes entry to misc\uselog.txt file...
IfExist, misc\info.html ; Looks for instructions file
{
Run misc\info.html ; Opens instructions file
Return
}
IfNotExist, misc\info.html ; If file does not exist, message is displayed
{
MsgBox, File is not available`. ; Message displayed
Return
}
Return
But it could look like
ButtonInfo: ; Creates button "Info" which opens misc\info.html instructions page
SoundPlay, misc\shot.wav ; Plays this sound when Info button pressed
FileAppend, %A_Hour%`:%A_Min% - Displayed Instructions`n, %LogFile% ; Writes entry to misc\uselog.txt file...
IfExist, misc\info.html ; Looks for instructions file
Run misc\info.html ; Opens instructions file
IfNotExist, misc\info.html ; If file does not exist, message is displayed
MsgBox, File is not available`. ; Message displayed
Return
Or like
ButtonInfo: ; Creates button "Info" which opens misc\info.html instructions page
SoundPlay, misc\shot.wav ; Plays this sound when Info button pressed
FileAppend, %A_Hour%`:%A_Min% - Displayed Instructions`n, %LogFile% ; Writes entry to misc\uselog.txt file...
IfExist, misc\info.html ; Looks for instructions file
{
Run misc\info.html ; Opens instructions file
Return
}
MsgBox, File is not available`. ; Message displayed
Return
This is because you are 'returning' whether or not it exists.
MenuViewVersionHistory is the same way.
Also, please consider using '
Else' instead of opposing If* commands, as it is more clear at a glance.
Also, the if* commands are deprecated, and will not be included in AHKv2.
Instead, I prefer to use
If FileExist() instead of
IfExist. This is up to you, but I strongly suggest a switch.