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
);
Inserting Unicode characters To insert a Unicode character, type the character code, press ALT, and then press X. For example, to type a dollar symbol ($), type 0024, press ALT, and then press X. For more Unicode character codes, see Unicode character code charts by script.
You can enter any Unicode character in an HTML file by taking its decimal numeric character reference and adding an ampersand and a hash at the front and a semi-colon at the end, for example — should display as an em dash (—). This is the method used in the Unicode test pages.
Inserting Unicode CharactersType the character code where you want to insert the Unicode symbol. Press ALT+X to convert the code to the symbol. If you're placing your Unicode character immediately after another character, select just the code before pressing ALT+X.
On your standard Mac keyboard, just type Option and the Unicode number for the character, and the character is applied to whatever text field you're currently typing in. As an example, Mac keyboards have special symbols that indicate Control, Option, and Command (Cmd).
CGEventRef e = CGEventCreateKeyboardEvent(NULL, NULL, true);
CGEventKeyboardSetUnicodeString(e, unicodeStringLength, unicodeString);
CGEventPost(kCGHIDEventTap, e);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With