Re: How do I move my running app?
Re: How do I move my running app?
- Subject: Re: How do I move my running app?
- From: "Alan Smith" <email@hidden>
- Date: Tue, 4 Jul 2006 10:58:17 -0400
Thanks everyone,
I looked in the Sparkle source and found what I wanted. It was a call
using system() that would restart the app Sparkle was running in.
After slight modification it does exactly what I want:
setenv("OLD_LAUNCH_PATH", [[[NSBundle mainBundle] bundlePath] UTF8String], 1);
setenv("NEW_LAUNCH_PATH", [@"/Users/EV Manager.app" UTF8String], 2);
system("/bin/bash -c '{ for (( i = 0; i < 3000 && $(echo $(/bin/ps
-xp $PPID|/usr/bin/wc -l))-1; i++ )); do\n"
" /bin/sleep .2;\n"
" done\n"
" mv \"${OLD_LAUNCH_PATH}\" \"${NEW_LAUNCH_PATH}\"\n"
" if [[ $(/bin/ps -xp $PPID|/usr/bin/wc -l) -ne 2 ]]; then\n"
" /usr/bin/open \"${NEW_LAUNCH_PATH}\"\n"
" fi\n"
"} &>/dev/null &'");
[[NSApplication sharedApplication] terminate:self];
Works like a charm.
Peace, Alan
On 7/3/06, Satoshi Matsumoto <email@hidden> wrote:
Hi, Alan
on 06.7.4 8:24 AM, Alan Smith at email@hidden wrote:
> On queue, I want to move my app into a folder that would have just
> been created. I've found that this can't be done if the app is
> running.
> I need to find a way to run a command so it sleeps for a few seconds
> while my app quits, then move the app and restart it.
This is not a Cocoa app but an AppleSript "Restart Finder" that quit Finder
and wait while Finder is quitting, then launch Finder again.
---------------------------
tell application "Finder" to quit
set theTime to time of (current date)
set maxTime to theTime + 3
repeat while theTime < maxTime
if time of (current date) > theTime then
if IsProcessExist("Finder") is false then
tell application "Finder" to launch
return
end if
set theTime to time of (current date)
end if
end repeat
display dialog "Failed to quit Finder!" buttons {"OK"}
return
on IsProcessExist(inAppName)
tell application "System Events"
copy every process to theList
set outResult to false
repeat with theItem in theList
try
if name of theItem is inAppName then
set outResult to true
return outResult
end if
on error
set outResult to false
return outResult
end try
end repeat
end tell
return outResult
end IsProcessExist
---------------------------
Satoshi
-----------------------------------------------------
Satoshi Matsumoto <email@hidden>
816-5 Odake, Odawara, Kanagawa, Japan 256-0802
--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"Don't waste your life doing things others have already done."
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden