home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / Akua Sweets 131 / Akua Sweets Examples / System / Post a Notification < prev    next >
Encoding:
Text File  |  1999-03-04  |  1.1 KB  |  45 lines  |  [TEXT/ToyS]

  1. on run
  2.     DelayNote()
  3. end run
  4.  
  5.  
  6. on DelayNote()
  7.     -- Get out a here
  8.     tell application "Finder" to activate
  9.     
  10.     -- You should always test if you are in the background before posting a notification
  11.     WaitUntilWeAreNotFront()
  12.     
  13.     -- Post it
  14.     set myNote to ¬
  15.         («event ÅkuSÑote» with «class ñEye» given «class ñStr»:¬
  16.             "Hey dude, I need some attention!", «class ñIcn»:150 ¬
  17.             , «class ñSnD»:"Indigo")
  18.     
  19.     -- Wait for the user to swap us back (or BP2F)    
  20.     WaitUntilWeAreInFront()
  21.     
  22.     -- Remove it from queue - good practice!
  23.     «event ÅkuSÑote» myNote with «class ñEnd»
  24.     
  25.     display dialog ¬
  26.         "Hi there. Thanks for coming back." & return & return & ¬
  27.         "Bye now." buttons {"OK"} default button 1
  28. end DelayNote
  29.  
  30.  
  31. on WaitUntilWeAreNotFront()
  32.     -- Check if we are still front…
  33.     repeat until (frontmost process with comparison to me) is 0
  34.         pause for 5 with seconds timing
  35.     end repeat
  36. end WaitUntilWeAreNotFront
  37.  
  38.  
  39. on WaitUntilWeAreInFront()
  40.     -- Check if we are still back…
  41.     repeat until (frontmost process with comparison to me) is not 0
  42.         pause for 2 with seconds timing
  43.     end repeat
  44. end WaitUntilWeAreInFront
  45.