{"id":169,"date":"2006-08-06T12:43:11","date_gmt":"2006-08-06T19:43:11","guid":{"rendered":"http:\/\/www.red-sweater.com\/blog\/169\/flextime-scripted-cues"},"modified":"2006-08-06T14:21:21","modified_gmt":"2006-08-06T21:21:21","slug":"flextime-scripted-cues","status":"publish","type":"post","link":"https:\/\/redsweater.com\/blog\/169\/flextime-scripted-cues","title":{"rendered":"FlexTime Scripted Cues"},"content":{"rendered":"<p>I&#8217;ve posted <a href=\"http:\/\/www.red-sweater.com\/flextime\/\">FlexTime 1.0b8<\/a>, which contains a great number of minor fixes, as well as my first stab at built-in Help documentation. While you&#8217;re waiting for the excitement of WWDC to commence, why not spend a few minutes optimizing your favorite timed activities? <\/p>\n<p>\nAppleScript 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&#8217;s <a href=\"http:\/\/caseapps.com\/sofacontrol-applications.html#flextime\">Sofa Control Plugin<\/a> from working as well as it could.\n<\/p>\n<p>\nA scripting feature I didn&#8217;t really go into detail about last time is an enhancement I&#8217;ve added to the &#8220;Run Script&#8221; functionality. If FlexTime finds an AppleScript handler called &#8220;HandleFlexTimeCue,&#8221; 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:\n<\/p>\n<div class=\"caption\">\n<pre>\n\n-- If somebody runs us directly, set them straight\ndisplay dialog \"This is a FlexTime cue script! \" & &not;\n\t\"Don't run me like that!\"\n\non HandleFlexTimeCue(myDocument, myRoutine)\n\t\n\t-- Just beep for fun\n\tbeep\n\t\n\t-- And ask FlexTime to show a message \n\tset routineName to name of myDocument\n\tset activityName to name of myRoutine\n\tset myText to \"Time to do \" & activityName & &not;\n\t\t\" for \" & routineName\n\ttell application \"FlexTime\"\n\t\tdisplay message myText &not;\n\t\t\tat screen position bottom left &not;\n\t\t\tdismissing after delay 5\n\tend tell\n\t\nend HandleFlexTimeCue\n\n<\/pre>\n<\/div>\n<p>\nThis script also demonstrates how you might use a &#8220;Run Script&#8221; cue handler to overcome some of the shortcomings in FlexTime&#8217;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.\n<\/p>\n<p>\nAs 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.\n<\/p>\n<p>\nOh, and one more not-so-obvious feature of the &#8220;Run Script&#8221; cue is that it will launch\/run\/open practically anything you can think of. It&#8217;s using the same mechanism as <a href=\"http:\/\/www.red-sweater.com\/fastscripts\/\">FastScripts<\/a>, which is very liberal in its willingness to call something a &#8220;script.&#8221; It will run shell scripts, launch\/activate applications, run Automator workflows &#8211; you can even ask it to open a document file for you.\n<\/p>\n<p>\nStay tuned for more on FlexTime&#8217;s secret powers :)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;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&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-169","post","type-post","status-publish","format-standard","hentry","category-flextime"],"_links":{"self":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/169","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/comments?post=169"}],"version-history":[{"count":0,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/169\/revisions"}],"wp:attachment":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/media?parent=169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/categories?post=169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/tags?post=169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}