Re: Keystrokes for non-ascii letters
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