I’d like to activate a particular window of a nonscriptable app, and decided to just use XCode as an exemplar. So here’s one setup:
- Launch Xcode, open some project (I opened Son of Grab)
- Double click a source file to open a source window (Controller.m in my case)
-
Select Window | Organizer to open the Organizer window
- at this point you’ll have three Xcode windows, a project (main) one, the Organizer, and a source window.
-
Focus the source (again Controller.m in my case) window.
-
Try to focus the “Organizer – Documentation” window in a script; my simpleminded approach was:
tell application “Xcode”
activate window “Organizer – Documentation”
end tell
After this runs, the source window that was focused before I ran the script will again be focused – but not the Organizer window.
What am I missing? Thanks to all!
The activate command brings the application to the front. Each application will have its own terminology for dealing with its documents, so you would need to look at the scripting dictionary. In Xcode, it looks like you can get what you want by setting the index of the document (usually the front to back ordering), for example, using your snippet: