You should not recognize them; and this is not generally possible if this is a different application. Your virtual keyboard should simply imitate keyboard not caring about focus. For this purpose, you need to simulate keyboard input on low-level. Use Windows API
SendInput
, see
http://msdn.microsoft.com/en-us/library/ms646310(v=vs.85).aspx[
^].
There is one delicate moment with the window of your virtual keyboard. As you type by pressing keys using the mouse, it will grab the focus from your target application. To prevent this, you need to do two changes on the window style: it should be non-focusable and always-on-top, at least when you use it. Use extended styles
WS_EX_NOACTIVATE | WS_EX_TOPMOST
, see .
http://msdn.microsoft.com/en-us/library/ff700543(v=vs.85).aspx[
^]. You can do it using Windows API
SetWindowLong
with the parameter
nIndex = GWL_EXSTYLE
, see
http://msdn.microsoft.com/en-us/library/ms633591(v=vs.85).aspx[
^].
—SA