[Pythonmac-SIG] HotKeys and LaunchServices

Valentino Volonghi dialtone at gmail.com
Mon Apr 11 04:23:20 CEST 2011


I've fixed yesterday's problem and it was my fault for not setting the File's Owner in Interface Builder.

My current problem though is different and I don't know how to approach it.

I am trying to do the last 2 bits of the application: start on login and register a global hotkey.

start on login requires LaunchServices and in objective-C it would be a matter of running this:

http://cocoatutorial.grapewave.com/tag/lssharedfilelist-h/

Unfortunately there are 2 problems with that code:

 1) LSSharedFileListRef is not iterable and I don't know how to cast it to (NSArray *) in objective-C or to make it iterable.
 2) kLSSharedFileListItemLast is not exported (this wouldn't be a complex problem if it wasn't for point 1 (I could pass the last item inside the function of course but I'd need to iterate it first).

I tried to use:
_objc.loadBundleVariables(__bundle__, globals(), [('kLSSharedFileListItemLast', '^{OpaqueLSSharedFileListItemRef=}')])

but it segfaults.

Now the second problem is hotkey... That's Carbon API and from the HotKey.py example it would be available under CarbonEvt which is unfortunately absolutely empty while CarbonEvents is not but one without the other is not gonna be very useful.

So without RegisterEventHotKey and UnregisterEventHotKey I don't think I have many chances to do this, at least in Python. I'd need to go the C way and wrap it in a module.

Alternatively is there a way to avoid wrapping in C and instead, just for these 2 cases, and use an ffi method like ctypes?

-- 
Valentino Volonghi aka Dialtone
Now Running MacOSX 10.6
http://www.adroll.com/



More information about the Pythonmac-SIG mailing list