Creating a timer with AppleScript?

Discussion in 'Mac Programming' started by orbdrums, Aug 14, 2011.

  1. orbdrums macrumors member

    Joined:
    Dec 13, 2008
    #1
    I want to create a timer with a Mac. Would AppleScript be the route and, if so, do I have to re-create the wheel or is there one included with Mac OS X?
     
  2. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
  3. orbdrums thread starter macrumors member

    Joined:
    Dec 13, 2008
    #3
    One that will take an input field (like 15 for 15 seconds) and countdown from 15 to zero and then sound an audible alarm.
     
  4. sammich macrumors 601

    sammich

    Joined:
    Sep 26, 2006
    Location:
    Sarcasmville.
    #4
    Code:
    set input to text returned of (display dialog "Enter length of timer" default answer "")
    delay input
    beep
    
     
  5. orbdrums thread starter macrumors member

    Joined:
    Dec 13, 2008
    #5
    It works great. Now I need to enhance the the interface. Thanks man.
     
  6. sammich macrumors 601

    sammich

    Joined:
    Sep 26, 2006
    Location:
    Sarcasmville.
    #6
    No worries.

    Although, there isn't much 'enhancing' that can be done.
     
  7. orbdrums thread starter macrumors member

    Joined:
    Dec 13, 2008
    #7
    I'm thinking that I can convert seconds to minutes and have the time count down with some kind of onscreen display? instead of having the code do everything in the background?
     
  8. sammich macrumors 601

    sammich

    Joined:
    Sep 26, 2006
    Location:
    Sarcasmville.
    #8
    From what I understand, AppleScript on it's own can't do very much. It can use other frameworks that you might have to make (http://macscripter.net/viewtopic.php?id=32292 is an example but the sample file in post 2 is gone).

    I'm guessing you want a countdown timer. The only way I can think of is rather obtrusive":

    Code:
    set input to text returned of (display dialog "Enter length of timer" default answer "")
    set countdown to input
    repeat input times
    	display dialog "Time left: " & countdown giving up after 1
    	set countdown to countdown - 1
    end repeat
    beep
    
     
  9. orbdrums thread starter macrumors member

    Joined:
    Dec 13, 2008
    #9
    Thanks again for your help. I agree, obtrusive (and intrusive) would be correct. I launched your code and it took refresh time to commit. I will look more in to xCode for the solutions I need. I'm new to Mac and I certainly appreciate your input. It's people like you that make Apple great.
     

Share This Page