在上一个问题中,我询问了如何将文本发送到记事本.它帮了我很大的忙.对于第2部分,这是相同应用的mIRC的简化版本:
[DllImport("User32.dll", EntryPoint = "FindWindow")] public static extern IntPtr FindWindow(String lpClassName, String lpWindowName); [DllImport("user32.dll", EntryPoint = "FindWindowEx")] public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); [DllImport("User32.dll")] public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam); IntPtr mainHandle = FindWindow("mIRC", null); IntPtr serverHandle = FindWindowEx(mainHandle, new IntPtr(0), "MDIClient", null); IntPtr chanHandle = FindWindowEx(serverHandle, new IntPtr(0), "mIRC_Channel", null); IntPtr editHandle = FindWindowEx(chanHandle, new IntPtr(0), "Edit", null); SendMessage(editHandle, 0x000C, 0, textBox1.Text);
这似乎对我来说是正确的,除了它不起作用!是否窗口名称不正确(MDIClient,mIRC_Channel和Edit)?这些是我通过Google搜索"FindWindowEx mIRC"在网站上找到的值.
1.)我在上面做错了什么?
2.)作为参考,一般来说,有一种简单的方法可以找到所有用于的窗口名称FindWindowEx()
?