Jump to content
Sign in to follow this  

gui_hide and show thing

Recommended Posts


aye, i have a problem

If $box = $GUI_HIDE  Then GUICtrlSetState($box, $GUI_SHOW)

with this code i want "$box" to show if it is hidden

i think i had the right idea when i tried to do this but it won't work for me

Share this post

Link to post
Share on other sites


You need to use WinGetState to find the current state of a window. But be careful, because as you can see from the Help file, you get a combination of styles as a return - so you have to use BitAND to extract the one you want. :

This shows it working - you would just need the <<<<<<<<<<<<<<<<<<< line: ;)

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

; Create the GUI
; This is the normal state - look in the Help file for WinGetState to see the various states
ConsoleWrite(WinGetState($hGUI) & @CRLF)

; Now hide it

; And look at the states again
ConsoleWrite(WinGetState($hGUI) & @CRLF)

; Check if the GUI is visible and show if not - this is the line you need <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
If BitAnd(WinGetState($hGUI), 2) <> 2 Then GUISetState(@SW_SHOW) ; 2 = visible

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE

If you are not too clear on BitAND (and its relative BitOR), take a look here where I explained it to another member.

You can skip this next bit if you want - but you might find it interesting. :blink:

Why, I hear you ask, WinGetState and not GUIGetState - which does not exist? Well, getting the info from a GUI is independent of who created it, so why have 2 identical commands? So, you ask perplexedly, why have both GUISetState AND WinSetState? I cannot really explain - you need a Dev for that as I am fairly sure that it is an internal AutoIt matter - but basically the GUI* commands work on GUIs the current script has created while Win* commands work on any window. So GUISetState appears to be a shorthand version of WinSetState - you need the latter if you try and change external windows (although it also works on your own GUIs once they exist).

A example of these differences is a compiled script I wrote where the actual window is hidden when running and I wanted this window to come back into view if the user attemopted to start another instance. After a lot of experimentation I found that I had to create the intial window with GUISetState (GUI in same script) - then hide it with WinSetState (GUI in same script) so that the new instance could use WinSetState (GUI in another script)to show it again.

Complex at times this coding in AutoIt, isn't it! :nuke:

I hope all this helps - sorry if it ended up a bit long! :P


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
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
Sign in to follow this