Re: Keystrokes for non-ascii letters (SOLVED)
Re: Keystrokes for non-ascii letters (SOLVED)
- Subject: Re: Keystrokes for non-ascii letters (SOLVED)
- From: Jean-Daniel Dupas <email@hidden>
- Date: Sun, 30 Nov 2008 11:58:36 +0100
Le 30 nov. 08 à 01:02, Dave DeLong a écrit :
Fantastic! I've gotten it to work, and it works beautifully! Thank
you, James (and everyone else) for helping me with this.
For archival purposes, here's my code:
CGEventSourceRef eventSource =
CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
CGEventRef keyEventDown = CGEventCreateKeyboardEvent(eventSource,
0, true);
NSString * characters = ;//some UTF16 string acquired from
somewhere. in my case, an NSData object
UniChar buffer;
for (int i = 0; i < [characters length]; i++) {
[characters getCharacters:&buffer range:NSMakeRange(i, 1)];
keyEventDown = CGEventCreateKeyboardEvent(eventSource, 1, true);
CGEventKeyboardSetUnicodeString(keyEventDown, 1, &buffer);
CGEventPost(kCGHIDEventTap, keyEventDown);
CFRelease(keyEventDown);
}
CFRelease(eventSource);
Thanks again for all your help!
Dave
Just a detail, but you may prefere -[NSString characterAtIndex:]
instead of -[NSString getCharacters:buffer:]
_______________________________________________
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