Locate the window handle at the top of the screen.

I want to check when an external application window (Poker On Line Game Table) jumps to all other windows, because it is my turn to play.

The problem is that the game table jumps in the foreground ... but the window DOES NOT BECOME ACTIVE ... this means that I can’t check if it jumps over all the visible windows of the GetForegroundWindow API (and in fatc this API continues to return the Handle of the previous windows, also if it is under the game table, which jumps over ALL windows of the desktop). Also, the GetTopWindow API does not work.

Now the question arises: how to find the handle of the top VISIBLE window (the window that is above all other open windows for my eyes), also if it is inactive ???


No, the window is NOT a TopMost window: in fact, if I click on another window, it will be in the background. If this is a TopMost window, it will remain on top.

It is probably placed in the foreground using the WM_SHOW or WM_NOACTIVATE icon.

+6
source share
3 answers

A poker application should use the Win32 API, such as SetForegroundWindow(hWnd) , to bring the window to the top when your move.

To detect such a call, you can use the Windbg Script API trace API

You can use it to view the APIs that the application uses from your Windbg without using another tool. If you need more information from the API, just run LogViewer.exe and open the .lgv file, which is automatically created when you use this script.

enter image description here

enter image description here

Output file with the extension .LGV.

enter image description here

LogViewer.exe is part of the debugging tools for Windows. It is in the same place where you installed Windbg. Open the .LGV file with LogViewer.exe:

enter image description here

Source code for API_TRACING.TXT:

 $$ $$ ============================================================================= $$ Trace APIs during the Debugging Session. $$ Creates a log on Desktop and Windbg window. $$ To see the more verbose log run logviewer.exe from Debugging Tools for Windows $$ and open the file that has the .lgv extension. $$ This file is inside LogExts on your desktop. $$ $$ Compatibility: Win32, should work on Win64. $$ $$ Usage: $$>< to run the program. $$ $$ Roberto Alexis Farah $$ Blog: blogs.msdn.com/debuggingtoolbox/ $$ $$ All my scripts are provided "AS IS" with no warranties, and confer no rights. $$ ============================================================================= $$ !logexts.loge !logexts.logc e * !logexts.logo ev !logexts.logb p $$ $$ ==================================== $$ Logging is enabled for this process. $$ ==================================== 

After you have all this information, you will find out which API call to look for from the specific caller / DLL / etc. and , that is, the time of its rotation , the poker window is turned on and you can use this article in the article Find the handle of the TopMost window

0
source

EnumWindows and possibly the WindowFromPoint API function. You can use them through P / Invoke in your VB.NET application and be able to find windows in upper and lower order (EnumWindows), checking their location, signature, etc., To determine the window of your interest or directly find the window in a specific location (WindowFromPoint; I thought that your window may appear in the center of the screen or concentrated in another window that you already know, or you can easily find it under the heading - this way you know that the point of your interest on the screen is already).

+2
source

It looks like the application can use SetWindowPos(..., HWND_TOPMOST, ...) to become the topmost window. Windows arranged in this way must not be active in order to be displayed on top.

In this case, you can try using GetWindow(..., GW_HWNDFIRST) to find the topmost window in the z-order of the window manager. See http://support.microsoft.com/kb/126386 for a short snippet of code that does this.

+1
source

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


All Articles