Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 0.85 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Close App A when App B closes: Mac OS X 10.7.3
  2. if not exists (processes where name is A)
  3.    tell application B to quit
  4. end if
  5.        
  6. set theNotice to current application's NSWorkspaceDidTerminateApplicationNotification
  7.     tell current application's NSWorkspace's sharedWorkspace's notificationCenter
  8.         addObserver_selector_name_object_(me, "appQuitNotification:", theNotice, missing value)
  9.     end tell
  10.        
  11. on appQuitNotification_(aNotification) -- an application quit
  12.     -- aNotification's userInfo record contains an NSRunningApplication instance that we can get properties from
  13.     set theApplication to (aNotification's userInfo's NSWorkspaceApplicationKey's localizedName()) as text
  14.     say "application " & theApplication & " quit" -- for testing
  15.     if theApplication is "this" then tell application "that" to quit -- or whatever
  16. end appQuitNotification_