Hot Keys and CGEventRef

  • I am trying to use Carbon Hot Key to send simulated keyboard events to the front application using CGEventRef, the problem is can't control the modifier keys that get sent to the front app completely. For example if the hot key contains a command modifier then if I send a up-arrow key to the front application a command+up-arrow is sent instead. I have tried to send modifier key up event to try remove the modifier key but it doesn't work. Perhaps I shouldn't be using CGEventRef I should be using something else. Any advice would be appreciated.

    Nathan Day
    Software Engineer
    mobile:        +61 (0)4 3863 2407
    home page:    http://homepage.mac.com/nathan_day/
  • I'm not sure what Carbon Hot Key is or exactly what you're trying to do, but having just implemented some wild Quartz event reverse engineering to send real NSTouch and Cocoa gesture data from the Magic Mouse (http://calftrail.com/sesamouse/), I'll take a stab at this:

    I'm assuming you are using CGEventCreateKeyboardEvent to create the events? Are you making sure to CGEventPost them to the intended tap location? I personally wouldn't bother with the PSN posting if you're going for the front application, but let the system do its job of targeting.

    Have you tried filtering out the modifier down keys via an active event tap, so that you don't even have to try canceling them out later?

    hope this helps,
    -natevw

    On Jan 15, 2010, at 11:39 PM, Nathan Day wrote:
    > I am trying to use Carbon Hot Key to send simulated keyboard events to the front application using CGEventRef, the problem is can't control the modifier keys that get sent to the front app completely. For example if the hot key contains a command modifier then if I send a up-arrow key to the front application a command+up-arrow is sent instead. I have tried to send modifier key up event to try remove the modifier key but it doesn't work. Perhaps I shouldn't be using CGEventRef I should be using something else. Any advice would be appreciated.
    >
    > Nathan Day
    > Software Engineer
    > mobile:        +61 (0)4 3863 2407
    > home page:    http://homepage.mac.com/nathan_day/
    >
    >
    >
    >
    >
    >
    >
    > _______________________________________________
    > MacOSX-dev mailing list
    > <MacOSX-dev...>
    > http://www.omnigroup.com/mailman/listinfo/macosx-dev