I have an app that has no AppleScript dictionary. It also has no File or Windows menus either. I think this is the reason I can not bring one of it's windows to front (either by name or index).
I can refer to windows by name in IF statements, and move them, click in them, etc., but so far the only method I have come up with to bring a window behind another to the front is to minimize/unminimize it.
It is always best to post the solution even if you just figure it out yourself - that way it is documented for the next person with the same problem (and in my experience, “the next person” is often yourself several years later when you've forgotten that you solved the problem previously).
Yeah… without a connected camera you won't have access to the windows that need to be managed.
But thanks for this… it works a treat, although it is actually a little slower to bring the wd to front than my hacky solution above. Nevertheless I will use it as it is a more direct/reliable solution and speed isn't all that important.
You have to know about System Events – and you have to be know about UI elements – and you have to know how to find out whether UI elements support actions.
Run this in the Script Editor.app to look at System Events' scripting dictionary:
tell application "System Events"
set sevApp to path to it
end tell
tell application "Script Editor"
activate
open sevApp
end tell
Run this with at least 1 window open in the Finder to get a quick glimpse of discovering actions:
tell application "System Events"
tell application process "Finder"
tell window 1
actions
end tell
end tell
end tell
I bought UI Browser about 15 years ago to help me with the mess that is UI-Scripting on the Mac.
It's about $55.00 U.S. and has saved me much frustration.
I also use Script Debugger ($99.00 U.S.), and it too has features that make discovering the Mac UI easier.
In addition to making AppleScript MUCH easier to write and debug.
Searching Google for AppleScript bring window to front I very quick got to this: