Jump to content
Sign in to follow this  
Guest zitto

How to know which radio button is selected ?

Recommended Posts

Guest zitto

Hello all,

I'm new in AutoIt scripting, and I have a little question.

I'd like to know wich function/keyword permits (in the code below) to know which radio button is selected ? :lmao:

I think it's quite easy, but I just can't find :">

#include <GUIConstants.au3>
GUICreate("My GUI radio") ; will create a dialog box that when displayed is centered

GuiCtrlCreateGroup("", 10, 10, 150, 150); open group
$radio1 = GUICtrlCreateRadio ("Radio 1", 20, 20, 100, 20)
$radio2 = GUICtrlCreateRadio ("Radio 2", 20, 40, 100, 20)
$radio3 = GUICtrlCreateRadio ("Radio 3", 20, 60, 100, 20)
GUICtrlSetState ($radio1,$GUI_CHECKED)
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

GUICtrlCreateButton("Which radio is selected ?",20,200,200,20)

GUISetState ()    ; will display an  dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
        
; Write here the script that when click on button, a msgbox is displayed with a message
; telling which radio is selected.


    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
GUICreate("My GUI radio"); will create a dialog box that when displayed is centered

GuiCtrlCreateGroup("", 10, 10, 150, 150); open group
$radio1 = GUICtrlCreateRadio ("Radio 1", 20, 20, 100, 20)
$radio2 = GUICtrlCreateRadio ("Radio 2", 20, 40, 100, 20)
$radio3 = GUICtrlCreateRadio ("Radio 3", 20, 60, 100, 20)
GUICtrlSetState ($radio1,$GUI_CHECKED)
GUICtrlCreateGroup ("",-99,-99,1,1);close group

$Button_1 = GUICtrlCreateButton("Which radio is selected ?",20,200,200,20)

GUISetState ()   ; will display an  dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()

      Select
         Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
            
         Case $msg = $Button_1
            Dim $SelRadBtn
            If GUICtrlRead($radio1) = $GUI_CHECKED Then
               $SelRadBtn = "radio1"
            ElseIf GUICtrlRead($radio2) = $GUI_CHECKED Then
               $SelRadBtn = "radio2"
            ElseIf GUICtrlRead($radio3) = $GUI_CHECKED Then
               $SelRadBtn = "radio3"
            EndIf
            If $SelRadBtn <> "" Then
               MsgBox(64, "Test", "Selected radio button: " & $SelRadBtn)
            EndIf
    EndSelect
Wend

Share this post


Link to post
Share on other sites
Guest zitto

Tanks a lot !! I was on the way to find. $GUI_CHECKED was missing !!!

Thx Slim ! :lmao:

Edited by zitto

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...