Check existence Notification window via ssh -System events error

Hello,
I am running applescript from python on remote machine via ssh to check if exists Notification window and get error “Application ‘System Events’ not running(-600)”
My applescript:
tell application “System Events”
if exists (window 1 of process “Notification Center”) then
tell application “System Events” to tell process “Notification Center” to tell window 1
click

	end tell
end if

end tell
Running from python using osascript -e:

UID = os.getlogin()
exit_code = os.system("sudo launchctl asuser %s osascript -e ‘%s’ " %(UID,scpt) )

Tried to activate System Events,kill /quit /relaunch - no success
Will be appreciate for any help
Many thanks,
Lilya

It seems to me, the problem with your script is simple: you should do not request for application “System Events” of application “System Events” inside the if block:


tell application "System Events" to tell process "NotificationCenter"
	if exists window 1 then click window 1
end tell

Or, the same in the one-liner form, as it likes @Marc Anthony :D:


tell application "System Events" to tell process "NotificationCenter" to if exists window 1 then click window 1