How can I get the name of notification window???

I’m trying to find how to get the name of notification

But I can’t find…

Anyway, What I want to know is that How to click “Cancel” button of notification window.

When I insert my modem device, the notification popup window is appeared.

I just want to cancel this window.

Please, Let me know.

You can press buttons like you want, but you need to know the name of the application which displayed the notification window. For example, if “Safari” displayed the notification you could do something like this…

tell application "System Events"
	tell process "Safari"
		click button "Cancel" of window 1
	end tell
end tell

First of all

Thank you for your answer.

However, I already know you information.

What I want to know is that How to find the name of application. Especially, notification window

I tried like that

	tell current application
		set appName to the name of the current application
		do shell script "echo " & appName
		delay 1
	end tell
end repeat

I can get the name of other applications, but this notification window doesn’t show any name of application…

If the window has a name at the top of it you could try something like this… or maybe the window has some specific text that you could search for. Whatever it is, find something unique about the window and then just loop through every process and check the windows for that value.

set windowName to "Untitled"

tell application "System Events"
	set runningProcesses to every process
	repeat with aProcess in runningProcesses
		set processWindows to name of windows of aProcess
		if processWindows contains windowName then
			return "The process for the window is: " & name of aProcess
		end if
	end repeat
end tell

I really appreciate it.^^

I’m done with your tips.

Its name is “UserNotificationCenter”, and I can click with below code.

tell application "System Events"
	tell process "UserNotificationCenter"
		click button "Cancel" of window 1
	end tell
end tell

Thank you for everything you did again.


you could also try the applescript example below:

tell application "Finder"
display dialog "Hello!  This is a test!"
end tell

the line with the "display dialog “Hello! This is a test!” " is the message window that will pop up and will show up with the message.