kkelley Posted September 2, 2014 Posted September 2, 2014 I am currently having a problem with creating a more dynamic style of GUI. I have two items in a ComboBox if selected I want to turn the other ComboBox off, or display *Not Needed*. I only know how to put this logic into the button click that I have. Is there some way to do a $GUI_HIDE or something? thanks for your help.
Moderators JLogan3o13 Posted September 2, 2014 Moderators Posted September 2, 2014 Yes, you can use GuiCtrlSetState to $GUI_HIDE if an item is selected. If you would post the code you have, so we're not reinventing the wheel for you, we can assist. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
kkelley Posted September 2, 2014 Author Posted September 2, 2014 (edited) The code is over 2000 lines but I will include a short version you can look at and maybe we can get somewhere. expandcollapse popup#include "Login.au3" ;===============================================================================================================================================================================================================================; ;Creating GUI $hGUI = GUICreate("UAT", 450, 270, 350, 150) $browserCombo = GUICtrlCreateCombo("", 72, 58, 313, 25) $serverCombo = GUICtrlCreateCombo("", 72, 118, 313, 25) $userCombo = GUICtrlCreateCombo("", 72, 178, 313, 25) $userLbl = GUICtrlCreateLabel("Select User Name", 72, 148, 250, 23) GUICtrlSetFont(-1, 12, 800, 0, "Rockwell") $browserLbl = GUICtrlCreateLabel("Select Browser", 72, 28, 250, 23) GUICtrlSetFont(-1, 12, 800, 0, "Rockwell") $serverLbl = GUICtrlCreateLabel("Select Server", 72, 88, 250, 23) GUICtrlSetFont(-1, 12, 800, 0, "Rockwell") $startBtn = GUICtrlCreateButton("Start", 72, 220, 75, 25) GUICtrlSetFont(-1, 10, 800, 0, "Rockwell") $exitBtn = GUICtrlCreateButton("Exit", 312, 220, 75, 25) GUICtrlSetFont(-1, 10, 800, 0, "Rockwell") GUICtrlSetData($browserCombo, "Internet Explorer|Google Chrome|Mozilla Firefox", "Internet Explorer") GUICtrlSetData($serverCombo, "", " ") GUICtrlSetData($userCombo, "", " ") GUISetState(@SW_SHOW) ;===============================================================================================================================================================================================================================; StartGUI() Func StartGUI() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $exitBtn Exit Case $startBtn $browser = GUICtrlRead($browserCombo) $server = GUICtrlRead($serverCombo) $user = GUICtrlRead($userCombo) ExitLoop EndSwitch WEnd GUIDelete($hGUI) ;---------------------------UAT-------------------------------------; If $browser = "Internet Explorer" And $server = "UAT" Then _IEuat() ElseIf $browser = "Google Chrome" And $server = "UAT" Then _Chromeuat() ElseIf $browser = "Mozilla Firefox" And $server = "UAT" Then _FFuat() EndIf expandcollapse popup#include <GUIConstantsEx.au3> #include <Constants.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <GuiEdit.au3> #include <MsgBoxConstants.au3> ;---------------------------------------------------; ;Opens UAT in internet explorer Func _IEuat() ShellExecute($IElocation) Sleep(5000) Send("!d") Sleep(1000) Send($UATweb) Send("{Enter}") Sleep(1000) Send($userName) Send("{Tab}") Sleep(1000) Send($password) Sleep(1000) Send("{Enter}") Sleep(3000) MouseClick("Left", 960, 405) Sleep(5000) EndFunc ;Opens UAT in mozilla firefox Func _FFuat() ShellExecute($FFlocation) Sleep(5000) Send("!d") Sleep(1000) Send($UATweb) Send("{Enter}") Sleep(1000) Send($userName) Sleep(1000) Send("{Tab}") Sleep(1000) Send($password) Send("{Enter}") Sleep(3000) MouseClick("Left", 954, 381) Sleep(5000) EndFunc ;Opens UAT in google chrome Func _Chromeuat() ShellExecute($Chromelocation) Sleep(5000) Send("!d") Sleep(1000) Send($UATweb) Send("{Enter}") Sleep(1000) Send($userName) Sleep(1000) Send("{Tab}") Sleep(1000) Send($password) Send("{Enter}") Sleep(3000) MouseClick("Left", 960, 405) Sleep(5000) EndFunc Edited September 2, 2014 by kkelley
kkelley Posted September 2, 2014 Author Posted September 2, 2014 (edited) So for reference $serverCombo and $userCombo do have items in there, removed for privacy Edited September 2, 2014 by kkelley
Moderators Solution JLogan3o13 Posted September 2, 2014 Moderators Solution Posted September 2, 2014 There are a couple of ways you could go about it. Something like this using OnEvent would be one: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> AutoItSetOption("GUIOnEventMode", 1) GUICreate("Test", 300, 300) $cmbo1 = GUICtrlCreateCombo("Please select an item", 10, 10, 130, 30) GUICtrlSetData(-1, "Do nothing|Check|Test|Test2", "Please select an item") GUICtrlSetOnEvent(-1, "_disable") $cmbo2 = GUICtrlCreateCombo("Please select an item", 160, 10, 130, 30) GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd GUIDelete() Func _disable() Switch GUICtrlRead($cmbo1) Case "Do nothing" GUICtrlSetData($cmbo2, "Do nothing selected") Case "Check" GUICtrlSetState($cmbo2, $GUI_HIDE) Sleep(500) GUICtrlSetState($cmbo2, $GUI_SHOW) Case "Test" GUICtrlSetData($cmbo2, "Not needed") EndSwitch EndFunc I have another script floating around that shows a cleaner method, if I can find it I will post. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
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