-1

I have an Android device and have connected it with PC using ADB, and the Android device acts as a server while the PC acts as a client (communicate with TCP).

When the Android device outputs some characters, only the English words and Chinese words considered, the PC can obtain those characters and output those onto the program with active cursor.

My PC app is written with C/C++. By the way, if the outputs is only one English letter, I can simulate it with key_press event , but this method doesn't work on Chinese letter.

(output is 'a' -> PC catches it -> simulate press 'a' key -> can output to program with active cursor)

Now I want a way to output string (not just a letter) to any other program which owns the active cursor.

The process is like:

(Android outputs 'hello world' -> PC catches 'hello world' -> outputs to program which owns the active cursor)

One more thing, 'owns the active cursor' means waiting for editing. (when you edit MS word file, this file is waiting for editing and owns the active cursor also)

chenzhongpu
  • 6,193
  • 8
  • 41
  • 79

1 Answers1

1

It sounds like the function you are looking for is SendInput.

Depending on what sort of keystrokes you need to inject, and where you need to inject them, your text-injection code might need to run inside a high-integrity process -- from the linked page: "This function is subject to UIPI. Applications are permitted to inject input only into applications that are at an equal or lesser integrity level."

(Note in particular the "UIAccess for UI automation applications" section in the second linked article)

Jeremy Friesner
  • 70,199
  • 15
  • 131
  • 234
  • `SendInput` is also simulate the `key event`. If I want to input a string like '你好'(Chinese words, not English letter), those cannot be simulated by `key event` directly. – chenzhongpu Nov 07 '14 at 04:49
  • Are you sure about that? http://stackoverflow.com/questions/22291282/using-sendinput-to-send-unicode-characters-beyond-uffff – Jeremy Friesner Nov 07 '14 at 16:37