Testing for window name in InDesign

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).

This is the action I'm using to test. Is there another way to test for the existence of a "tabbed" window in InDesign?

You could have the macro Float all the windows first.
Do your actions.
Consolidate them again.

Like this:

Another way could be to script InDesign.
It can be controlled with AppleScript and JavaScript.

I found this page: https://macgrunt.com/tag/repeat-loops/

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.

1 Like

Great ideas! Thanks for the suggestions.

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.

1 Like

@JimmyHartington, I changed your script block to use the forum syntax for script blocks:

How to Put Code in a Forum Code Block

Just insert your script between the lines with the triple backquotes:

image

See Markdown for Code Blocks

To get syntax highlighting, then use the keyword in lower case for that language, like:
applescript
javascript
html

Here is a macro that will paste the script on the clipboard into the forum in the proper format:

MACRO: KM Forum -- Paste Script Block

1 Like

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.

Select Untitled Window in InDesignSelect Untitled Window in InDesign.png

1 Like

Thanks.
I seem to remember that there once was a button for this in the interface. But I could not find one.

Thanks all. So many good options!