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

On 29 Nov, 2008, at 3:10 PM, James W. Walker wrote:

Your source file is probably encoded as UTF-8, so the pound character is getting interpreted as 2 bytes of UTF-8, not a single UTF-16 character. Don't try to enter Unicode directly in your source.

Lastly, I'm not sure how I can convert my NSString into a UniChar array (which is what the function wants).

See the getCharacters: method.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to