App Status Applet

The App Status applet watches a specified application and speaks when the status of the targeted application changes.

The script accesses both the NSWorkspace and NSNotificationCenter classes of the AppKit framework to respond to changes in status of a specified application.

To setup the applet for use:

To use the applet, double-click its icon. To stop using the applet, bring it to the front, and select “Quit” from the applet’s “File” menu or type Command-Q (⌘Q).

use framework "Foundation" use framework "AppKit" use scripting additions property targetApplicationDisplayName : "Keynote" -- create an instance of the Shared Workspace set workspace to current application's NSWorkspace's sharedWorkspace() -- identify the Shared Workspace's notification center set noteCenter to workspace's notificationCenter() -- register notification handlers for dealing with application status noteCenter's addObserver:me selector:"appWasActivated:" |name|:"NSWorkspaceDidActivateApplicationNotification" object:(missing value) noteCenter's addObserver:me selector:"appWasDeactivated:" |name|:"NSWorkspaceDidDeactivateApplicationNotification" object:(missing value) noteCenter's addObserver:me selector:"appWasTerminated:" |name|:"NSWorkspaceDidTerminateApplicationNotification" object:(missing value) on appWasActivated:notif -- (localizedName, bundleIdentifier, processIdentifier) set activeAppName to (notif's userInfo()'s NSWorkspaceApplicationKey's localizedName()) as text if activeAppName is targetApplicationDisplayName then say targetApplicationDisplayName & " was activated." end if end appWasActivated: on appWasDeactivated:notif set deactivatedAppName to (notif's userInfo()'s NSWorkspaceApplicationKey's localizedName()) as text if deactivatedAppName is targetApplicationDisplayName then say targetApplicationDisplayName & " was deactivated." end if end appWasDeactivated: on appWasTerminated:notif set terminatedAppName to (notif's userInfo()'s NSWorkspaceApplicationKey's localizedName()) as text if terminatedAppName is targetApplicationDisplayName then say targetApplicationDisplayName & " was quit. [[slnc 500]] Me too! Goodbye." tell me to quit end if end appWasTerminated:
UNDER CONSTRUCTION

This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.

DISCLAIMER