Creating custom dropdown menus with apple script or JXA, but not with choose from list function

I’ve just skimmed this thread, so I might be getting the wrong end of the stick, but is the issue that KM in some circumstances doesn’t appear to execute an ASObjC script properly, or at least not in the same manner as other script runners do ? Is this to do with NSWindow and NSView object instances failing to be created in KM ?

This is presumably the same case when running those scripts using osascript from the command line ?

If it’s useful to know, when I last used KM about two years ago, it relied on osascript to execute AppleScript files and AppleScripts supplied as text to its Execute An AppleScript action. And osascript’s environment is only a subset of the AppleScript environment that’s instantiated when running in Script Editor, Script Debugger, and the like.

Similarly, FastScripts used to execute its scripts either using osascript or something similar, and wasnt able to create NSWindow graphics contexts. But the engine was overhauled for version 3, and since then, I believe it not only executes every script in its own separate environment, but that environment is now a bonafide AppleScript instance so one would expect it to handle anything Script Debugger can handle.

I don’t know how Keyboard Maestro runs scripts, but apparently it isn’t running these correctly. They work everywhere else (including FastScripts), so the test was to see if using osascript via a shell script would isolate it, since it should be running in its own shell. A couple of the options in the script posted by @Dirk don’t use NSWindow, so it would also be interesting to see how that works with the OP’s workflow.