Jump to content

How do you detect a dialog box inside of a program, same title?


Recommended Posts

What's the new window's class?  If it's a #32770, this will grab it (it grabs enabled popups):

Local $hChild, $iTimer = TimerInit()
$hChild = _WinAPI_GetWindow($hYourParentHWND,6)
While Not IsHWnd($hChild) And TimerDiff($iTimer)<10000
    Sleep(100)
    $hChild = _WinAPI_GetWindow($hYourParentHWND,6)
WEnd
If IsHWnd($hChild) Then
    ConsoleWrite(WinGetTitle($hChild) & @CRLF)
    ConsoleWrite(WinGetText($hChild) & @CRLF)
Else
    ConsoleWrite("no 'enabled popup' within 10 seconds of starting the script" & @CRLF)
EndIf
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

JohnOne

eClinicalWorks, I will post a picture of the password timeout window I am talking about, once I get it. 

BrewManNH

Believe it or not I have read all these posts several times now, I have been browsing the forums and doing many Google searches for a answer to this question; only recently have I decided to post this question. Handles will not work as they change each time I run the program, the window I need to detect pops up at random times and in no order. I bet there are a thousand windows that can and might be opened before a user decides to walk away and let there logon time out, some times it even happens when they are actively using the program.

Thanks for ya'll's input and help!

Link to comment
Share on other sites

Compile and run this.

$G1 = GUICreate("Same Title")
$b = GUICtrlCreateButton("button", 10, 10)
GUISetState()

While 3
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $b
            _ChildGui()
    EndSwitch
WEnd

Func _ChildGui()
    $G2 = GUICreate("Same Title")
    GUISetState()
    GUISwitch($G2)
    While 3
        If GUIGetMsg() = -3 Then
            ExitLoop
        EndIf
    WEnd
    GUIDelete($G2)
    GUISwitch($G1)
EndFunc   ;==>_ChildGui


Func _Exit()
    Exit
EndFunc   ;==>_Exit

Then run this script

$list = WinList("Same Title")
If Int($list[0][0]) <> 1 Then
    Exit MsgBox(0, 0, "More than 1 window already open")
EndIf
$Windows = $list[0][0]
$OriginalWindow = $list[1][1]

While 3
    Sleep(10)
    $list = WinList("Same Title")
    $Windows = $list[0][0]
    If Int($Windows) > 1 Then
        For $i = 1 To Int($Windows)
            If $list[$i][1] <> $OriginalWindow Then
                MsgBox(0, 0, "Popup window detected, cloding...")
                WinClose(HWnd($list[$i][1]))
            EndIf
        Next

    EndIf
WEnd

When you hit the button in compiled script it will make child window of same name, be detected by non compiles script and closed.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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...