Jump to content

delete a gui with command


Recommended Posts

Im trying to delete a gui with a command, my problem is that the delete doesnt recognize the gui created

 

If $vFlagBlack = True Then
        $gui = GuiCreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP);
        GuiSetState(@SW_SHOW);
        WinSetOnTop($gui, "", 1);
        GuiSetBkColor("0x000000");
        $vFlagBlack = False
    Else
        GUIDelete($gui)
        $vFlagBlack = True
    EndIf

 

Link to comment
Share on other sites

#include <GUIConstants.au3>

Global $hMain = GUICreate("Main", 120, 45)
Global $btnExample = GUICtrlCreateButton("Create GUI", 10, 10, 100, 25)
Global $hExample = Null

GUISetState(@SW_SHOW, $hMain)

While (True)
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            Exit 0
        Case $btnExample
            ; The $hExample GUI Exists
            If ($hExample) Then
                GUIDelete($hExample)
                $hExample = Null
            ; The $hExample GUI does not exist
            Else
                $hExample = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
                GUISetState(@SW_SHOW, $hExample)
            EndIf
    EndSwitch
WEnd

Try this.

Edited by InunoTaishou
Link to comment
Share on other sites

You need to declare $gui before if

works for me

Global $vFlagBlack = True, $gui

Func a()
    If $vFlagBlack = True Then
        $gui = GuiCreate("", @DesktopWidth, @DesktopHeight, 0, 0);
        GuiSetState(@SW_SHOW);
        WinSetOnTop($gui, "", 1);
        GuiSetBkColor("0x000000");
        $vFlagBlack = False
    Else
        GUIDelete($gui)
        $vFlagBlack = True
    EndIf
EndFunc

a()
Sleep(2000)
a()

 

Sorry for my english :)

Link to comment
Share on other sites

31 minutes ago, InunoTaishou said:
#include <GUIConstants.au3>

Global $hMain = GUICreate("Main", 120, 45)
Global $btnExample = GUICtrlCreateButton("Create GUI", 10, 10, 100, 25)
Global $hExample = Null

GUISetState(@SW_SHOW, $hMain)

While (True)
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            Exit 0
        Case $btnExample
            ; The $hExample GUI Exists
            If ($hExample) Then
                GUIDelete($hExample)
                $hExample = Null
            ; The $hExample GUI does not exist
            Else
                $hExample = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
                GUISetState(@SW_SHOW, $hExample)
            EndIf
    EndSwitch
WEnd

Try this.

thanks it worked :)

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