Hello.
I am writing a keyboard assistant application, that has to monitor Scroll Lock button keypresses, do not allow the system to pass this button press to applications, and I need to perform some custom action when this button is pressed.
So far I've been using code like this:
if(!AXAPIEnabled() && !AXIsProcessTrusted()) {
ExececuteWithAdminPrivilegesUsingHelperBinary { //this is just pseudocode, i am actually launching a helper application using authorization services here
AXMakeProcessTrusted(pathToExecutable);
}
}
and then I could execute
eventTap = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap,
kCGEventTapOptionDefault, 1 << kCGEventKeyDown, myCGEventCallback, self); //active event tap (can modify events)
and watch and modify scroll lock keypress events.
So, the user started my application, it asked him to enter password to launch helper tool if needed, and then the user had to restart the application and work normally since then.
Now, on 10.8 this approach doesn't work. AXMakeProcessTrusted returns kAXErrorFailure (-25200), and I can do nothing about it. The only thing I can do - is show a message box and ask the user, if he wants to use my application, he has to enable access for assistive devices in System Preferences, manually.
So my question is - is there any other way to watch Scroll Lock keypresses, and do not allow Scroll Lock press event propagate further to the system, without asking user to enable access for assistive devices? Scroll Lock is F14 on Mac keyboards. Maybe installing some filter kext, or some other way?
I do not need to monitor/change/log all the keyboard buttons events, only F14 (scroll lock).
Thank you