On Wed, Jul 19, 2006 at 11:29:45PM -0700, Robert Stephenson wrote:
> As far as I can see, appscript lacks an equivalent of Applescript's
> launch verb, which opens an app without running it (useful for apps
> like Textedit or Keynote that create default documents when they
> run). Did I miss something, or how can you open a file without the
> default run action?
AppleScript actually does two different things when you 'launch app
"XYZ"'. First, it opens the app in the background; second, it sends a
"launch" event (ascr/noop) to the process. Python doesn't wrap the
pieces of Launch Services needed to pass an initial Apple Event to an
application, so appscript can't do this - though it could.
I just updated my 'launch' tool to do this. Feel free to steal the
appropriate code.
<http://web.sabi.net/nriley/software/launch-1.1d2.tar.gz>
Examples:
% launch -Li com.apple.TextEdit
- launches in foreground, no window
% launch -Lbi com.apple.TextEdit
- launches in background, no window, like AppleScript
Note - if the application is already running, the above commands still
open a window. To truly emulate AppleScript you'd need to check if
the app is already running, and if so, don't do anything.
--
Nicholas Riley <[EMAIL PROTECTED]> | <http://www.uiuc.edu/ph/www/njriley>
_______________________________________________
Pythonmac-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig