Tag: findwindow

在C#中创建spy ++的函数“find window …”

我想在C#中创建与spy ++相同的function“Find windows …”。 我试过WINAPI的这个function: HWND WINAPI WindowFromPoint(__in POINT Point); http://msdn.microsoft.com/en-US/library/ms633558.aspx但是我没有到达所有元素,因为它们被禁用或隐藏。 例如,在程序员模式下使用窗口7计算器,如果它们被禁用,我无法使用我的程序获得“ABCDEF”,那么spy ++就可以获得它。 编辑:我试过这个但它不起作用: [DllImport(“user32.dll”)] public static extern ulong GetClassLongPtr(IntPtr hWnd, int nIndex); [DllImport(“user32.dll”)] public static extern IntPtr ChildWindowFromPointEx(IntPtr hWndParent, Win32Point pt, uint uFlags); IntPtr hWnd = WindowFromPoint(myPoint); hWnd= ChildWindowFromPointEx(hWnd , myPoint, 0x0000); myPoint是我鼠标的位置。 我不熟悉WINAPI,我想你的解释是对我缺乏了解。 可以有一个ChildWindowFromPointEx函数的小例子,或者知道我的代码不起作用? thanx你的答案 我试图创建循环,但似乎句柄在另一个句柄下,但不是句柄的子句,循环总是发送相同的句柄,并且当禁用键“abcdef”时没有所需的子句。 你有另一个想法吗?

以编程方式单击“消息框”按钮

正如标题所示,我正在尝试以编程方式模拟MessageBox中的按钮单击。 我之前尝试通过其标题查找其句柄,并在SendMessage()应用WM_CLOSE或SC_CLOSE来关闭MessageBox。 但是,由于存在“是/否”按钮,这不起作用(X按钮显示为灰色)。 现在我试图点击No按钮,如下所示 – : List result = new List(); GCHandle listHandle = GCHandle.Alloc(result); try { IntPtr Window_hWnd = CloseMessageBox.FindWindowByCaption(“#32770”, “LastQuestion”); //Could use null as the first argument too. “#32770” represents classname Dialog. CloseMessageBox.EnumChildWindows(Window_hWnd, (hWnd, lParam) => { StringBuilder sb = new StringBuilder(); foreach (var control in GCHandle.FromIntPtr(lParam).Target as List) { CloseMessageBox.GetWindowText(control, sb, 250); […]

来自user32.dll的FindWindowEx使用dllimport返回零句柄和错误代码127

我需要以编程方式处理另一个Windows应用程序,搜索谷歌我找到了一个使用DLLImport属性处理Windows计算器的示例,并在C#中将user32.dll函数导入托管应用程序。 应用程序正在运行,我正在获取主窗口的句柄,即计算器本身,但后续代码不起作用。 FindWindowEx方法不返回计算器子项的句柄,如按钮和文本框。 我尝试在DLLImport上使用SetLastError = True,发现我收到错误代码127,即“找不到过程”。 这是我从中获取示例应用程序的链接: http://www.codeproject.com/script/Articles/ArticleVersion.aspx?aid=14519&av=34503 如果有人知道如何解决它,请帮忙。 更新:DLLImport是: [DllImport(“user32.dll”, SetLastError = true)] public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle); 不起作用的守则是: hwnd=FindWindow(null,”Calculator”); // This is working, I am getting handle of Calculator // The following is not working, I am getting hwndChild=0 and err = 127 hwndChild = FindWindowEx((IntPtr)hwnd,IntPtr.Zero,”Button”,”1″); […]