views:

28

answers:

0

Hello!

I'm writing a OSX PDF Workflow in ObjC and C. A single executable ("UNIX Tool" as named in the Apple reference), that reads in the spooled PDF file, does some parsing.

I'd like to give more functionality by enabling a key-down event handling, meaning
- when user opens print dialog in an application
- and chooses to left-mouse-click on the custom made pdf workflow to run it
- depending on if a keyboard key is down (i.e. option key, but "any key down" would be enough for me) when running that workflow
- a decision is made in the code.

I have read NSEvent and Carbon Event Manager reference and it seems that in this case (a plain unix executable + not run as root) it's not possible. Or is it? Many thanks in advance, Kroko

Edit:

//Carbon
((GetCurrentKeyModifiers() & optionKey) == optionKey) ? NSLog(@"Opt enabled (carbon)!") : NSLog(@"Opt disabled (carbon)!");

//Cocoa
(([NSEvent modifierFlags] & NSAlternateKeyMask) == NSAlternateKeyMask) ? NSLog(@"Opt enabled (cocoa)!") : NSLog(@"Opt disabled (cocoa)!");

;)