Jump to content

GUI closes but WinExists = 1?


Go to solution Solved by Andreik,

Recommended Posts

Could this be any simpler? What's the proper way of checking the open/closed state of a window since this doesn't work.

 

#include <MsgBoxConstants.au3>  ; For $MB_TOPMOST

$hGUI = GUICreate("My Simple GUI", 300, 200)
GUISetState(@SW_SHOW)
MsgBox($MB_TOPMOST, "IsGUIOpen", IsGUIOpen())

WinClose($hGUI)

MsgBox($MB_TOPMOST, "IsGUIOpen", IsGUIOpen())

Func IsGUIOpen()
    If WinExists($hGUI) Then
        Return 1 ; GUI is open
    Else
        Return 0 ; GUI is closed
    EndIf
EndFunc

 

Edited by NassauSky
Link to comment
Share on other sites

  • Solution
#include <MsgBoxConstants.au3>  ; For $MB_TOPMOST

$hGUI = GUICreate("My Simple GUI", 300, 200)
GUISetState(@SW_SHOW)
MsgBox($MB_TOPMOST, "IsGUIOpen", IsGUIOpen())

GUIDelete($hGUI)

MsgBox($MB_TOPMOST, "IsGUIOpen", IsGUIOpen())

Func IsGUIOpen()
    Return WinExists("My Simple GUI")
EndFunc

Don't mix GUI functions with Win functions. Basically if you deal with a window created by GUICreate() then you destroy it with GUIDelete(). If you deal with windows that are not created by your script you can use Win functions.

 

PS: IsGUIOpen() can be even simpler, as you can see above

Edited by Andreik

When the words fail... music speaks.

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