Possible Duplicate:
Create an On-screen Keyboard
I'm trying to write a virtual keyboard. Can you tell me how I can get the descriptor hWnd
of the focused window? (It can be for Word, Excel, Skype, etc.)
I'm using findWindow()
, but for that I must know the name of the window.
IntPtr hWnd = FindWindow("Notepad", null);
if (!hWnd.Equals(IntPtr.Zero))
{
MessageBox.Show("Tagil");
IntPtr edithWnd = FindWindowEx(hWnd, IntPtr.Zero, "Edit", null);
if (!edithWnd.Equals(IntPtr.Zero))
SendMessage(hWnd, WM_SETTEXT, IntPtr.Zero, new StringBuilder("Hello World"));
}