• 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: Keystrokes for non-ascii letters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keystrokes for non-ascii letters


  • Subject: Re: Keystrokes for non-ascii letters
  • From: Dave DeLong <email@hidden>
  • Date: Sat, 29 Nov 2008 14:03:58 -0700

More questions!  (wheeee  =) )

I've abandoned the NSEvent approach, although it would've been nice if it had worked, and am now trying CGEventKeyboardSetUnicodeString. Here's my code:

CGEventSourceRef eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
CGEventRef keyEventDown = CGEventCreateKeyboardEvent(eventSource, 0, true);
UniChar buffer = '£'; //that's a pound (the currency) sign for all you without unicode support in your email
CGEventKeyboardSetUnicodeString(keyEventDown, 1, &buffer);
CGEventPost(kCGHIDEventTap, keyEventDown);
CFRelease(keyEventDown);


First off, when building it, I get a warning on the "buffer = '£';" line, that it's a "multi-character character constant". What does that mean? Then, when I actually run it, I don't get the pound sign, but get some Asian character that looks like a cross between a camping stove and a two-story house. Lastly, I'm not sure how I can convert my NSString into a UniChar array (which is what the function wants).

I've been all over Google and the various list archives for more information on CGEventKeyboardSetUnicodeString, but have found nothing helpful.

Can anyone point me in the right direction?

Thanks for all your help!

Dave

On 29 Nov, 2008, at 1:27 PM, James W. Walker wrote:

Eric Schlegel already suggested CGEventKeyboardSetUnicodeString, although he misspelled it. As long as you can require 10.5.5 or later, that should do the trick.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Keystrokes for non-ascii letters
      • From: "James W. Walker" <email@hidden>
References: 
 >Keystrokes for non-ascii letters (From: Dave DeLong <email@hidden>)
 >Re: Keystrokes for non-ascii letters (From: Ricky Sharp <email@hidden>)
 >Re: Keystrokes for non-ascii letters (From: Dave DeLong <email@hidden>)
 >Re: Keystrokes for non-ascii letters (From: Bill Bumgarner <email@hidden>)
 >Re: Keystrokes for non-ascii letters (From: Dave DeLong <email@hidden>)
 >Re: Keystrokes for non-ascii letters (From: "James W. Walker" <email@hidden>)

  • Prev by Date: Rollover on custom Cells
  • Next by Date: Re: reading a PDF
  • Previous by thread: Re: Keystrokes for non-ascii letters
  • Next by thread: Re: Keystrokes for non-ascii letters
  • Index(es):
    • Date
    • Thread