Script to display random message?
  • Does anyone have an AppleScript to tell FlexTime to display a random message selected from a text file? It doesn't look hard, but I don't know AppleScript, so if somebody's already done it and is willing to share I'd be grateful.
  • Hi Andy! This is a great idea, so I took a few minutes to whip up a script that demonstrates the concept.

    Unfortunately there's no way currently to have FlexTime display a message *exactly* as if it was displayed by the routine ... that is to say, the timing of the dismissal of the message will be entirely up to the script and not controlled by FlexTime. This can be both a benefit and a curse :)

    http://www.red-sweater.com/AppleScript/FlexTimeRandomMessage.zip

    This script looks for a hardcoded "RandomMessages.txt" in your home directory. It should be easy to modify the hardcoded path to suit your needs. All it does is, when run, opens and finds a random line from that file, and asks FlexTime to show it in a FlexTime-style heads up display.

    Hope this helps!

    Daniel
  • Oh and - in case it's not obvious, you just point any routine's activity to the script by selecting "Run Script" from the activity details configuration. Whenever the the activity's cue is triggered, it will run the script and display a random message.
  • Thanks a lot, Daniel! I'll try that out when I get home tonight.
  • Okay, I couldn't wait. :) The script works very nicely. My only suggestion would be to check for empty lines (and there will be at least one if the text file ends with a newline) to avoid displaying a message window with no message.
  • Good idea - I just modified the script and reposted it. Now it will discard any line that doesn't have "words" in it.
Start a New Discussion

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!