Enlightened ones: Can you suggest how I could run a small script repeatedly, yet stop it easily if I need to?
Background is that I use Citrix Workspace to run apps on a Windows server, and it times out after just a few minutes of inactivity. Reconnecting involves a password and an SMS message, so it’s a pain.
So I wrote an AppleScript that runs a loop: every five minutes it checks to see whether Citrix Workspace is running in the background. If that’s so, it activates Citrix Workspace, types a harmless keystroke, and returns to the app that was previously in the front. It’s not elegant but it seems to work.
I’ve set the script to run for a couple of hours once it’s started. Once it’s running, though, I would like a way to break out without force-quitting Script Editor (or the app that I could build from the script). Some feedback about the length of time left on the clock would be good, too.
I could put the whole script in a repeat loop that puts up a dialog box and checks for input (
if button returned of the result is "Stop" then exit repeat).
But is there a better way, perhaps by taking the loop out of the AppleScript and using some other technique (cron?) to run it every five minutes? Ideally I’d control it from the menubar but that’s probably a step too far.
I reckon I’m missing a trick somewhere and I’d be grateful for creative suggestions.