Jump to content

GUICtrlRead isn't fetching the text of my radio buttons


Recommended Posts

  • Moderators

I am trying to use GUICtrlRead to fetch the text of my radio buttons, labeled "radio 1" "radio 2" "radio 3" and so on, but it is returning an empty string! How can I fix this?

GUICtrlRead get's the state of a radio button, not the text of it.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

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

$radio1 = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
$radio2 = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
GUICtrlSetState ($radio2, $GUI_CHECKED)

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 = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED
            MsgBox(64, 'Info:', 'You clicked the Radio 1 and it is Checked.' & @CRLF & 'Text = ' &  _GUICtrlGetText($GUI, $radio1))
        Case $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED
            MsgBox(64, 'Info:', 'You clicked on Radio 2 and it is Checked.' & @CRLF & 'Text = ' &  _GUICtrlGetText($GUI, $radio2))
    EndSelect
Wend

Func _GUICtrlGetText($hGUI, $nCTRLID)
    Return ControlGetText($hGUI, '', $nCTRLID)
EndFunc
If this is what you are trying to do.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

I am trying to use the advanced mode of GUICtrlRead. From the AutoIt Help file:

I didn't know there was an advanced mode :whistle::)

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

$radio1 = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
$radio2 = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
GUICtrlSetState ($radio2, $GUI_CHECKED)

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 = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED
            MsgBox(64, 'Info:', 'You clicked the Radio 1 and it is Checked.' & @CRLF & 'Text = ' &  GUICtrlRead($radio1, 1))
        Case $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED
            MsgBox(64, 'Info:', 'You clicked on Radio 2 and it is Checked.' & @CRLF & 'Text = ' &  GUICtrlRead($radio2, 1))
    EndSelect
Wend
Still gives me the correct result.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

I get function call parsing errors when I try to use _GUICtrlGetText. What version of AutoIt is it in?

3.2.2.0

It's simply ControlGetText() shouldn't be getting a function call error unless you only called the function with one parameter.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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