View Full Version : simulate a press key

Sep 6, 2008, 02:25 AM
This is my first thread! I'm Stejano and I hope I can help you and you can help me.
I want to try to simulate an event key of a pression of key of my keyboard.
I've found how to "read" the pression of a button (NSEvent) but I don't find how simulate the pression of a keyboard's key.
How can I do?I use cocoa.


Sep 6, 2008, 12:43 PM
I don't know of a way you can do that directly in Cocoa if you mean a true simulation of the user pressing a key anywhere in an app. You could maybe fake it by constructing and sending keyboard events to whichever view/window the user has active (like the current "key" window). Of course that will only work inside your own application, not in another or in the Finder. You might also be able to use AppleScript to do it.