4

Where can I find documentation for notification center method and properties to use it in applescript? I can't find anything in script editor's dictionary neither on web.

This is example code to work with notification center:

on run
    tell application "System Events"
        tell process "Notification Center"
           set theseWindows to every window
           display notification (count of theseWindows)
        end tell
   end tell
end run
2
  • Welcome to Ask Different. Great effort showing your code and asking a useful question. I'm going to edit the answer - they ask a very good question about what line 4 is expected to do. My edit to their answer will help explain counting a string, but not windows.
    – bmike
    Commented Jan 19, 2019 at 11:47
  • Note that display notification is a part of StandardAdditions and as such it does not belong within a tell block of process "Notification Center" or application "System Events" and should be placed after the end tell of the tell application "System Events" block. Commented Jan 19, 2019 at 12:26

1 Answer 1

3

Script Editor app has a searchable library. Open that under the window menu and then select the Standard Additions bundle. If you search for the term notification, you'll see it's defined under User Interaction:

display notification [text] : the body text of the notification
  [with title text] : the title of the notification (default is the name of the calling application).
  [subtitle text] : the subtitle of the notification
  [sound name text] : the name of the sound to play

But Notifications Center doesn't have any windows. Are you trying to count all windows for all applications?

To be clear - here's the notification part setting aside what a window count might be:

on run
    tell application "System Events"
        tell process "Notification Center"
            set theseWindows to "a b c"
            display notification (count of theseWindows)
        end tell
    end tell
end run
1
  • 2
    Note that display notification is a part of StandardAdditions and as such it does not belong within a tell block of process "Notification Center" or application "System Events" and should be placed after the end tell of the tell application "System Events" block. Commented Jan 19, 2019 at 12:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .