Jump to content

Recommended Posts

Posted

Hi guys,

I am new to coding with AutoIT and have figured out most things on my own, but now I cannot find any help or tutorials to continue with my project..

I created a GUI with KODA so that you can understand what I am about to do

so when I click on Test1 - checkbox "first" and "second" should appear

and when I click on Test2 - checkbox "third" and "fourth" should appear

but checkbox "first" and "second" should not be hidden instead "third" and "fourth" should be at the top

here is the GUI to show u what i mean...

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region
$Form1 = GUICreate("Form1", 584, 311, -1, -1)
GUISetFont(20, 400, 0, "Calibri")
$Bot = GUICtrlCreateTab(0, 0, 581, 310, BitOR($TCS_SCROLLOPPOSITE,$TCS_FIXEDWIDTH))
GUICtrlSetFont(-1, 12, 400, 0, "Calibri")
$Collecting = GUICtrlCreateTabItem("TEST")
GUICtrlSetState(-1,$GUI_SHOW)
$List1 = GUICtrlCreateList("", 5, 35, 280, 251, $LBS_NOTIFY)
GUICtrlSetData(-1, "Test1|Test2")
GUICtrlSetFont(-1, 6, 400, 0, "MS Sans Serif")
$Group2 = GUICtrlCreateGroup("", 296, 30, 280, 256)
GUICtrlSetFont(-1, 6, 400, 0, "MS Sans Serif")
$Checkbox5 = GUICtrlCreateCheckbox("first", 304, 40, 169, 20)
GUICtrlSetFont(-1, 5, 400, 0, "MS Sans Serif")
$Checkbox6 = GUICtrlCreateCheckbox("second", 304, 60, 177, 20)
GUICtrlSetFont(-1, 5, 400, 0, "MS Sans Serif")
$Checkbox7 = GUICtrlCreateCheckbox("third", 304, 80, 177, 20)
GUICtrlSetFont(-1, 5, 400, 0, "MS Sans Serif")
$Checkbox7 = GUICtrlCreateCheckbox("fourth", 304, 100, 177, 20)
GUICtrlSetFont(-1, 5, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

 

Posted

You'll have to hide the controls when they are created and then when the list is clicked, get the list item text and act accordingly. You also have two controls with the same id ($Checkbox7). Something like this, assuming the checkbox controls are always at the same top position.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region
$Form1 = GUICreate("Form1", 584, 311, -1, -1)
GUISetFont(20, 400, 0, "Calibri")
$Bot = GUICtrlCreateTab(0, 0, 581, 310, BitOR($TCS_SCROLLOPPOSITE, $TCS_FIXEDWIDTH))
GUICtrlSetFont(-1, 12, 400, 0, "Calibri")
$Collecting = GUICtrlCreateTabItem("TEST")
GUICtrlSetState(-1, $GUI_SHOW)
$List1 = GUICtrlCreateList("", 5, 35, 280, 251, $LBS_NOTIFY)
GUICtrlSetData(-1, "Test1|Test2")
GUICtrlSetFont(-1, 6, 400, 0, "MS Sans Serif")
$Group2 = GUICtrlCreateGroup("", 296, 30, 280, 256)
GUICtrlSetFont(-1, 6, 400, 0, "MS Sans Serif")
$Checkbox5 = GUICtrlCreateCheckbox("first", 304, 40, 169, 20)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 5, 400, 0, "MS Sans Serif")
$Checkbox6 = GUICtrlCreateCheckbox("second", 304, 60, 177, 20)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 5, 400, 0, "MS Sans Serif")
$Checkbox7 = GUICtrlCreateCheckbox("third", 304, 80, 177, 20)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 5, 400, 0, "MS Sans Serif")
$Checkbox8 = GUICtrlCreateCheckbox("fourth", 304, 100, 177, 20)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 5, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $List1
            Switch GUICtrlRead($List1)
                Case 'Test1'
                    GUICtrlSetState($Checkbox5, $GUI_SHOW)
                    GUICtrlSetState($Checkbox6, $GUI_SHOW)
                Case 'Test2'
                    GUICtrlSetPos($Checkbox5, 304, 80)
                    GUICtrlSetPos($Checkbox6, 304, 100)
                    GUICtrlSetPos($Checkbox7, 304, 40)
                    GUICtrlSetPos($Checkbox8, 304, 60)
                    GUICtrlSetState($Checkbox7, $GUI_SHOW)
                    GUICtrlSetState($Checkbox8, $GUI_SHOW)
            EndSwitch
    EndSwitch
WEnd

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...