I would use functions rather than subs, as a matter of preference. There isn't any particular reason that you can't use subs now and later use functions if they seem more suitable for the task. A facelift would only be needed if you were concerned about style, which isn't practical.
My hotkey script is full of quick-fix hotkeys, with minimal organisation. I find it adequate to just search (Ctrl+F) for a window title or hotkey if I think it exists. Otherwise it doesn't matter how the script is organised; I just pick a spot and add another quick-fix hotkey. Often there's nothing to gain by using a separate function/sub, and certainly no need for OOP.
Early on I split some of my hotkeys into files based on category, but this has actually made some of them harder to find quickly.
That's for my hotkey script, though, since the example had hotkeys; I suppose modularity is more important for function libraries or other programs written with AutoHotkey. To put it another way, my hotkey script is full of simple, unrelated hotkeys, so perhaps there's not as much potential for organisation as with a library or program, where everything is related.
waetherman wrote:I also got surprised when I used a 'super global' variable by defining a variable in 'autostart' section of the script with `global` keyword - turned out the local variables I used inside my Calculator class where accessing super globals, so you should absolutely avoid using them if you care about encapsulation.
If you declare a name as
global and there are no declarations to the contrary, of course it's going to be treated as
global. What did you expect?
The purpose of
global varname outside a function is to make
varname globally accessible, everywhere. If you don't want that, then certainly, avoid using it.
You could declare
local varname inside the function, but then you run the risk of forgetting other declarations and ending up with global variables that were intended to be local. (This is because the presence of a local declaration makes the function assume all undeclared variables are global.)