Question

I want to check when the window of an external application (a Poker On Line Game Table) jumps over all other windows because it's 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 is jumped over all the other visible windows by the API GetForegroundWindow (and in fatc this API continue to return the Handle of the previous window, also if it is UNDER the Game Table that is jumped over ALL the desktop windows). Also the GetTopWindow API don't works.

Now the question is: how to find the handle of the top VISIBLE window (the window that is over all the other open windows for my eyes) also if it is not active???


No, the Window IS NOT a TopMost window: in fact if I click on another window it goes in background. If it should be a TopMost window it would remain on the top.

Probably it is put in the foreground by a WM_SHOW or WM_NOACTIVATE flag.

Was it helpful?

Solution

The poker application must use a Win32 API such as SetForegroundWindow(hWnd) to bring the window to the Top when its your turn.

In order to detect such a call you can use Windbg Script Tracing API calls

You can use it to see the APIs an application is using from your Windbg screen without using another tool. If you need more details from the APIs, just execute LogViewer.exe and open the .lgv file that is automatically created when you use this script.

enter image description here

enter image description here

Output file, with .LGV extension.

enter image description here

LogViewer.exe is part of Debugging Tools For Windows. It's in the same location you installed Windbg. Open the .LGV file using 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 e v
!logexts.logb p
$$
$$ ====================================
$$ Logging is enabled for this process.
$$ ====================================

Once you have all this info, you will know what API call to look out for from a particular caller/DLL/etc and that is the time its your turn, the poker window is ontop and you can use this KB article to Find the Handle of the TopMost Window

OTHER TIPS

EnumWindows and possibly WindowFromPoint API functions. You can use them via P/Invoke in your VB.NET application and be able to find windows either in top to bottom order (EnumWindows) checking their location, caption etc on the way to identify the window of your interest, or directly locate the window at certain position (WindowFromPoint; I thought your window of interested might be popping up in the center of the screen, or centered by another window you already know or you can easily find it by its caption - this way you know the point of your interest on the screen already).

Sounds like the app may be using SetWindowPos(..., HWND_TOPMOST, ...) to become a topmost window. Windows that are positioned this way don't have to be active to appear on top.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top