Hello,
I've recently been having issues with CGEventRef, namely with the function key. Basically what I have is:
source = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState); CGEventRef functionDown = CGEventCreateKeyboardEvent(source, kVK_Function, true); CGEventPost(kCGHIDEventTap, functionDown); CFRelease(functionDown);
Then I do a short delay with usleep, and then I do the same thing for the false (up) state. Using a tool called Ukelele, I can see that the function key is indeed going down, which is good. However, If i put like a left arrow down/up or right arrow down/up in between, all that's triggered is the left or right arrow (no page up, page down). So what it really seems like is that the function key isn't technically going down or up. Is there something I'm doing wrong, or is this what's supposed to happen? I assume that when the user presses the function key and then a right arrow, the keyCode for the rightArrow is translated into the keyCode for end, but it seems like this is not happening in my situation.
Along the same lines, when using the kCGEventFlagMaskSecondaryFn mask (which should put function down), again it doesn't seem to trigger.
Any help would be greatly appreciated!
Thanks,
Joe Turner |