|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|
|Sync Creates duplicates (or more) in Contacts||Bucharoo1||iCloud and Apple Services||5||Jul 9, 2011 11:12 PM|
|Applescript with cocoa||Renmusxd||Mac Programming||0||Nov 16, 2010 11:06 PM|
|AppleScript Application||fivetoadsloth||OS X||0||Nov 15, 2010 06:35 PM|
|Handling duplicate entry errors?||MythicFrost||Web Design and Development||5||Apr 7, 2010 11:05 AM|
|Handling Duplicates||jayb2000||Digital Photography||0||Jan 24, 2007 07:16 PM|
All times are GMT -5. The time now is 09:14 AM.