The broader question might be whether anyone has done anything dependent on the behaviour of enter_alt( ) being diffferent than pressing the <ALT> key when a script is running outside of <ALT> mode? I don't think so FWIW.
Yeah, I think that's the right question, and probably the right answer.
IMHO, it really doesn't make sense to have a weird "script running in alt mode but with the alt gui handler" state you can only access with key presses. If someone was relying on this behavior, they can complain, and we can try to accommodate whatever the actual use case was.
I believe @reyalp 's usual advice is that many scripted actions when the camera is not in <ALT> mode are indeterminate?
Yes, and I stand by that, but it's also a lazy cop-out. It's been 10+ years, if it's undefined, we should define it in some way that is useful (edit: Or at least unambiguous).
In ML scripts always run outside of ALT mode, ie there is no ALT mode, other than by hijacking one button to access ML’s menu.
For whatever reason, and this is my ignorance, in CHDK we must start a script in ALT mode, where access to camera functionality is limited.
So I guess the question, to address my ignorance, is, does CHDK require to start a script in ALT mode, or is it a legacy matter, ie CHDK scripts could be allowed to start outside of ALT mode, ie running in the background.
In CHDK, alt mode is, by definition, how you access CHDK functionality (except for a few shortcuts which are a different problem for a different day). So you need to be in alt mode to *start* a script.
AFAIK, what happens if you leave alt mode with a script running was never specifically defined. The ability to do it exists because the code doesn't prevent it, and the resulting state is just however those bits of code happen to interact. It's possible there was some intended behavior at some point, but if so, it certainly hasn't been maintained in all the time I've been involved.
In the meantime, the code has gotten more complicated. "Alt mode" actually involves several different pieces of state: How keys are handled, what the GUI handler is and so on.
This area has been an ongoing source of bugs and confusion (most recently
https://chdk.setepontos.com/index.php?topic=14130.msg144400#msg144400 but also been a involving PTP)
Alt mode itself is somewhat poorly defined, in the sense that there's the initial state when you press alt (the alt GUI handler), and the various sub states of using menus, running script and so on which are described as running "in" alt mode.
FWIW, there is an alternate approach to accessing "normal" camera functionality with a script running: You can forward the keys presses and releases, like
https://chdk.fandom.com/wiki/Lua/Scripts:_Continuous_Autoexposure does. However, this is definitely clunkier than working directly in the Canon UI, and doesn't work for any keys that aren't known to the script.