Administrators Jon Posted June 16, 2004 Administrators Posted June 16, 2004 One of the things that will have broken old scripts under new builds is the way the control ref you get when you create a control is numbered. Any script that assumes that first control created will be 1 will fail. While we are messing around with the code you should not assume the value of the first control so make sure to save the reference. What you _can_ and will be able to assume for the future is that whatever the value of the first control you get subsequent controls will be numbered sequentially allowing you to do math. E.g. If you create three controls: $first = GuiSetControl(...) $second = GuiSetControl(...) $third = GuiSetControl(...) If - for example - $first was the value 100 then $second = 101 $third = 102 This allows you do do things like this (notice how the script keeps track of the radio button clicked with minimum code). The bit to look for is the bit that does math with the control ref/msg in the Select statement. #include <GUIconstants.au3> Opt("GUICoordMode", 1) Opt("GUINotifyMode", 1) GUICreate("Radio Box Demo", 400,280) ; Create the controls $button_1 = GUISetControl("button", "B&utton 1", 30, 20, 120, 40) $group_1 = GUISetControl("group", "Group 1", 30, 90, 165, 160) $radio_1 = GUISetControl("radio", "Radio &0", 50, 120, 70, 20) $radio_2 = GUISetControl("radio", "Radio &1", 50, 150, 60, 20) $radio_3 = GUISetControl("radio", "Radio &2", 50, 180, 60, 20) ; Init our vars that we will use to keep track of GUI events $radioval1 = 0 ; We will assume 0 = first radio button selected, 2 = last button $radioval2 = 2 GuiShow() ; In this message loop we use variables to keep track of changes to the radios, another ; way would be to use GuiRead() at the end to read in the state of each control While 1 $msg = GuiMsg() Select Case $msg = -3 Exit Case $msg = $button_1 MsgBox(0, "Default button clicked", "Radio " & $radioval1 ) Case $msg = $radio_1 OR $msg = $radio_2 OR $msg = $radio_3 $radioval1 = $msg - $radio_1 EndSelect WEnd Hope that helps. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
GEOSoft Posted June 17, 2004 Posted June 17, 2004 Thanks Jon, but I already knew why they were broken. That does not help much with a GUI that uses over 70 controls ( many created from within arrays) and all of them are called several times during various functions. This is now becoming a job that will require a total rewrite to work (only 1200 lines) with the new versions of the GUI so I'm staying with the old one George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
pekster Posted June 17, 2004 Posted June 17, 2004 Or you could just keep a copy of the proper files so that you could compile programs that operate under the old assumptions. For all your newer code, you could use the return value of the set control functions, but for code that you don't want to re-write, just run it though the old compiler when you need to modify it. [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.
GEOSoft Posted June 30, 2004 Posted June 30, 2004 Or you could just keep a copy of the proper files so that you could compile programs that operate under the old assumptions. For all your newer code, you could use the return value of the set control functions, but for code that you don't want to re-write, just run it though the old compiler when you need to modify it.The problem here is that it can be a bit difficult to declare a string name for a checkbox when you are doing something like using a splitstring of 12 or 15 items. $CbxName = StringSplit ('Label1,Label2,Label3,Etc,Etc,Etc,Ad,Infinitum,,,,,,,,'',') $Gw = 200 $Gh = 80 + ($CbxName[0]*20) GUICreate ('TEST',$Gw,$Gh) For $I = 1 To $CbxName[0] GUISetControl ('Button,$CbxName[$i],15,40+($I*20),$Gw-30,20) Next GUISetControl ('Button','Do It',($Gw/2)-30,$Gh-30,60,20) WhileGUIMsg() > 0 Function calls here depend on what boxes are checked. Wend I also have another page which uses nine buttons and nine labels all created in a single For/Next loop. Another reason for using the control number is it is easliy checked with a simple message box at While/Wend loop. MsgBox (0,'TEST',GUIRead()) George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Administrators Jon Posted June 30, 2004 Author Administrators Posted June 30, 2004 The problem here is that it can be a bit difficult to declare a string name for a checkbox when you are doing something like using a splitstring of 12 or 15 items. $CbxName = StringSplit ('Label1,Label2,Label3,Etc,Etc,Etc,Ad,Infinitum,,,,,,,,'',') $Gw = 200 $Gh = 80 + ($CbxName[0]*20) GUICreate ('TEST',$Gw,$Gh) For $I = 1 To $CbxName[0] GUISetControl ('Button,$CbxName[$i],15,40+($I*20),$Gw-30,20) Next GUISetControl ('Button','Do It',($Gw/2)-30,$Gh-30,60,20) WhileGUIMsg() > 0 Function calls here depend on what boxes are checked. Wend I also have another page which uses nine buttons and nine labels all created in a single For/Next loop. Another reason for using the control number is it is easliy checked with a simple message box at While/Wend loop. MsgBox (0,'TEST',GUIRead())$CbxName = StringSplit ('Label1,Label2,Label3,Etc,Etc,Etc,Ad,Infinitum,,,,,,,,'',') Dim $CbxID[$CbxName[0] + 1] $Gw = 200 $Gh = 80 + ($CbxName[0]*20) GUICreate ('TEST',$Gw,$Gh) For $I = 1 To $CbxName[0] $CbxID[$i] = GUISetControl ('Button,$CbxName[$i],15,40+($I*20),$Gw-30,20) Next GUISetControl ('Button','Do It',($Gw/2)-30,$Gh-30,60,20) While 1 $msg = GUIMsg() Select Case $msg = -3 ExitLoop Case $msg = $CbxID[1] ; First control clicked ... EndSelect Wend Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
GEOSoft Posted August 5, 2004 Posted August 5, 2004 $CbxName = StringSplit ('Label1,Label2,Label3,Etc,Etc,Etc,Ad,Infinitum,,,,,,,,'',') Dim $CbxID[$CbxName[0] + 1] $Gw = 200 $Gh = 80 + ($CbxName[0]*20) GUICreate ('TEST',$Gw,$Gh) For $I = 1 To $CbxName[0] $CbxID[$i] = GUISetControl ('Button,$CbxName[$i],15,40+($I*20),$Gw-30,20) Next GUISetControl ('Button','Do It',($Gw/2)-30,$Gh-30,60,20) While 1 $msg = GUIMsg() Select Case $msg = -3 ExitLoop Case $msg = $CbxID[1] ; First control clicked ... EndSelect Wend <{POST_SNAPBACK}>Thanks Jon, I figured you would come up with something like this and I will try it the next time. For the time being I just named the ones that were not created by an array variable and then used $Sys_Text+1, $Sys_Text+2 etc. to ead those that were created by arrays. I may have to totally rewrite the entire program one of these days and I will do it with your method. Right now I have just been too busy to think about it. This particular app is the same one that is still giving me the problem in XP but I have decided to totally drop XP and I'm nor writing for it any more. It's a developers tool and if someone wants to take it over for XP then I'll turn over the code. I'll be on and of the forum for the next day or so and then I'm out of town for a month or so again. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
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