Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How send unicode character to active application?

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
);
like image 725
user486134 Avatar asked Aug 04 '11 15:08

user486134


People also ask

How do I enter Unicode characters?

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.

How do you add Unicode characters in HTML?

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.

How do I insert a Unicode in Word?

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.

How do I type Unicode characters on a Mac?

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).


1 Answers

CGEventRef e = CGEventCreateKeyboardEvent(NULL, NULL, true);
CGEventKeyboardSetUnicodeString(e, unicodeStringLength, unicodeString);   
CGEventPost(kCGHIDEventTap, e);      
like image 190
user486134 Avatar answered Sep 28 '22 02:09

user486134