Apple Script - How do I check if a window with a specific title exists?
You can do this with the System Events application - for example:

tell application "System Events"
    if exists (window "Terminal — -zsh" of process "Terminal") then
        display dialog "Found"
    else
        display dialog "Not found"
    end if
end tell


Note that process is case sensitive while window is not.  Therefore this will work

if exists (window "TeRmInAl — -ZsH" of process "Terminal")

but this will not

if exists (window "Terminal — -zsh" of process "terminal")



If you are running from Script Editor you must authorise it in System Preferences > Security &amp; Privacy > Privacy > Accessibility