Jump to content
Sign in to follow this  
kkelley

ComboBox1 to ComboBox2

Recommended Posts

kkelley

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.

Share this post


Link to post
Share on other sites
JLogan3o13

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
kkelley

The code is over 2000 lines but I will include a short version you can look at and maybe we can get somewhere.

#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
#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 by kkelley

Share this post


Link to post
Share on other sites
kkelley

So for reference $serverCombo and $userCombo do have items in there, removed for privacy

Edited by kkelley

Share this post


Link to post
Share on other sites
JLogan3o13

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.


√-1 2^3 ∑ π, and it was delicious!

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  

×