Jump to content

If Radio Button Then


Recommended Posts

This should be simple but i cant quite get it to work

I have 4 gui buttons and im trying to make it idetifie witch one is clicked and if one is checked and then they click the start button start fallowing more of my script

so this is my current code

Case $msg = $Select2 And BitAND(GUICtrlRead($SelectYoutube), $GUI_CHECKED) = $GUI_CHECKED               Case $btn_start
               MsgBox(4096, "22", "2 was selected", 10)

please help i dont know what im doing wrong.

Link to comment
Share on other sites

This is my sample is it what you are looking for?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("Form1", 317, 144, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 72, 104, 145, 25, $WS_GROUP)
GUICtrlSetState($Button1,$GUI_DISABLE)
$Radio1 = GUICtrlCreateRadio("Radio1", 168, 24, 113, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Radio1
            If BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) Then
                GUICtrlSetState($Button1,$gui_enable)
            else
                GUICtrlSetState($Button1,$GUI_DISABLE)
            EndIf
        Case $Button1
            MsgBox(0,"Clicked!","I`m Working Now...",3)
            GUICtrlSetState($Radio1,$gui_UNCHECKED)
            GUICtrlSetState($Button1,$GUI_DISABLE)


    EndSwitch
WEnd
[size="5"] [/size]
Link to comment
Share on other sites

  • Moderators

Medic873,

Perhaps this might help: :mellow:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

GUIStartGroup()
$hRadio_1 = GUICtrlCreateRadio(" Radio 1", 10, 10, 100, 20)
$hRadio_2 = GUICtrlCreateRadio(" Radio 2", 10, 30, 100, 20)
$hRadio_3 = GUICtrlCreateRadio(" Radio 3", 10, 50, 100, 20)
$hRadio_4 = GUICtrlCreateRadio(" Radio 4", 10, 70, 100, 20)

$hButton_Start_1 = GUICtrlCreateButton("Start 1", 10, 100, 80, 30)

$hBut_1 = GUICtrlCreateCheckbox("Button 1", 400, 10, 50, 20, $BS_PUSHLIKE)
$hBut_2 = GUICtrlCreateCheckbox("Button 2", 400, 30, 50, 20, $BS_PUSHLIKE)
$hBut_3 = GUICtrlCreateCheckbox("Button 3", 400, 50, 50, 20, $BS_PUSHLIKE)
$hBut_4 = GUICtrlCreateCheckbox("Button 4", 400, 70, 50, 20, $BS_PUSHLIKE)

$hButton_Start_2 = GUICtrlCreateButton("Start 1", 400, 100, 80, 30)

GUISetState()

While 1

    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        ; This is for the radios on the left
        Case $hButton_Start_1
            For $i = $hRadio_1 To $hRadio_4
                If GUICtrlRead($i) = 1 Then
                    MsgBox(0, "", "Radio " & $i - $hRadio_1 + 1 & " checked")
                    ExitLoop
                EndIf
            Next
        ; This is for the buttons on the right
        Case $hButton_Start_2
            For $i = $hBut_1 To $hBut_4
                If GUICtrlRead($i) = 1 Then
                    MsgBox(0, "", "Button " & $i - $hBut_1 + 1 & " checked")
                    ExitLoop
                EndIf
            Next
        Case $hBut_1 To $hBut_4
            For $i = $hBut_1 To $hBut_4
                GUICtrlSetState($i, $GUI_UNCHECKED)
            Next
            GUICtrlSetState($iMsg, $GUI_CHECKED)


    EndSwitch

WEnd

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...