Jump to content
Sign in to follow this  
pedge

Setting form controls visible depending on event

Recommended Posts

pedge

Hi all,

I have used AutoIT on and off for the last 5 years but never got down to do any heavy scripting so forgive me if I'm being a tad naive.

I'm currently working out a way to create a script where by using an input form will allow a user to adjust some settings in the Registry. These settings are to allow a database dependent application to swap from using SQL Server to Oracle. Rather than having to manually hack the reg I want to get the script to automate the hack.

I'm getting the gist of RegRead and RegWrite to include some variables however, the thing that's bothering me is the form and how to get the users input.

My idea is to provide an input form where the user will be presented either by 2 radio buttons or a combo box with 2 options, SQL Server & Oracle. Two tab controls (to include several input fields) will also be available which will be disabled/hidden until the user selects either SQL Server or Oracle from either the radio buttons or combo. Then dependent on the selected DB the tab will be enabled/visible and the input fields available to the user to apply the servername/db name etc into the input fields.

All the entered data will then be written to the registry once the user has clicked OK.

I've included the draft code for the form below. If anybody has any pointers it would be a great help.

TIA

Pete

CODE
#include <ButtonConstants.au3>

#include <ComboConstants.au3>

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <TabConstants.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=c:\users\pprieto\documents\install\scripting\autoit\samples\reg\form1.kxf

$Form1_1 = GUICreate("Form1", 471, 376, 193, 125)

$Radio1 = GUICtrlCreateRadio("SQL Server", 80, 48, 113, 17)

$Radio2 = GUICtrlCreateRadio("Oracle", 80, 72, 113, 17)

$Group1 = GUICtrlCreateGroup("Database Type", 48, 24, 185, 81)

GUICtrlCreateGroup("", -99, -99, 1, 1)

$Tab1 = GUICtrlCreateTab(48, 136, 289, 193)

GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)

$TabSheet1 = GUICtrlCreateTabItem("SQL Server")

$Input1 = GUICtrlCreateInput("Input1", 128, 184, 121, 21)

$Label1 = GUICtrlCreateLabel("Server", 72, 184, 35, 17)

$Input4 = GUICtrlCreateInput("Input4", 128, 216, 121, 21)

$Label4 = GUICtrlCreateLabel("Database", 72, 216, 50, 17)

$Input6 = GUICtrlCreateInput("Input6", 128, 248, 121, 21)

$Label6 = GUICtrlCreateLabel("User", 72, 248, 26, 17)

$Input7 = GUICtrlCreateInput("Input7", 128, 280, 121, 21)

$Label7 = GUICtrlCreateLabel("Password", 72, 280, 50, 17)

$TabSheet2 = GUICtrlCreateTabItem("Oracle")

$Input2 = GUICtrlCreateInput("Input2", 128, 184, 121, 21)

$Label2 = GUICtrlCreateLabel("Server", 72, 184, 35, 17)

$Input3 = GUICtrlCreateInput("Input3", 128, 216, 121, 21)

$Label3 = GUICtrlCreateLabel("SID", 72, 216, 22, 17)

$Input5 = GUICtrlCreateInput("Input5", 128, 248, 121, 21)

$Label5 = GUICtrlCreateLabel("User", 72, 248, 26, 17)

$Input8 = GUICtrlCreateInput("Input8", 128, 280, 121, 21)

$Label8 = GUICtrlCreateLabel("Password", 72, 280, 50, 17)

GUICtrlCreateTabItem("")

$Combo1 = GUICtrlCreateCombo("Combo1", 304, 48, 145, 25)

GUICtrlSetData(-1, "|SQL Server|Oracle")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Radio1

EndSwitch

WEnd

Share this post


Link to post
Share on other sites
NBJ

Something that may get you started:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
Dim $label[10]
Dim $Input[10]
#Region ### START Koda GUI section ### Form=c:\users\pprieto\documents\install\scripting\autoit\samples\reg\form1.kxf
$Form1_1 = GUICreate("Form1", 471, 376, 193, 125)
$Radio1 = GUICtrlCreateRadio("SQL Server", 80, 48, 113, 17)
$Radio2 = GUICtrlCreateRadio("Oracle", 80, 72, 113, 17)
$Group1 = GUICtrlCreateGroup("Database Type", 48, 24, 185, 81)
GUICtrlCreateGroup("", -99, -99, 1, 1)
;$Tab1 = GUICtrlCreateTab(48, 136, 289, 193)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
;$TabSheet1 = GUICtrlCreateTabItem("SQL Server")
$Input[1] = GUICtrlCreateInput("Input1", 128, 184, 121, 21)
$Label[1] = GUICtrlCreateLabel("Server", 72, 184, 35, 17)
$Input[2] = GUICtrlCreateInput("Input2", 128, 216, 121, 21)
$Label[2] = GUICtrlCreateLabel("Database", 72, 216, 50, 17)
$Input[3] = GUICtrlCreateInput("Input3", 128, 248, 121, 21)
$Label[3] = GUICtrlCreateLabel("User", 72, 248, 26, 17)
$Input[4] = GUICtrlCreateInput("Input4", 128, 280, 121, 21)
$Label[4] = GUICtrlCreateLabel("Password", 72, 280, 50, 17)
;$TabSheet2 = GUICtrlCreateTabItem("Oracle")
$Input[5] = GUICtrlCreateInput("Input5", 128, 184, 121, 21)
$Label[5] = GUICtrlCreateLabel("Server", 72, 184, 35, 17)
$Input[6] = GUICtrlCreateInput("Input6", 128, 216, 121, 21)
$Label[6] = GUICtrlCreateLabel("SID", 72, 216, 22, 17)
$Input[7] = GUICtrlCreateInput("Input7", 128, 248, 121, 21)
$Label[7] = GUICtrlCreateLabel("User", 72, 248, 26, 17)
$Input[8] = GUICtrlCreateInput("Input8", 128, 280, 121, 21)
$Label[8] = GUICtrlCreateLabel("Password", 72, 280, 50, 17)
GUICtrlCreateTabItem("")
$Combo1 = GUICtrlCreateCombo("Combo1", 304, 48, 145, 25)
GUICtrlSetData(-1, "|SQL Server|Oracle")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
            For $x=1 to 8
            GUICtrlSetState($Input[$x], $GUI_Hide)
            GUICtrlSetState($Label[$x], $GUI_Hide)
            Next

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

        Case $Radio1
            For $x=1 to 4
            GUICtrlSetState($Input[$x], $GUI_Hide)
            GUICtrlSetState($Label[$x], $GUI_Hide)
            Next
            For $x=4 to 8
            GUICtrlSetState($Input[$x], $GUI_Show)
            GUICtrlSetState($Label[$x], $GUI_Show)
            Next
        Case $Radio2
            For $x=1 to 4
            GUICtrlSetState($Input[$x], $GUI_Show)
            GUICtrlSetState($Label[$x], $GUI_Show)
            Next
            For $x=4 to 8
            GUICtrlSetState($Input[$x], $GUI_Hide)
            GUICtrlSetState($Label[$x], $GUI_Hide)
            Next
    EndSwitch
WEnd

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  

×