• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sending a keystroke
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending a keystroke


  • Subject: Re: Sending a keystroke
  • From: Paul Haddad <email@hidden>
  • Date: Sat, 21 Sep 2002 21:14:42 -0500

Hi All,

On Saturday, September 21, 2002, at 02:24 PM, Sam Taylor wrote:

I have my own question on this subject - how do I get the computer to
(temporarily) ignore any modifier keys the user is holding. If I am
trying to send a keyboard shortcut to an application, but the user is
holding down option then either the wrong thing will happen or the
computer will just beep. Using CGPostKeyboardEvent to simulate keyups
for all modifiers down doesn't seem to work. Has anyone solved this?

This seems to work, though I'm not sure if its the "correct" way to do it......

CGInhibitLocalEvents(YES);
CGEnableEventStateCombining(NO);
CGSetLocalEventsFilterDuringSupressionState(kCGEventFilterMaskPermitAllE vents, kCGEventSupressionStateSupressionInterval);

CGPostKeyboardEvent((CGCharCode)NULL, (CGKeyCode)55, true);
CGPostKeyboardEvent((CGCharCode)'v', (CGKeyCode)9, true);
CGPostKeyboardEvent((CGCharCode)'v', (CGKeyCode)9, false);
CGPostKeyboardEvent((CGCharCode)NULL, (CGKeyCode)55, false);

CGEnableEventStateCombining(YES);
CGInhibitLocalEvents(NO);

---
Paul Haddad (aim:ETS Paul)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Sending a keystroke (From: Sam Taylor <email@hidden>)

  • Prev by Date: iTunes feature: OT
  • Next by Date: Re: NSTextField Focus
  • Previous by thread: Re: Sending a keystroke
  • Next by thread: Re: Sending a keystroke
  • Index(es):
    • Date
    • Thread