scriptomator Posted July 4, 2010 Share Posted July 4, 2010 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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 4, 2010 Moderators Share Posted July 4, 2010 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 WEndIf 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. 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! I hope all this helps - sorry if it ended up a bit long! M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now