tags:

views:

20

answers:

0

Hi All,

I am working on the application whete I want to pass on the key strokes to a remote application. all key strokes I've done should get pass on to my remote application. The UI of this application is in Qt. all works fine if I remotely write any thing on TextEdit or any other mac native application but when I try to pass Capital letters to any qt Window ( in any text box or combo box ) or on the UI of same application, they show up as small letters. I am using CGEventPost() to post all such events. Here is the code snippet I am using to post Caps Lock event.

             // Post Caps lock event.
    CGEventRef CapsOnKeyboardEvent = CGEventCreateKeyboardEvent(NULL, 57, true);

    CGEventSetType(CapsOnKeyboardEvent, kCGEventKeyDown);
    // Post the event to the event system of the computer
    CGEventPost(kCGHIDEventTap || kCGSessionEventTap || kCGAnnotatedSessionEventTap, CapsOnKeyboardEvent);

    CFRelease(CapsOnKeyboardEvent);

    printf("#### Posting Caps Lock event\n");

//  Now Post the key event.
// Create a Quartz event for the given keyboard event
CGEventRef KeyboardEvent = CGEventCreateKeyboardEvent(NULL, KEY_CODE /*character which is to be printed */, bKeyDown);

if (KeyboardEvent)
{
    // Customize the event
    CGEventSetType(KeyboardEvent, kCGEventKeyDown);

    // Post the event to the event system of the computer
    CGEventPost(kCGHIDEventTap, KeyboardEvent);

    // Release the event
    CFRelease(KeyboardEvent);
}

So after sending Caps event to the system I am sending the Character to be printed in caps. I am able to inject capital letters to all Mac native applications where as not on any Qt Window or dialog box. Is it a limitation of Qt? Any help or suggestion will be appreciated!

Thanks Manish