Jump to content

ComboBox1 to ComboBox2


kkelley
 Share

Go to solution Solved by JLogan3o13,

Recommended Posts

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.

Link to comment
Share on other sites

  • Moderators

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!

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators
  • Solution

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!

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