FlexTime Scripted Cues
August 6th, 2006I’ve posted FlexTime 1.0b8, which contains a great number of minor fixes, as well as my first stab at built-in Help documentation. While you’re waiting for the excitement of WWDC to commence, why not spend a few minutes optimizing your favorite timed activities?
AppleScript got a great deal of enhancement on this round. I finally implemented a scripting interface for setting cue parameters, and fixed a few little bugs that were preventing FlexTime’s Sofa Control Plugin from working as well as it could.
A scripting feature I didn’t really go into detail about last time is an enhancement I’ve added to the “Run Script” functionality. If FlexTime finds an AppleScript handler called “HandleFlexTimeCue,” it will attempt to call it directly instead of running the script as a whole. This mechanism gives your scripted cues access to information about the activity and routine they are being asked to cue on behalf of. For instance, a simple scripted cue that displays the name of the activity and routine document might look like this:
This script also demonstrates how you might use a “Run Script” cue handler to overcome some of the shortcomings in FlexTime’s built-in cues. For instance, the text message displayed by the above script is configured to automatically dismiss after 5 seconds, and is positioned at the lower-left hand of the screen.
As FlexTime evolves the UI will get more powerful, but it will probably always lag somewhat behind the power exposed by the scripted interface. The Run Script cue is a good option for FlexTime routines that need to push the envelope of possible actions.
Oh, and one more not-so-obvious feature of the “Run Script” cue is that it will launch/run/open practically anything you can think of. It’s using the same mechanism as FastScripts, which is very liberal in its willingness to call something a “script.” It will run shell scripts, launch/activate applications, run Automator workflows – you can even ask it to open a document file for you.
Stay tuned for more on FlexTime’s secret powers :)
August 7th, 2006 at 10:50 am
The scripting support in this release feels silky smooth (if such superlatives can be meaningfully applied to scripting support, that is).
This post has made me realize that you can use the scripting support to create new types of cues. For example, here’s one that creates a countdown (or up):
So awesome. I love Applescript.
I wanted to make it say the count, too, but the time it took to speak the number messed with the timing of the beats. Hmm…
August 7th, 2006 at 11:10 am
Ryan: Awesome! I’m really glad you’re playing with the scripting interface and making good progress with it. I took the liberty of putting “<pre>” tags around your script to improve the readability.
The problem with the timing getting messed up on time-intensive scripted cues is something I hope to improve in the “engine” of FlexTime as time goes on. I am currently sort of firing the cue directly from the engine but over time I hope to make it so it sort of “spins off” the cue mechanism and allows the timing to continue completely uninterrupted.
August 8th, 2006 at 7:40 pm
Funny thing; I put <pre> tags in too, and they didn’t stick.