Jump to content

Need to close a window without a Title - (Moved)


JohnTWI
 Share

Recommended Posts

I have one widow open and then another info window is displayed ( unwanted and no Title assigned). 

I need to close only the info window and continue processing.

Both have the small class #32770

   If WinExists ("[CLASS:#32770]","") Then   ;;;;;;;;;;;;;;;;;;;;;;;;;;   Close the Open Dialog Window
       Sleep(1000)
       ControlFocus("[CLASS:#32770]", "", "Button1")
       Sleep(1000)
       ControlSend("[CLASS:#32770]", "", "Button1", "{ENTER}")

       Sleep(2000)

   EndIf

WindowInfo.PNG

Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hey John,

You didn't ask a question. :)

Anyway, I believe WinExists would return on the first instance and I don't know if that would be the window you want. I would try something like this, if there is an issue, others would correct it.

Maybe, get a list of Windows for the class with WinList function, and check for Title element.

test()

Func test()

    Local $aWindowList = WinList("[CLASS:#32770]")

    if $aWindowList = "" then exit ; No window found

    For $i = 1 to Ubound($aWindowList)-1
        If $aWindowList[$i][0] = "" Then
            WinClose($aWindowList[$i][1])
            ExitLoop
        EndIf
    Next
    
EndFunc

 

Edited by GokAy
Added check for array
Link to comment
Share on other sites

Thank you for the feed back. I ran the following below, and there are a lot of windows with no title. 

Is there a way to get a handle on a newly opened window and close only it?

 

 

Example()

Func Example()
    ; Retrieve a list of window handles.
    Local $aList = WinList()
    MsgBox($MB_SYSTEMMODAL, "stop", "winlist title " &  $aList )
    ; Loop through the array displaying only visable windows with a title.
    For $i = 1 To $aList[0][0]
        If $aList[$i][0] <> "THRIVE PRODUCTION SERVER - Thrive" Then  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   changed to = from <> before the And
            MsgBox($MB_SYSTEMMODAL, "", "Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1])
            
        EndIf
    Next
EndFunc   ;==>Example

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