• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTask's launchedTaskWithLaunchPath:arguments: versus NSWorkspace's launchApplication:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask's launchedTaskWithLaunchPath:arguments: versus NSWorkspace's launchApplication:


  • Subject: Re: NSTask's launchedTaskWithLaunchPath:arguments: versus NSWorkspace's launchApplication:
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Thu, 20 Dec 2007 18:50:03 +0100


Le 20 déc. 07 à 18:22, Mattias Arrelid a écrit :

Hi,

We have an application that needs to launch another application from within itself. Now, we could either do this using NSTask's "launchedTaskWithLaunchPath:arguments:" or getting the shared workspace from NSWorkspace and send "launchApplication:" to it.

Now the problem is that we want the newly launched application to (1) get focus (e.g. we want it to be the active application from now on) and (2) to be able to receive the regular command line arguments we send it. The two above mentioned operations either accomplishes 1 (NSWorkspace) or 2 (NSTask) but not both simultaneously.

Does anyone know how I could solve this?

Thanks in advance, and merry christmas.
Mattias

I don't know a proper Cocoa way to do it but i can give you a workaround.


NSTask *task = [NSTask ......];
pid_t pid = [task processIdentifier];
ProcessSerialNumber psn;
if (noErr == GetProcessForPID(pid, &psn)) {
	SetFrontProcess(&psn);
}

The LSOpenApplication() function may also works, but the doc says that argv is ignored on 10.4, so use it only if you want to target Leopard.
Merry christmas too


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSTask's launchedTaskWithLaunchPath:arguments: versus NSWorkspace's launchApplication:
      • From: Constantine <email@hidden>
References: 
 >NSTask's launchedTaskWithLaunchPath:arguments: versus NSWorkspace's launchApplication: (From: Mattias Arrelid <email@hidden>)

  • Prev by Date: NSTask's launchedTaskWithLaunchPath:arguments: versus NSWorkspace's launchApplication:
  • Next by Date: Re: Trouble with Leopard's newly enhanced NSSplitView
  • Previous by thread: NSTask's launchedTaskWithLaunchPath:arguments: versus NSWorkspace's launchApplication:
  • Next by thread: Re: NSTask's launchedTaskWithLaunchPath:arguments: versus NSWorkspace's launchApplication:
  • Index(es):
    • Date
    • Thread