<分区>
Possible Duplicate:
Create an On-screen Keyboard
我正在尝试编写一个虚拟键盘。你能告诉我如何获得聚焦窗口的描述符 hWnd
吗? (它可以用于 Word、Excel、Skype 等)
我正在使用 findWindow()
,但为此我必须知道窗口的名称。
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"));
}