问题
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
);
回答1:
CGEventRef e = CGEventCreateKeyboardEvent(NULL, NULL, true);
CGEventKeyboardSetUnicodeString(e, unicodeStringLength, unicodeString);
CGEventPost(kCGHIDEventTap, e);
来源:https://stackoverflow.com/questions/6943969/how-send-unicode-character-to-active-application