1
votes

I'm launching an application using NSTask and using NSPipe to get it's stdout and stderr. I'd like to hide it (the GUI) on launch, as the app just does some commands and exits. I can't use NSWorkspace since I need stdout/stderr. Does anyone know of a way to achieve this?

2
is the application being launched an application that you have the code for, or is it some other application that you (or the user) bought & installed? - Michael Dautermann
Some other application that the user installed. - Patrick Pijnappel

2 Answers

0
votes

NSRunningApplication will hand you an object representing the app if you have its process ID: +[NSRunningApplication runningApplicationWithProcessIdentifier:], which you should be able to obtain from -[NSTask processIdentifier].

Then you can send hide to the NSRunningApplication instance.

0
votes
/*
 *  TransformProcessType()
 *  
 *  Summary:
 *    Changes the 'type' of the process specified in the psn parameter.
 *     The type is specified in the transformState parameter.
 *  
 *  Discussion:
 *    Given a psn for an application, this call transforms that
 *    application into the given type.  Foreground applications have a
 *    menu bar and appear in the Dock.  Background applications do not
 *    appear in the Dock, do not have a menu bar ( and should not have

....

This is what I am doing