Jump to content

Recommended Posts

Posted

I would like to start out by saying AutoIT rocks. I have just recently started to use the scripting piece of it and I am thrilled at what I can do with it. The problem I am having at the moment is that I want to read an ini file and populate two different combo boxes with that information. I would like to be able to then automatically check a series of check boxes that I already have developed. I am attaching the code I have been playing with to see if I can read an ini file. I get a dialog box but no information in the combo box. Guidance please and thank you in advance for the help.

Thank you,

Jcampbell

CODE:

dim $myini

dim $mylist

$myini=IniReadSection("C:\Documents and Settings\jcampbell\My Documents\Scripts\myini.ini","Combo1")

#include <GUIConstants.au3>

#include <WindowsConstants.au3>

#include <ComboConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 633, 454, 193, 115)

$mylist = GUICtrlCreateCombo($myini, 144, 64, 145, 25)

GUISetState(@SW_SHOW)

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

While 1

$msg = GUIGetMsg()

$myini=IniReadSection("C:\Documents and Settings\jcampbell\My Documents\Scripts\myini.ini","Combo1")

Switch $msg

Case $GUI_EVENT_CLOSE

ExitLoop

Case $mylist

$read = GUICtrlRead($mylist)

EndSwitch

WEnd

INI file

[combo1]

1=Accounting

2=Sales

3=Training

[combo2]

1=manager

2=teacher

3=cunsultant

Posted

Are these parts of your script becuase when i tried to run the script with them in it i got an error message...

INI file
[combo1]
1=Accounting
2=Sales
3=Training

[combo2]
1=manager
2=teacher
3=cunsultant

"FREEDOM is not FREE""Its a good thing war is so terrible, or we grow too fond of it" -Robert E. Lee[quote]Firestrom: global $warming = False[/quote]My scripts:Desktop Cleaner---->Total Downloads:167;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;111111;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;"a wise man once said why use your skills when we have technology"

Posted

you need to setup the combo box with entries first from the ini like

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 193, 115)
$mylist = GUICtrlCreateCombo("", 144, 64, 145, 25)

$btn_test = GUICtrlCreateButton("btn_test", 308, 52, 75, 25, 0)

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

; read first 
$myini=IniReadSection("myini.ini","Combo1")
;return 2 dim array !! 

If @error Then 
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else

 For $i = 1 To $myini[0][0]
        MsgBox(4096, "", "Key: " & $myini[$i][0] & @CRLF & "Value: " & $myini[$i][1])

        GUICtrlSetData($mylist,$myini[$i][1]) ; add other item snd set a new default
        
    Next
endif




;; -- main msg loop 
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $btn_test 
            $t = GUICtrlRead($mylist)
            MsgBox(0, "test", $t);

EndSwitch
WEnd
Posted

Are these parts of your script becuase when i tried to run the script with them in it i got an error message...

INI file
[combo1]
1=Accounting
2=Sales
3=Training

[combo2]
1=manager
2=teacher
3=cunsultant
TNT,

The section you are refering to is the items in my ini file

Posted

you need to setup the combo box with entries first from the ini like

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 193, 115)
$mylist = GUICtrlCreateCombo("", 144, 64, 145, 25)

$btn_test = GUICtrlCreateButton("btn_test", 308, 52, 75, 25, 0)

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

; read first 
$myini=IniReadSection("myini.ini","Combo1")
;return 2 dim array !! 

If @error Then 
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else

 For $i = 1 To $myini[0][0]
        MsgBox(4096, "", "Key: " & $myini[$i][0] & @CRLF & "Value: " & $myini[$i][1])

        GUICtrlSetData($mylist,$myini[$i][1]) ; add other item snd set a new default
        
    Next
endif




;; -- main msg loop 
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $btn_test 
            $t = GUICtrlRead($mylist)
            MsgBox(0, "test", $t);

EndSwitch
WEnd
nobbe the code you sent me works great for controlling one combo box. I added a second set of if statements to control my second combo box and that worked good. I am stuck again and I am sorry if this is newby question but I am learning as I go. What I want to be able to do is if combobox1 = John and combobox2 = Smith I want to select a set of checkboxes that I have in a larger set of code in order to set an install process in motion. Below is the section I am working on. I would like the read of the combo boxes and the selection of the checkboxes to be automatic but I am beginning to think I need a control button to start the read process. Your guidance would be greatly appreciated.

CODE:

dim $m

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 633, 454, 193, 115)

$Combo1 = GUICtrlCreateCombo("", 184, 72, 145, 25)

$Combo2 = GUICtrlCreateCombo("", 184, 104, 145, 25)

GUISetState(@SW_SHOW)

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

;Read ini file

$myini=IniReadSection("myini.ini","Global Practice")

$myinilist=IniReadsection("myini.ini","Av")

If @error Then

MsgBox(4096, "", "Error occurred, probably no INI file.")

Else

For $i = 1 To $myini[0][0]

GUICtrlSetData($Combo1,$myini[$i][1]) ; add other item snd set a new default

Next

endif

If @error Then

MsgBox(4096, "", "Error occurred, probably no INI file.")

Else

For $i = 1 To $myinilist[0][0]

GUICtrlSetData($Combo2,$myinilist[$i][1]) ; add other item snd set a new default

Next

endif

$read = GUICtrlRead ($combo1)

$read2 = GUICtrlRead ($combo2)

If $read = "Aviation" and $read2 = "MEP" then $m=$read2

MsgBox (0,"Function", $m)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

Posted

hi

there are 3 parts in a script

1) the gui setup part (can be done with koda)

2) the initialising part ( read ini file and add items to combo and controls)

3) the logic part - if buttons are pressed , evaluates controls, reads conbo etc

(3) is done here in the main loop

;; -- main msg loop

While 1

$msg = GUIGetMsg()

Switch $msg

Case $GUI_EVENT_CLOSE

ExitLoop

Case $btn_test

$t = GUICtrlRead($mylist)

MsgBox(0, "test", $t);

EndSwitch

WEnd

4) for further help you may want to write down the gui layout with koda and script some logic to it

e.g "press button (start) " -> read combo1 entry, see if checkbox 1 is checked , then do action (1), if checkbox2 is checked then do action (2)

.. and so on..

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
×
×
  • Create New...