|Dec 22, 2010, 05:48 AM||#1|
Handling Duplicate AppleScripts
I have an AppleScript-based application that I have set a cron job to run every 15 minutes. This part works perfectly. However, when the script opens, it pauses and waits for user interaction. Sometimes I put it off, and by the time the next 15 minutes rolls around, a second instance opens.
What I’d like to have happen is: when the app launches, it checks to see if another instance is already running, brings that instance to the front, and quits itself. Conversely, it could quit the one that’s already running and bring itself to the front. Either way, I’d wind up with a single instance of the application as the frontmost window.
Right now, the closest I’ve come is:
tell application "System Events" to set previousScript to (name of processes) contains "the app name.app" if previousScript is true then tell application "the app name" to activate return false end if
So, bottom line: how can I check for another instance of the same script that’s doing the checking, and operate on that?
“Aunque el mono se vista de seda, mono se queda.”
|Dec 22, 2010, 05:53 AM||#2|
Get the script to create a file somewhere at the start and delete it at the end. Check for the existence of that file and quit if it already exists.
Sponsor me to cycle 100Km round London in the dark
|applescript, applescript help, code, duplicates|
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|AppleScripts work but flood Console with sandbox errors||Aeryn||Mac Programming||2||Nov 24, 2013 09:38 AM|
|EyeTV, HDHomerun Dual, and Recording OTA - Exporting, AppleScripts, etc.||cpeek||Apple TV and Home Theater||14||Apr 12, 2013 12:54 AM|
|AppleScripts snippets thread||moonman239||Mac Programming||1||Jan 14, 2013 11:37 PM|
|Most consistent way of referring to iTunes playlists in Applescripts||fhill2||Mac Programming||0||Jun 22, 2012 07:57 PM|
|iteration of a list in applescripts||fhill2||Mac Programming||4||Jun 4, 2012 09:04 AM|
All times are GMT -5. The time now is 09:38 AM.