1

I am not sure if Apple script is what i need but it seems to do most of what i need. Feel free to offer alternatives.

I need to send a character to a program at an exact time to start a countdown video. The Apple script i have is

tell application "ProPresenter 5"
    activate
end tell
tell application "System Events"
    keystroke "z"
end tell

What i need is to be able to start that at say 10:40:25 one day and then 10:40:15 the next day. All the guides i see involve the calendar or automator but those have 1 minute resolution. I also only need to set it up about 20 minutes in advance

If it matters i am on os x 10.8.5

1

Here's a little something I set up for you which will display a dialogue asking you to enter the time to have system events send the keystroke. You can save this script as an application and run it whenever you want. Another option would be to remove the very first two lines of the code and replace it with this… property requested_time : "10:40:25 AM” . Then you could just add the script to an iCal event to launch every day at whatever time you choose

set requested_time to display dialog "Please Enter Your Start Time With The Following Format: Hour:Minutes:Seconds" default answer "10:40:25 AM" buttons {"OK"} default button 1
set requested_time to text returned of requested_time
set theTime to time string of (current date)

tell application "ProPresenter 5" to launch -- Opens The App Without Bringing It Up Upfront. Added This Line To Make Sure Your Application Is Running When System Events Sends The Keystroke.  You Can Always Remove This Line If You Prefer

repeat until theTime is greater than or equal to requested_time -- Added The "Greater Than" Just As A Failsafe
    delay 1
    set theTime to time string of (current date)
end repeat

tell application "ProPresenter 5" to activate
delay .5 -- My system did not need this delay.  Yours may not either, but I added it just in case.  
tell application "System Events"
    keystroke "z"
end tell

Or you can save this version of the script as an app.

property requested_time : "10:40:25 AM”
set theTime to time string of (current date)

tell application "ProPresenter 5" to launch -- Opens The App Without Bringing It Up Upfront. Added This Line To Make Sure Your Application Is Running When System Events Sends The Keystroke.  You Can Always Remove This Line If You Prefer

repeat until theTime is greater than or equal to requested_time -- Added The "Greater Than" Just As A Failsafe
    delay 1
    set theTime to time string of (current date)
end repeat

tell application "ProPresenter 5" to activate
delay .5 -- My system did not need this delay.  Yours may not either, but I added it just in case.  
tell application "System Events"
    keystroke "z"
end tell

Then you can create a new calendar event to repeat daily, and 20 minutes before, it will launch the script you saved as an app

enter image description here

|improve this answer|||||
  • I tested this using TextEdit app because I do not have "ProPresenter 5". It works like a charm on the latest version of Sierra. I'm not sure if it will work on 10.8.5 – wch1zpink Sep 25 '17 at 6:48
  • What I ended up using was something along the lines of this. I don't have the computer handy because it is at church so i may be off a bit on my code. I don't tend to use osx. set theTime 09/25/2017 10:40:25 AM delay theTime - currentTime The code listed in my question. I will probably steal the dialog box though. might make it easier for others running this. – birdman3131 Sep 25 '17 at 19:24
-1

You could simply use the AppleScript delay command to delay the script from executing on the exact minute by however many seconds.

Per your example: if you want it to run at 10:40:25 ... set your script to execute at 10:40:00 but put the command delay 25 on the first line.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.