Launching A Workflow App Every 5 minutes

Hi I’m an extreme noobie at Applescript so if you guys could bear with me. I’m trying to launch an app in my Applications folder called “Screenshot” and I’d like it to repeat the launch every 5 minutes a bunch of times using Applescript and I’ve come across a snag in a very, very, easy script so here it is:

tell application “Screenshot”
launch
delay 360
repeat 50000
end tell

I get a message that says:

Expected “end” but found “end tell”.

Hope you can help! thanx.

your error is because “repeat” needs an end statement. Here’s what you probably want…

repeat 50000 times
	tell application "Screenshot"
		launch
	end tell
	delay 360
end repeat

Note how your code goes inside of the repeat loop.

Here’s a better way to do it. Save this as a “stay open” application. Then run the application whenever you want. The advantage of this is that this application will show up in your dock, and therefore you can quit it like any other application whenever you want, thus you don’t have to wait for “50000” repeat loops to finish before the script finishes running.

Note: the “on idle” handler only works in a “stay open” application, so you can’t run this directly from Script Editor. It needs to be saved as a stay open app first.

on idle
	tell application "Screenshot"
		launch
	end tell
	return 360
end idle

Or you could have launchd loadit at a certain interval. by adapting this guide to suit your application http://textsnippets.com/posts/show/298, then you would not have to worrie about it dying on you whilst it must remain idle for ever.