Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / September 2007



Tip: Looking for answers? Try searching our database.

Quit Application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
p2 - 28 Sep 2007 13:07 GMT
Hi

How can i quit Application from other application ?

I have following details
->application path

Is there any API to send quit event to other application ?

p2
Michael Ash - 28 Sep 2007 14:35 GMT
> Hi
>
[quoted text clipped - 4 lines]
>
> Is there any API to send quit event to other application ?

Send it a Quit Apple Event. Code for how to do this seems a bit scarce but
this may get you started:

http://developer.apple.com/documentation/AppleScript/Conceptual/AppleEvents/crea
te_send_aepg/chapter_7_section_4.html


Signature

Michael Ash
Rogue Amoeba Software

Gregory Weston - 28 Sep 2007 15:22 GMT
> > Hi
> >
[quoted text clipped - 10 lines]
> http://developer.apple.com/documentation/AppleScript/Conceptual/AppleEvents/cr
> eate_send_aepg/chapter_7_section_4.html

Robustly turning a string that happens to be a file system path into an
identifier for a running process is the tricky part of this. I haven't
been able to think of a truly reliable way to do it, although I can
think of a couple of 99% solutions.
Michael Ash - 28 Sep 2007 15:39 GMT
> Robustly turning a string that happens to be a file system path into an
> identifier for a running process is the tricky part of this. I haven't
> been able to think of a truly reliable way to do it, although I can
> think of a couple of 99% solutions.

Make an FSRef from the path, iterate over all processes and call
GetProcessBundleLocation, return any which match, that should coverr
everything.

Signature

Michael Ash
Rogue Amoeba Software

Gregory Weston - 28 Sep 2007 17:47 GMT
> > Robustly turning a string that happens to be a file system path into an
> > identifier for a running process is the tricky part of this. I haven't
[quoted text clipped - 4 lines]
> GetProcessBundleLocation, return any which match, that should coverr
> everything.

Except for apps that moved since launch, depending on when and how the
path the OP was handed was constructed.
Michael Ash - 28 Sep 2007 18:23 GMT
>> > Robustly turning a string that happens to be a file system path into an
>> > identifier for a running process is the tricky part of this. I haven't
[quoted text clipped - 7 lines]
> Except for apps that moved since launch, depending on when and how the
> path the OP was handed was constructed.

Well, if he has a path to where the app actually *is*, and not where it
once *was*, then this will still work, since the FSRefs will follow the
move. If he only has a path to where the app once was, then nothing short
of a guessing game will work without a time machine. But I wouldn't count
that in your 1%, because it's a pathological case, like saying that
Spotlight won't find a file by name if you've changed the name.

Signature

Michael Ash
Rogue Amoeba Software

Gregory Weston - 28 Sep 2007 19:01 GMT
> >> > Robustly turning a string that happens to be a file system path into an
> >> > identifier for a running process is the tricky part of this. I haven't
[quoted text clipped - 14 lines]
> that in your 1%, because it's a pathological case, like saying that
> Spotlight won't find a file by name if you've changed the name.

Spotlight'll still work if you change the name of any number of
nonterminal nodes in the path. People do rename volumes and folders from
time to time. I think the real answer to "How can I terminate a process
given a path" is "first look to see if you can get something better like
a bundle ID or creator code." Even an alias would be more reliable.
Michael Ash - 28 Sep 2007 21:31 GMT
>> Well, if he has a path to where the app actually *is*, and not where it
>> once *was*, then this will still work, since the FSRefs will follow the
[quoted text clipped - 8 lines]
> given a path" is "first look to see if you can get something better like
> a bundle ID or creator code." Even an alias would be more reliable.

Yes, a lot depends on where the path comes from. I had taken the "path to
the app" as a given, rather than assuming it's "a path which was once to
the app".

If the path comes from, say, an open panel which just finished running
then you're pretty safe, aside from the race conditions inherent in any
use of paths which nobody seems to want to talk about.

If the path comes out of preferences or something then you're right and
it's just plain the wrong approach to use in the first place. Storing the
bundle ID would be the right way to proceed in this case, IMO.

Signature

Michael Ash
Rogue Amoeba Software

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.