Advertisement
Guest User

Untitled

a guest
Sep 9th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --settings
  2. property alertVolume : 50 -- percentage
  3. property outputVolume : 50 -- percentage
  4. property alarmRepeatInterval : 5 -- seconds
  5.  
  6. property alarmText : "alarm!"
  7. property alarmCount : 5
  8. global firstrun
  9.  
  10. tell me to activate
  11.  
  12. set firstrun to true
  13. set alarmText to userString()
  14. set alarmCount to userNumber()
  15.  
  16. on idle
  17.     try
  18.         --get firstrun
  19.         if firstrun is false then
  20.             my alarm()
  21.         else
  22.             set firstrun to false
  23.         end if
  24.     on error m number n
  25.         tell me
  26.             beep
  27.             activate
  28.             display dialog (n as text) & return & (m as text)
  29.             tell me to quit
  30.         end tell
  31.     end try
  32.     return alarmCount * 60
  33. end idle
  34.  
  35. on userString()
  36.     set theString to text returned of (display dialog "Enter the text you want displayed for this alarm" default answer alarmText)
  37.     return theString
  38. end userString
  39.  
  40. on userNumber()
  41.     try
  42.         set theNumber to (text returned of (display dialog "enter the number of minutes after which you want to be alarmed" default answer alarmCount)) as number
  43.     on error number -1700
  44.         display dialog "you may only enter numbers"
  45.         getalaramTime()
  46.     end try
  47.     return theNumber
  48. end userNumber
  49.  
  50. on alarm()
  51.     set {prevAlertV, prevOutputV, prevOutputM} to {alert volume, output volume, output muted} of (get volume settings) -- cache current volume settings
  52.     set volume alert volume alertVolume
  53.     set volume output volume outputVolume
  54.     set volume without output muted
  55.     set theConfirmation to ""
  56.     tell me
  57.         activate
  58.         repeat until theConfirmation = "OK"
  59.             beep
  60.             say (alarmText as text) without waiting until completion
  61.             set theConfirmation to button returned of (display dialog (alarmText as text) buttons {"OK"} default button 1 giving up after alarmRepeatInterval)
  62.         end repeat
  63.         set volume alert volume prevAlertV
  64.         set volume output volume prevOutputV
  65.         if prevOutputM = true then
  66.             set volume with output muted
  67.         end if
  68.         tell me to quit
  69.     end tell
  70. end alarm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement