[Pythonmac-SIG] open program via a protocol (eg. myapp:command)

has hengist.podd at virgin.net
Fri Jul 10 15:13:42 CEST 2009


Brendan Simon (eTRIX) wrote:

> I have an OS X python program that is invoked via a uri on a webpage  
> --
> eg. "myapp:command"
>
> The app is invoked fine (via the plist), but I can't seem to extract  
> the
> "command" from the system args.  sys.argv contains the name of the
> application and some other values.
> example:
>   sys.argv[0] = 'myapp
>   sys.argv[1] = '-psn_0_22123800'
>
>
> How can I my program read the _uri_ that caused the program to be  
> invoked.

You need to install an Apple event handler that responds to the GetURL  
event. Various ways you can do that, depending on whether your Python  
application is Carbon or Cocoa based, has an event loop or runs in  
batch mode, uses argvemulation, etc. For more specific advice, provide  
more details.

HTH

has
-- 
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net



More information about the Pythonmac-SIG mailing list