AppleScript: How to get all window names of processes that share the same title?
Note: On my system, macOS Sierra, there is no window for this process.

You can use a whose clause, like this:

For a process that contains only one window, use this script:

tell application "System Events"
    set theWindowList to name of window 1 of (processes whose name is "RSScriptRunner")
    if theWindowList contains "The title of the initial dialog of this script goes here." then
        error number -128
    end if
end tell




For a process that can contain one or more windows, use this script:

tell application "System Events"
    set myList to name of windows of (processes whose name is "RSScriptRunner") -- get a list of lists, each sublist contains names 
end tell
set theWindowList to my subListsToOneList(myList) --  Flattening a list of lists

if theWindowList contains "The title of the initial dialog of this script goes here." then
    error number -128
end if

on subListsToOneList(l)
    set newL to {}
    repeat with i in l
        set newL to newL &amp; i
    end repeat
    return newL
end subListsToOneList




The solution for macOS Sierra, maybe it works for other OSes as well, to get the name of the launched scripts, is to use the ps and pgrep commands.

set theNameList to paragraphs of (do shell script "ps -p $(pgrep -x RSScriptRunner) | sed -n 's:.*RSScriptRunner.*/::p'") -- get the name of the scripts
if theNameList contains "the name of this script.scpt" then error number -128


Informations:


$(pgrep -x RSScriptRunner) : A sub shell to get the process ID of
each instance of the RSScriptRunner, the '-x' option: require
an exact match of the process name
ps -p: get the command of each PID (the result contains the path of
the launched script).
The sed command : delete characters from the beginning of the line
through the last slash character to get the name of the script (the
-noption is to print the line which contains the
'RSScriptRunner' word only, because the first line is the headers
--> PID TTY           TIME CMD).