Code: Select all
#InstallKeybdHook
OnExit, ExitRoutine
exit
ExitRoutine:
msgbox exiting test....
exitapp
thank you
Joe Petree
Code: Select all
#InstallKeybdHook
OnExit, ExitRoutine
exit
ExitRoutine:
msgbox exiting test....
exitapp
Perhaps it's not a common mistake.I found NOTHING even similar to my problem.
Exactly what would you add to the documentation?I feel this is entirely about the idiosyncratic way EXIT works in this context, and just wish there had been one small note about that.
ExitApp wrote:Terminates the script unconditionally.
Exit wrote:Exits the current thread or (if the script is not persistent and contains no hotkeys) the entire script.
Remarks
If the script has no hotkeys, isn't persistent, and hasn't requested the Num/Scroll/CapsLock key(s) to be kept AlwaysOn or AlwaysOff, it will terminate immediately when Exit is encountered (except if it has an OnExit subroutine).
Otherwise, the Exit command terminates the current thread. In other words, the stack of subroutines called directly or indirectly by a menu, timer, or hotkey subroutine will all be returned from as though a Return were immediately encountered in each. If used directly inside such a subroutine -- rather than in one of the subroutines called indirectly by it -- Exit is equivalent to Return.
Use ExitApp to completely terminate a script that is persistent or contains hotkeys.
Specifies a subroutine or function to run automatically when the script exits.
Exit does NOTHING sometimes. This is VERY UNINTUITIVE. Gee, I could use it like a NOOP sometimes (something I often wondered why it doesn't exist for writing IF..ELSE statements). (Kinda just joking.)(if the script is not persistent and contains no hotkeys)
By lacking, I mean "examples include" does not limit threads to other events.The current thread is defined as the flow of execution invoked by the most recent event; examples include hotkeys, SetTimer subroutines, custom menu items, and GUI events
No. It always exits the thread. This is its primary purpose, hence the first four words of its documentation being "Exits the current thread". Exiting the script is a side-effect; if the script has nothing left to do, there's no reason to leave the process running.Exit does NOTHING sometimes.
No, the auto-execute section is a subroutine, but it is called in its own thread. Without a thread, there is no "flow of execution".One question then: Is the auto-execute section of a script considered a THREAD?
... and Windows task manager shows the script has having ONE thread.
Although AutoHotkey doesn't actually use multiple threads, it simulates some of that behavior
Source: Threads
The script starting.... but what event is the above?
Users browsing this forum: Google [Bot] and 335 guests