JohnOne Posted August 20, 2009 Share Posted August 20, 2009 (edited) Hi I have been reading the forums But cannot seem to find my answer Its probably to noob, so please forgive me I am brand new not only to AutoIt but to programming My first project is to collect data from input boxes and radio buttong whithin a gui, and writing results to an ini file. My problems lie in the radio data collection, I am doing something totally wrong Can someone help me out with the code ? it would be much appreciated expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 509, 281, 192, 124) $Group1 = GUICtrlCreateGroup("Group1", 48, 24, 417, 73) $Radio1 = GUICtrlCreateRadio("Radio1", 80, 56, 113, 17) $Radio2 = GUICtrlCreateRadio("Radio2", 200, 56, 113, 17) $Radio3 = GUICtrlCreateRadio("Radio3", 336, 56, 113, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Group2", 48, 120, 417, 73) $Radio4 = GUICtrlCreateRadio("Radio4", 80, 152, 113, 17) $Radio5 = GUICtrlCreateRadio("Radio5", 200, 152, 113, 17) $Radio6 = GUICtrlCreateRadio("Radio6", 336, 152, 113, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("Cancel", 120, 224, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Next", 272, 224, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit Case $Button2 $sIni = @DesktopDir & "\radioinitest.ini" $nData1 = "group_1 = " & GUICtrlRead($Group1) $nData2 = "group_2 = " & GUICtrlRead($Group2) IniWriteSection($sIni, "Result1", $nData1) IniWriteSection($sIni, "Result2", $nData2) Exit EndSwitch WEnd I'm wanting the name of the radio button in any group to be written to the ini file, but at the moment it is writing the group name. ie. heres the result from the script [Result1] group_1 = Group1 [Result2] group_2 = Group2 I am after [Result1] group_1 = Radio1 [Result2] group_2 = radio4 Or whatever button was selected Any help EDIT: Also, I cant figure out how to create a space between the sections Edited August 20, 2009 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Manjish Posted August 20, 2009 Share Posted August 20, 2009 Here you go.. >_< expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $r1="Radio 1",$r2="Radio 2",$r3="Radio 3",$r4="Radio 4",$r5="Radio 5",$r6="Radio 6" $Form1 = GUICreate("Form1", 509, 281, 192, 124) $Group1 = GUICtrlCreateGroup("Group1", 48, 24, 417, 73) $Radio1 = GUICtrlCreateRadio($r1, 80, 56, 113, 17) $Radio2 = GUICtrlCreateRadio($r2, 200, 56, 113, 17) $Radio3 = GUICtrlCreateRadio($r3, 336, 56, 113, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Group2", 48, 120, 417, 73) $Radio4 = GUICtrlCreateRadio($r4, 80, 152, 113, 17) $Radio5 = GUICtrlCreateRadio($r5, 200, 152, 113, 17) $Radio6 = GUICtrlCreateRadio($r6, 336, 152, 113, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("Cancel", 120, 224, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Next", 272, 224, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit Case $Button2 $sIni = @DesktopDir & "\radioinitest.ini" Select Case GUICtrlRead($radio1)=1 $var1=$r1 Case GUICtrlRead($radio2)=1 $var1=$r2 Case GUICtrlRead($radio3)=1 $var1=$r3 EndSelect Select Case GUICtrlRead($radio4)=1 $var2=$r4 Case GUICtrlRead($radio5)=1 $var2=$r5 Case GUICtrlRead($radio6)=1 $var2=$r6 EndSelect $nData1 = "group_1 = " & $var1 $nData2 = "group_2 = " & $var2 IniWriteSection($sIni, "Result1", $nData1) IniWriteSection($sIni, "Result2", $nData2) Exit EndSwitch WEnd [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
99ojo Posted August 20, 2009 Share Posted August 20, 2009 (edited) Hi I have been reading the forums But cannot seem to find my answer Its probably to noob, so please forgive me I am brand new not only to AutoIt but to programming My first project is to collect data from input boxes and radio buttong whithin a gui, and writing results to an ini file. My problems lie in the radio data collection, I am doing something totally wrong Can someone help me out with the code ? it would be much appreciated expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 509, 281, 192, 124) $Group1 = GUICtrlCreateGroup("Group1", 48, 24, 417, 73) $Radio1 = GUICtrlCreateRadio("Radio1", 80, 56, 113, 17) $Radio2 = GUICtrlCreateRadio("Radio2", 200, 56, 113, 17) $Radio3 = GUICtrlCreateRadio("Radio3", 336, 56, 113, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Group2", 48, 120, 417, 73) $Radio4 = GUICtrlCreateRadio("Radio4", 80, 152, 113, 17) $Radio5 = GUICtrlCreateRadio("Radio5", 200, 152, 113, 17) $Radio6 = GUICtrlCreateRadio("Radio6", 336, 152, 113, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("Cancel", 120, 224, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Next", 272, 224, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit Case $Button2 $sIni = @DesktopDir & "\radioinitest.ini" $nData1 = "group_1 = " & GUICtrlRead($Group1) $nData2 = "group_2 = " & GUICtrlRead($Group2) IniWriteSection($sIni, "Result1", $nData1) IniWriteSection($sIni, "Result2", $nData2) Exit EndSwitch WEnd I'm wanting the name of the radio button in any group to be written to the ini file, but at the moment it is writing the group name. ie. heres the result from the script I am after [Result1] group_1 = Radio1 [Result2] group_2 = radio4 Or whatever button was selected Any help EDIT: Also, I cant figure out how to create a space between the sections Hi, change $nData1 = "group_1 = " & GUICtrlRead($Group1) $nData2 = "group_2 = " & GUICtrlRead($Group2) IniWriteSection($sIni, "Result1", $nData1) IniWriteSection($sIni, "Result2", $nData2) to If GUICtrlRead ($Radio1) = $GUI_CHECKED Then $nData1 = "group_1 = Radio1" ElseIf GUICtrlRead ($Radio2) = $GUI_CHECKED Then $nData1 = "group_1 = Radio2" ElseIf GUICtrlRead ($Radio3) = $GUI_CHECKED Then $nData1 = "group_1 = Radio3" EndIf If GUICtrlRead ($Radio4) = $GUI_CHECKED Then $nData1 = "group_2 = Radio4" ElseIf GUICtrlRead ($Radio5) = $GUI_CHECKED Then $nData1 = "group_2 = Radio5" ElseIf GUICtrlRead ($Radio6) = $GUI_CHECKED Then $nData1 = "group_2 = Radio6" EndIf IniWriteSection($sIni, "Result1", $nData1) IniWriteSection($sIni, "Result2", $nData2) So, if you want to check radiobutton, you have to check it instead of checking the group. There is a more elegant way to check the buttons with a For loop, i think Melba did it. But this should also work. For the space i would try a IniWriteSection($sIni, "", @CRLF) after the write for "Result1". ;-)) Stefan [edit]Manjish beats me with another solution.......... Edited August 20, 2009 by 99ojo Link to comment Share on other sites More sharing options...
JohnOne Posted August 20, 2009 Author Share Posted August 20, 2009 Much appreciated guys I see I had'nt even made any variables for the radio buttons, I really am a nooby. Thank you very much AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
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