One of my application processes occasionally creates a floating window that I'd like to programmatically auto-close.
I have no problem checking for the existence of this window through its name, but then I am unable to close it with neither close window "windowname"
nor tell window "windowname" to close
. E.g.
tell application "System Events" to tell process "processname"
if exists window "windowname" then
close window "windowname"
end if
end tell
These result in:
error "System Events got an error: window "windowname" of process "processname" doesn’t understand the “close” message."
How can I close this window then?
I can close a Finder window like this. Maybe you can do the same.
tell application "System Events"
tell process "Finder"
click button 1 of window 1
end tell
end tell
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With