Sign in to follow this  
Followers 0
Christopher Blue

GUICtrlRead isn't fetching the text of my radio buttons

9 posts in this topic

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?

Share this post


Link to post
Share on other sites



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.

[center]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.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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?

????

http://www.autoitscript.com/forum/index.ph...c=41689&hl=

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

#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

[center]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.[/center]

Share this post


Link to post
Share on other sites

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

In 'advanced' mode the return value contains additional data of the control (see below).

...

Type

Checkbox, Radio

Additional Value

The text of the control.

Share this post


Link to post
Share on other sites

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.

[center]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.[/center]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.


[center]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.[/center]

Share this post


Link to post
Share on other sites

OK, I will try out those suggestions, thanks!

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