How to bring AppleScript "choose from list" to foreground?

I have a macro that uses AppleScript to display a Choose from List series. It starts by creating two variables within a “tell km engine” block, then there’s the “try” block for the choose list, then (assuming the user didn’t cancel), I set the results to a KM variable.

This works great on its own, assigned to a hot key. But I want to run it from a palette with a number of other macros. It runs fine there, except that when the AppleScript choose list pops up, it doesn’t have focus.

I can’t figure out what to tell AppleScript or KM to activate to get that window focus after choosing my macro from the pop-up palette.


Figured it out:

tell application "System Events"
      choose from list…
   end try
end tell

That works from the palette. (Now to figure out how to cancel a macro from AppleScript…)


You could also say

tell application (path to frontmost application as text)
… choose …

This has the advantage that you don’t have to switch to the System Events application.

I would only switch to System Events if you have Default Folder X installed, and the currently (= at runtime) frontmost app doesn’t work with Default Folder X. (This used to be the case, for example, with the Finder; but nowadays it seems to work fine with it, too.)

1 Like