1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Cocoa-AppleScript Appletで通知センターを利用する

Last updated at Posted at 2013-02-04
NotificationCenterExample
on userNotificationCenter_shouldPresentNotification_(notificationcenter, notification)
    return 1
end userNotificationCenter_shouldPresentNotification_

on notification(aTitle, aSubtitle, aMessage)
    set userNotification to current application's NSUserNotification's alloc()'s init()
    set userNotification's title to aTitle
    set userNotification's subtitle to aSubtitle
    set userNotification's informativeText to aMessage
    current application's NSUserNotificationCenter's defaultUserNotificationCenter's deliverNotification_(userNotification)
    current application's NSUserNotificationCenter's defaultUserNotificationCenter's setDelegate_(me)
    userNotification's release()
end notification

notification("THIS IS TEST", "notification test", "This is notification test from cocoa applescript applet.")
~~~~

Cocoaブリッジしているので通常のAppleScriptではなくCocoa-Applescript AppletかCocoa-Applescript Applicationで動くコードです。
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?