Ahk when to use percent?
This gathers the wildcard text to search :
InputBox, wildcard, Part Description Wildcard?, Enter Text if ErrorLevel Exit
Then I define a variable that literally equals the percent sign :
percentage := "%"
Then I send this to the application :
send, %percentage% %wildcard% %percentage%
Is there an easier way to do this?
If we're not trying to return a value from a function, and are just interested in the control flow, there is not much difference. But the difference is there.
You could indeed end an hotkey label with exit, and it would be the same as ending it with return. From the documentation: "If there is no caller to which to return, Return will do an Exit instead.". I guess it's just convention to end hotkey labels with return.
So basically said, there is difference between the two, if return isn't about to do an exit.
Well when would this be? For example:
The first return has no caller to which to return to, so it will do an exit. The second return however does have a caller to return to do, so it will return there, and then execute the 3rd message box. If we replaced the second return with an exit, the current thread would just be exited and the 3rd message box would never have been shown.
Here's the same exact example with legacy labels:
I'm showing this, because they're very close to hotkey labels, and hotkey labels were something you were wondering a lot about.
In this specific example, if the line MsgBox, 3 didn't exist, replacing the second return with an exit would produce the same end result. But only because code execution is about to end anyway on the first return.
In AHK v1, hotkeys and hotstrings work like labels, and labels are legacy. Labels don't care about { }s like modern functions do. So we need something to stop the code execution. Return does that.