Jump to content

gui_hide and show thing


Recommended Posts

  • Moderators

scriptomator,

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
GUISetState()
; This is the normal state - look in the Help file for WinGetState to see the various states
ConsoleWrite(WinGetState($hGUI) & @CRLF)

Sleep(2000)
; Now hide it
GUISetState(@SW_HIDE)

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

Sleep(2000)
; 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
            Exit
    EndSwitch
WEnd

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

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

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

 

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