I want to test to see if a window containing "Untitled" exists in InDesign. The test works if the windows are "floating" but not if they are "tabbed" (as shown in image, below).
And modified a the sample to work with my version of InDesign.
tell application "Adobe InDesign CC 2018"
set mgList to {}
repeat with mgDoc in every document
set active document to mgDoc
set end of mgList to name of active document
end repeat
end tell
return mgList
It returns a list of the names of the open documents.
But you then need a way to process them afterwards. And my AppleScript or JavaScript skills are not good enough to help here.
That's because windows and tabs are difference things. One window can contain many tabs. Most apps have a different object model for tab than windows.
I don't have InDesign, so I can't develop or test a script for it, but here's an analogous script for Safari:
tell application "Safari"
tell every window
set tabList to name of every tab
end tell
set untitledTab to first tab of every window whose name starts with "Untitled"
end tell
Try this in Script Debugger 7. In SD7 it is very easy to explore the app's object model (called an "SDEF"). If you don't have SD7, I highly recommend it. If you decided not to buy, it will gracefully downgrade to the free SD7 Lite -- both much, much better than Apple's Script Editor.
Change "Safari" to "InDesign", and try it -- 50/50 that it will work. IAC you can open the InDesign object model to find out about "tabs", which will be a "class".
EDIT: Sorry, @JimmyHartington, I didn't see your script until after I had posted.
Using an older version of InDesign, I was able to get this working by targeting the Window menu instead of a window title, so maybe this will work for @rcraighead in the newer version of InDesign.