Sign in to follow this  
Followers 0
dakishman

Radio help

2 posts in this topic

I can not figure out a way to save two radio group values too two different variables with one click of the button. For EX:

;======

;Group 1

;======

$Running = GUICtrlCreateGroup("Do While Running", 152, 8, 137, 137)

$A1 = GUICtrlCreateRadio("A1 ", 160, 24, 49, 17)

GUICtrlSetState(-1, $GUI_CHECKED)

$H1 = GUICtrlCreateRadio("H1 ", 160, 40, 81, 17)

$n1 = GUICtrlCreateRadio("N1!", 160, 56, 65, 17)

$C1 = GUICtrlCreateGroup("C1 (Sec)", 152, 96, 137, 49)

;======

;Group 2

;======

$Running = GUICtrlCreateGroup("Do While not Running", 152, 8, 137, 137)

$A2 = GUICtrlCreateRadio("A2 ", 160, 24, 49, 17)

GUICtrlSetState(-1, $GUI_CHECKED)

$H2 = GUICtrlCreateRadio("H2 ", 160, 40, 81, 17)

$n2 = GUICtrlCreateRadio("N2!", 160, 56, 65, 17)

$C2 = GUICtrlCreateGroup("C2 (Sec)", 152, 96, 137, 49)

;========

;My Button

;========

$OK = GUICtrlCreateButton("OK", 8, 152, 75, 25, 0)

========

;My Loop

========

Do

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Cancel

ExitLoop

Case $msg = $OK

(Save Group1 radio value to $Value1)

(Save Group2 radio value to $Value2)

Exit

EndSelect

Until $exit = 1


I love AutoIT! It doesn't talk back, it doesn't complain that ur on the computer, it loves to be ran over and over and over... but IT STILL DOESN'T DO THE DISHES... Gatta keep da pimp hand strong...

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I can not figure out a way to save two radio group values too two different variables with one click of the button. For EX:

;======

;Group 1

;======

$Running = GUICtrlCreateGroup("Do While Running", 152, 8, 137, 137)

$A1 = GUICtrlCreateRadio("A1 ", 160, 24, 49, 17)

GUICtrlSetState(-1, $GUI_CHECKED)

$H1 = GUICtrlCreateRadio("H1 ", 160, 40, 81, 17)

$n1 = GUICtrlCreateRadio("N1!", 160, 56, 65, 17)

$C1 = GUICtrlCreateGroup("C1 (Sec)", 152, 96, 137, 49)

;======

;Group 2

;======

$Running = GUICtrlCreateGroup("Do While not Running", 152, 8, 137, 137)

$A2 = GUICtrlCreateRadio("A2 ", 160, 24, 49, 17)

GUICtrlSetState(-1, $GUI_CHECKED)

$H2 = GUICtrlCreateRadio("H2 ", 160, 40, 81, 17)

$n2 = GUICtrlCreateRadio("N2!", 160, 56, 65, 17)

$C2 = GUICtrlCreateGroup("C2 (Sec)", 152, 96, 137, 49)

;========

;My Button

;========

$OK = GUICtrlCreateButton("OK", 8, 152, 75, 25, 0)

========

;My Loop

========

Do

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Cancel

ExitLoop

Case $msg = $OK

(Save Group1 radio value to $Value1)

(Save Group2 radio value to $Value2)

Exit

EndSelect

Until $exit = 1

Here's one way. (Only done for group 1)

#include <guiconstants.au3>
$gui = GUICreate("button to save groups", 600, 300)
GUISetState()
;======
;Group 1
;======
$Running = GUICtrlCreateGroup("Do While Running", 152, 8, 137, 137)
$A1 = GUICtrlCreateRadio("A1 ", 160, 24, 49, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$H1 = GUICtrlCreateRadio("H1 ", 160, 40, 81, 17)
$n1 = GUICtrlCreateRadio("N1!", 160, 56, 65, 17)
$C1 = GUICtrlCreateGroup("C1 (Sec)", 152, 96, 137, 49)
$a = -1;not set with values
;======
;Group 2
;======
$Running = GUICtrlCreateGroup("Do While not Running", 352, 8, 137, 137)
$A2 = GUICtrlCreateRadio("A2 ", 360, 24, 49, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$H2 = GUICtrlCreateRadio("H2 ", 360, 40, 81, 17)
$n2 = GUICtrlCreateRadio("N2!", 360, 56, 65, 17)
$C2 = GUICtrlCreateGroup("C2 (Sec)", 352, 96, 137, 49)

;========
;My Button
;========
$OK = GUICtrlCreateButton("READ", 8, 152, 75, 25, 0)
$BK = GUICtrlCreateButton("Set Back", 108, 152, 125, 25, 0)
;========
;My Loop
;========
Do
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ConsoleWrite("111" & @CRLF)
            ExitLoop
        ;Case $msg = $Cancel
        ;   ExitLoop
        Case $msg = $OK
            ConsoleWrite("222" & @CRLF)
            $a = 0
            If GUICtrlRead($A1) = $GUI_CHECKED Then $a += 1
            If GUICtrlRead($H1) = $GUI_CHECKED Then $a += 2
            If GUICtrlRead($n1) = $GUI_CHECKED Then $a += 4
        ;(Save Group1 radio value to $Value1)
        ;(Save Group2 radio value to $Value2)
        ;Exit
        Case $msg = $BK
            If $a > -1 Then
                If $a = 1 Then GUICtrlSetState($A1, $GUI_CHECKED)
                If $a = 2 Then GUICtrlSetState($H1, $GUI_CHECKED)
                If $a = 4 Then GUICtrlSetState($n1, $GUI_CHECKED)
            EndIf
            
    EndSelect
Until 0

The code could be shorter if you used arrays for your controls

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
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
Sign in to follow this  
Followers 0