on 2008-06-19 3:46 AM, Daniel at [EMAIL PROTECTED] wrote:

> CGEventRef event = CGEventCreateKeyboardEvent(NULL, (CGKeyCode) 40, true);
> CGEventPost(kCGHIDEventTap, event);

I wouldn't expect you to get even the "k" character with that code by
itself. To type a character requires posting a key down event AND a key up
event with  the same keycode. So add these two lines at the end of your
code:

CGEventSetType(event, kCGEventKeyDown);
CGEventPost(kCGHIDEventTap, event);

Or simply create a separate keyboard event with false in the keyDown
parameter and post it.

Also, you might have better luck with one of the other tap locations, such
as kCGSessionEventTap. I believe the kCGHIDEventTap location requires you to
run as root or it doesn't work.

To identify the valid keycodes for your keyboard, get one of the Key Code
utililties that are floating around on the Web. My free PreFab Event Taps
Testbench is one such, at <http://prefabsoftware.com/eventtapstestbench>.

--

Bill Cheeseman - [EMAIL PROTECTED]
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com

PreFab Software - www.prefabsoftware.com


_______________________________________________

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