Create a "find window ..." function for spy ++ in C #

I want to create the same "Find windows ..." function for spy ++ in C #. I tried using this WINAPI function:

HWND WINAPI WindowFromPoint(__in POINT Point); 

http://msdn.microsoft.com/en-US/library/ms633558.aspx But I did not come to get all the elements because they are disabled or hidden.

For example, with a window 7 calculator in programming mode, I cannot get "ABCDEF", with my program, if they are disabled, then spy ++ can get it.

Edit: I tried this, but it does not work:

 [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 is the position of my mouse.

I am not familiar with WINAPI, and I present with your explanation that this is a lack of understanding of me. Is it possible to have a small example of the ChildWindowFromPointEx function or find out that my code is not working? thanks for your reply


I am trying to create a loop, but it looks like the descriptor is under a different descriptor, but is not a child of the descriptor, the loop always sends the same descriptor, not the child of the desire, when the "abcdef" key is disabled. Do you have another idea?

+4
source share
1 answer

WindowFromPoint returns a window handle. Since you are working with disabled / hidden windows, you would like to use ChildWindowFromPointEx , passing in hwndParent like any handle obtained from WindowFromPoint .

You may find the following article: http://blogs.msdn.com/b/oldnewthing/archive/2010/12/30/10110077.aspx


As for the added code, ChildWindowFromPointEx takes the coordinates of the client, while the coordinates of the mouse position you have the coordinates of the screen. You can do the conversion using ScreenToClient .

Note. This is a WinAPI way. I have no idea if any C # APIs ship.

+5
source

Source: https://habr.com/ru/post/1399106/


All Articles