Chunk 1978 wrote:

ok... so i've decided to use a simple apple script for this:

tell application "Finder"
        quit
        delay 0.25
        launch
end tell

or this (which i believe is the same thing)

tell application "Finder"
        quit
        delay 0.25
        activate application "Finder"
end tell

but i'd like to know about the delay.  without the delay... in this
script the delay works to save the finder's window state and then to
relaunch the finder.  should i be concerned about this delay on older,
slower computers?  should it be longer?


Quitting an application and relaunching it immediately afterwards is a bit problematic as the 'quit' event will return before the application has finished terminating, with the result that you're trying to start up an application that's in the process of shutting down. Sticking in a delay is crude at best, and potentially unreliable as the time a process takes to terminate might vary. You might try getting the process's PID then repeatedly polling the system to see if that PID still exists, and only proceed with the relaunch once it ceases to be. (If you're in 10.5+, AppleScript's application objects have an 'is running' property, although I don't know if they do this or something else). To be honest, I'm not really sure what's best.

HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to