I need something like SendInput in Windows API.
I see this method, I don't know there is anyway to convert unicode character to virtual Key code.
CGEventRef CGEventCreateKeyboardEvent ( CGEventSourceRef source, CGKeyCode virtualKey, bool keyDown ); I need something like SendInput in Windows API.
I see this method, I don't know there is anyway to convert unicode character to virtual Key code.
CGEventRef CGEventCreateKeyboardEvent ( CGEventSourceRef source, CGKeyCode virtualKey, bool keyDown ); CGEventRef e = CGEventCreateKeyboardEvent(NULL, NULL, true); CGEventKeyboardSetUnicodeString(e, unicodeStringLength, unicodeString); CGEventPost(kCGHIDEventTap, e); NULL as the second parameter of CGEventCreateKeyboardEvent, because it's not a pointer. It happens to work, because the NULL is treated as zero, which is a valid key code. Also note that you should say CFRelease(e) at the end.