Jump to content

How to detect new title-less popup window?


Mbee
 Share

Recommended Posts

I'm working on automating a third-party app that doesn't use the standard Windows GUI functions (a firewall application). This means that I'm forced to do most everything with brute-force MouseClick() and the like. The windows have no titles, and they're class names are often duplicated by multiple windows.

I've been able to identify when various popup windows are opened by testing for a window that has a particular size and/or screen location. All except for one (so far). It has no title, the class names are duplicated by the previous window, and there's no consistency as to where the window will open or what size it will be. In short, I need a way to detect when that popup window opens, but how?

I tried the following function:

Func _WaitForNewTopWin()

    Local $Lf_PrevTopWinHdl, $Lf_WinHdl

    $Lf_PrevTopWinHdl = _WinAPI_GetTopWindow( 0 )

    For $i = 1 To (60 * 1000) / 250
        Sleep( 250 )
        $Lf_WinHdl = _WinAPI_GetTopWindow( 0 )
        If $Lf_WinHdl <> $Lf_PrevTopWinHdl Then
            Return SetError( 0, 0, $Lf_WinHdl )
        EndIf
    Next

    Return SetError( 1, 0, 0 )

EndFunc

But this always times out.

(BTW, the documentation for GetTopWindow reads: "Handle to the parent window whose child windows are to be examined. If this parameter is 0, the function returns a handle to the window at the top of the Z order." What, pray tell, is "the z order"? I assume it means Z axis, that is, top to bottom, which is what I want. But am I correct?)

What technique would you use to detect a new top window?  Thanks!

 

Link to comment
Share on other sites

if you know the parent window's handle, you can test each of those duplicates with _WinAPI_GetAncestor to confirm which one is derived from the parent window thus getting the correct handle

if this isn't the case add extra details as to  what is the class name of those duplicates 

is it "#32768" by chance? ,if yes then you can easily pull out something from LarsJ function over here 

Edited by Deye
Link to comment
Share on other sites

Thanks, @Deye! The GetAncestor function looks promising.

I also noticed that the two windows' styles are different, so I could hard code those. That approach rubs the programmer in me in the wrong way, since it's not definitive. But the probability that the specific style value is associated with the window in question is extremely high, so I may end up going that way.

Thanks again

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...