Jump to content

How to set and read a radiobox when the radio was generated by Program.


 Share

Recommended Posts

Can someone help put me on the right track here.. I have never tried to read a control when it was generated by program... so I am not sure how to read and tic and untic the boxes since I am not sure what the name of the control is..

The only thing I need help with at this point is making the 4 buttons talk to the program generated radio boxes...

In other words I just need to know how to make the buttons here talk to the radio boxes..

$readone = GUICtrlCreateButton("Read One", 50, 160, 100, 25)

$tickone = GUICtrlCreateButton("Tick One", 200, 160, 100, 25)

$untickall = GUICtrlCreateButton("Untick All", 50, 200, 100, 25)

$tickall = GUICtrlCreateButton("Tick All", 200, 200, 100, 25)

Pay no attention to my Case messages.. as none of them work.. that is just things I was experimenting with in an attempt to talk to the radios but none work... of course.

Thanks for any help.

#include <IE.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <DATE.au3>
Dim $LblVer, $t, $test
Dim $start, $mgs, $nrsecs, $i, $tot, $oIE
Dim $mytime, $nrwins, $num, $secdelay, $file, $dog, $i, $sync, $cat
Dim $cnt, $mynum, $test, $cver, $hver, $uver, $xver, $mode, $test, $cap, $rpt
Global $nrtorun, $mysound
HotKeySet("{ESC}", "Terminate")
Func Terminate()
Exit
EndFunc
$Form1_1 = GUICreate("Hud Alert Control Version " & $cver, 378, 303, 750, 0)
$LblVer = GUICtrlCreateLabel('UVER - ' & $uver & '   CVER - ' & $cver & '   HVER - ' & $hver & '  XVER - ' & $xver, 65, 285, 300, 17)
$Tab1 = GUICtrlCreateTab(16, 32, 337, 249)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)

GUICtrlCreateTabItem("Window Control")
For $i = 1 to 4
$t = $t + 60
$radio=GUICtrlCreateCheckbox($i, $t,  60,  50,  20)
Next
$t=0
For $i = 5 to 8
$t = $t + 60
$radio=GUICtrlCreateCheckbox($i, $t,  80,  50,  20)
Next
$t=0
For $i = 9 to 12
$t = $t + 60
$radio=GUICtrlCreateCheckbox($i, $t,  100,  50,  20)
Next
$t=0
For $i = 13 to 16
$t = $t + 60
$radio=GUICtrlCreateCheckbox($i, $t,  120,  50,  20)
Next
;                                              L    T    W   H
$readone   = GUICtrlCreateButton("Read One",   50, 160, 100, 25)
$tickone   = GUICtrlCreateButton("Tick One",  200, 160, 100, 25)
$untickall = GUICtrlCreateButton("Untick All", 50, 200, 100, 25)
$tickall   = GUICtrlCreateButton("Tick All",  200, 200, 100, 25)

$StartUp = GUICtrlCreateTabItem("StartUp")
$Group1 = GUICtrlCreateGroup("Start Up", 32, 72, 297, 185)
$Label1 = GUICtrlCreateLabel("Number of Instances to Run", 72, 136, 137, 17)
$nrtorun = GUICtrlCreateInput("8", 224, 136, 57, 21)
$Label2 = GUICtrlCreateLabel("Number of seconds apart ", 72, 176, 126, 17)
$nrsecs = GUICtrlCreateInput("30", 224, 176, 57, 21)
GUISetState(@SW_SHOW)

GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop

        Case $msg = $readone
   ; Read 1
   $i = 1
   $test = GUICtrlRead($radio & $i)
   $Msgbox(0,"","Radio 1 = " & $test)

        Case $msg = $tickone
   ; Tick 1
   $i = 1
   GUICtrlSetState ( $radio & $i, $GUI_CHECKED)

        Case $msg = $tickall
   ; Check all
   For $i = 1 to 16
   GUICtrlSetState ($radio & $i, $GUI_CHECKED)
   Next

        Case $msg = $untickall
   ; Uncheck All
   For $1 = 1 to 16
   GUICtrlSetState( $radio & $i, $GUI_UNCHECKED)
   Next
 
EndSelect
  
   
WEnd
Link to comment
Share on other sites

Try this, ask if you have any questions.

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Run_Tidy=y
#Tidy_Parameters=/sf
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ie.au3>
#include <buttonconstants.au3>
#include <editconstants.au3>
#include <guiconstantsex.au3>
#include <staticconstants.au3>
#include <tabconstants.au3>
#include <windowsconstants.au3>
#include <date.au3>

Global $LblVer, $t, $test, $radio[17]
Global $start, $mgs, $nrsecs, $i, $tot, $oIE
Global $mytime, $nrwins, $num, $secdelay, $file, $dog, $i, $sync, $cat
Global $cnt, $mynum, $test, $cver, $hver, $uver, $xver, $mode, $test, $cap, $rpt
Global $nrtorun, $mysound
HotKeySet("{ESC}", "Terminate")
$Form1_1 = GUICreate("Hud Alert Control Version " & $cver, 378, 303, 750, 0)
$LblVer = GUICtrlCreateLabel('UVER - ' & $uver & '   CVER - ' & $cver & '   HVER - ' & $hver & '  XVER - ' & $xver, 65, 285, 300, 17)
$Tab1 = GUICtrlCreateTab(16, 32, 337, 249)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)

GUICtrlCreateTabItem("Window Control")
For $i = 1 To 4
    $t = $t + 60
    $radio[$i] = GUICtrlCreateCheckbox($i, $t, 60, 50, 20)
Next
$t = 0
For $i = 5 To 8
    $t = $t + 60
    $radio[$i] = GUICtrlCreateCheckbox($i, $t, 80, 50, 20)
Next
$t = 0
For $i = 9 To 12
    $t = $t + 60
    $radio[$i] = GUICtrlCreateCheckbox($i, $t, 100, 50, 20)
Next
$t = 0
For $i = 13 To 16
    $t = $t + 60
    $radio[$i] = GUICtrlCreateCheckbox($i, $t, 120, 50, 20)
Next
;                                              L    T    W   H
$readone = GUICtrlCreateButton("Read One", 50, 160, 100, 25)
$tickone = GUICtrlCreateButton("Tick One", 200, 160, 100, 25)
$untickall = GUICtrlCreateButton("Untick All", 50, 200, 100, 25)
$tickall = GUICtrlCreateButton("Tick All", 200, 200, 100, 25)

$StartUp = GUICtrlCreateTabItem("StartUp")
$Group1 = GUICtrlCreateGroup("Start Up", 32, 72, 297, 185)
$Label1 = GUICtrlCreateLabel("Number of Instances to Run", 72, 136, 137, 17)
$nrtorun = GUICtrlCreateInput("8", 224, 136, 57, 21)
$Label2 = GUICtrlCreateLabel("Number of seconds apart ", 72, 176, 126, 17)
$nrsecs = GUICtrlCreateInput("30", 224, 176, 57, 21)
GUISetState(@SW_SHOW)

GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop

        Case $msg = $readone
            ; Read 1
            $i = 1
            $test = GUICtrlRead($radio[$i])
            MsgBox(0, "", "Radio 1 = " & $test)

        Case $msg = $tickone
            ; Tick 1
            $i = 1
            GUICtrlSetState($radio[$i], $GUI_CHECKED)

        Case $msg = $tickall
            ; Check all
            For $i = 1 To 16
                GUICtrlSetState($radio[$i], $GUI_CHECKED)
            Next

        Case $msg = $untickall
            ; Uncheck All
            For $i = 1 To 16
                GUICtrlSetState($radio[$i], $GUI_UNCHECKED)
            Next

    EndSelect


WEnd
Func Terminate()
    Exit
EndFunc   ;==>Terminate
Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

That works great. Thank you very much..

Case $msg = $untickall

; Uncheck All

For $1 = 1 To 16

GUICtrlSetState($radio[$i], $GUI_UNCHECKED)

Next

Just noticed that you accidentally put a 1 for the i in the For loop... I do that all the time so it was not a problem for me but if you still have eidting capability you might want to fix it for those who may use it in the future as they try to learn also. $1 vice $i... Thanks again it was very helpful...

Edited by tommytx
Link to comment
Share on other sites

Corrected the above script, thanks for the heads up. I hate when I make simple mistakes like that.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

That simple correction might save several folks a lot of head scratching in the future.. as you just never know how many trainees.. in the future will load that script and try to learn from it.... Here is a funny... I swear it worked correctly the way it was when I loaded it the first time and I never even noticed a problem until I moved it above the other tab.. and then it failed... and I said "self" what the hell difference could it make it I simply switch tab positions.. but then realized the error and all was well..... As you can see I have been a busy little beaver just building one program after the other... and would never have been able to do it without all the help from all you Master Programmers...

Edited by tommytx
Link to comment
Share on other sites

I noticed you changed my Dim to Global.... the Dim's seem to work ok... but someone suggested the other day that I stop using the Dim and use Global... I have not noticed any failures using the Dim... is that basically a NO NO when using AutoIT... as the Dim seems to work... just curious... I think I need to start using Local a lot more as I am ending up with just to darn many Global... its just not something I am used to but starting to get the hang of using Local.....

Edited by tommytx
Link to comment
Share on other sites

Dim can cause issues in scripts when using it in a function. Global and Local should be the standard statements to use for declaring variables. Only use Local if it's being used in a function.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...