1

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?

Patrick Pijnappel
  • 7,317
  • 3
  • 39
  • 39

2 Answers2

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