ShaneHale Posted November 14, 2007 Posted November 14, 2007 Hi, Been a while since I needed to ask for help, guess that means I am getting this stuff a little better. Anyways, I am trying to read from a ini file that is going to have dynamically changing information for the section names - actually written form another script on client computers in a student lab into netlogon. It has information such as @computername, @username and other varible information I am collecting in order to restrict and monitor computer usage. So I can read the information from the ini and I can have it looped through an array and spit out into information on buttons in a gui - BUT - that is where I get stumped. I can not get my select cases to dicern from one button to the next because my variable is just called $button. What I think I need is a way to go through the loop and load arrayed info from the ini into variables as i am doing but each time rename the $button variable to another name like some way to say $button after it is loaded can be combined with $a_number to become $button1 and $button2 and so on BUT the information I entered INTO $button on this time around the loop woud not be changed. So then later in the gui while loop I could call these new variables and use information that was loaded on each specific pass of the for loop by calling $button1 or $button2 and so on. I bet someone knows what I mean and I bet some one has already done something simular. In fact it could be that I am thinking too hard and it is easy to do what I want. Although i do suppose Easy is a relative term. At any rate here is what I have and it works all the way up to the point where I want to add events to the button clicks: CODE#include <GUIConstants.au3> $var0 = IniReadSectionNames("enabled.ini") $Form1 = GUICreate("Lab Monitor Console", 310, 563, 220, 70) $n = 0 For $i = 1 To $var0[0] MsgBox(0,"",$var0[$i]) $var1 = IniRead("enabled.ini", $var0[$i], "USER", "NotFound") $var2 = IniRead("enabled.ini", $var0[$i], "COMPUTER", "NotFound") $var3 = IniRead("enabled.ini", $var0[$i], "MONITOR", "NotFound") $var4 = IniRead("enabled.ini", $var0[$i], "RECORD", "NotFound") $var5 = IniRead("enabled.ini", $var0[$i], "ALERT", "NotFound") $var0[$i] = GUICtrlCreateButton($var1 & " " & $var2 & " " & $var3 & " " & $var4 & " " & $var5, 0, $n, 309, 20, 0) $n = $n + 20 Next GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Any help or suggestions would be appreciated......
Valuater Posted November 14, 2007 Posted November 14, 2007 Maybe... #include <GUIConstants.au3> $var0 = IniReadSectionNames("enabled.ini") $Form1 = GUICreate("Lab Monitor Console", 310, 563, 220, 70) $n = 0 Dim $Button[UBound($var0) ] For $i = 1 To $var0[0] ;MsgBox(0, "", $var0[$i]) $var1 = IniRead("enabled.ini", $var0[$i], "USER", "NotFound") $var2 = IniRead("enabled.ini", $var0[$i], "COMPUTER", "NotFound") $var3 = IniRead("enabled.ini", $var0[$i], "MONITOR", "NotFound") $var4 = IniRead("enabled.ini", $var0[$i], "RECORD", "NotFound") $var5 = IniRead("enabled.ini", $var0[$i], "ALERT", "NotFound") $Button[$i] = GUICtrlCreateButton($var1 & " " & $var2 & " " & $var3 & " " & $var4 & " " & $var5, 0, $n, 309, 20, 0) $n = $n + 20 Next GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch For $x = 1 To UBound($Button) - 1 If $nMsg = $Button[$x] Then MsgBox(0x0, "You pressed ", GUICtrlRead($Button[$x]) & " ", 5) Next WEnd 8)
ShaneHale Posted November 14, 2007 Author Posted November 14, 2007 Maybe...Definately! Thank you. I was soooo close. I have some kind of mental block with 'ubound' just not clear on how or when to use it. i think I learned something wrong at some point i you knw what I mean. That's very possibly true since i am my teacher....... Ha!Thanks again so much..... Shane Hale Tuacahn center for the Arts
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now