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?
Asked
Active
Viewed 275 times
1
-
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 May 18 '13 at 20:34
-
Some other application that the user installed. – Patrick Pijnappel May 18 '13 at 21:55
2 Answers
0
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.

jscs
- 63,694
- 13
- 151
- 195
-
This does work, but it only works once the app gui is fulled loaded and shown, so it will noticeably be visible for a split second before it is hidden. – Patrick Pijnappel May 18 '13 at 22:18
0
/*
* 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

Tom Andersen
- 7,132
- 3
- 38
- 55