Sign in to follow this  
Followers 0
Rigest

Newbie question: How to read radio's?

13 posts in this topic

Okay, so I really don't have a clue how to read radio's. I've tried several options but none of them seem to be working. I've tried it like this:

If GUICtrlGetState($Radioarr) = $GUI_CHECKED then send ("Bet $Bet1 $Date1")

and

If $Radiolreg = 1 then send ("Bet Z9"

I know this probably is a stupid question, but I really can't figure it out myself. Below is the script I'm working on. Thanks in advanche for the help!

HotKeySet("^a", "Afspraak")

While 1
Sleep(100)
WEnd

Func Afspraak()

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Betaalafspraak", 320, 540, 155, 44)
$Radioarr = GUICtrlCreateRadio("Eenmalige betaling", 16, 15, 113, 17)
$Radiolreg = GUICtrlCreateRadio("Regeling", 132, 15, 113, 17)
$Combogeslacht = GUICtrlCreateCombo("Dhr.", 16, 54, 145, 25)
GUICtrlSetData(-1, "Mevr.")
$Combodbofp = GUICtrlCreateCombo("Debiteur betaalt", 16, 80, 145, 25)
GUICtrlSetData(-1, "Partner betaalt")
$Label1 = GUICtrlCreateLabel("Te betalen bedrag", 15, 115, 100, 100)
$Bet1 = GUICtrlCreateInput("", 110, 110, 40, 21)
$Label2 = GUICtrlCreateLabel("Datum betaling", 15, 140, 100, 100)
$Date1 = GUICtrlCreateDate("2010/06/03 23:13:8", 93, 135, 160, 21)
$Group1 = GUICtrlCreateGroup("Regeling", 8, 172, 305, 230)
$Label3 = GUICtrlCreateLabel("2e te betalen bedrag", 18, 190, 100, 100)
$Label4 = GUICtrlCreateLabel("2e betaaldatum", 18, 215, 100, 100)
$Input2 = GUICtrlCreateInput("", 120, 184, 40, 21)
$Date2 = GUICtrlCreateDate("2010/06/03 23:13:8", 95, 212, 170, 21)
$Label5 = GUICtrlCreateLabel("3e te betalen bedrag", 18, 245, 100, 100)
$Label6 = GUICtrlCreateLabel("3e betaaldatum", 18, 270, 100, 100)
$Input3 = GUICtrlCreateInput("", 120, 238, 40, 21)
$Date3 = GUICtrlCreateDate("2010/06/03 23:13:8", 95, 265, 170, 21)
$Label7 = GUICtrlCreateLabel("4e te betalen bedrag", 18, 300, 100, 100)
$Label8 = GUICtrlCreateLabel("4e betaaldatum", 18, 325, 100, 100)
$Input4 = GUICtrlCreateInput("", 120, 295, 40, 21)
$Date4 = GUICtrlCreateDate("2010/06/03 23:13:8", 95, 320, 170, 21)
$Label9 = GUICtrlCreateLabel("5e te betalen bedrag", 18, 350, 100, 100)
$Label10 = GUICtrlCreateLabel("5e betaaldatum", 18, 375, 100, 100)
$Input5 = GUICtrlCreateInput("", 120, 346, 40, 21)
$Date5 = GUICtrlCreateDate("2010/06/03 23:13:8", 95, 370, 170, 21)
$Comboopvolging = GUICtrlCreateCombo("Automatisch incasso in het vervolg ok", 16, 410, 200, 25)
GUICtrlSetData(-1, "Debiteur controlleert de automatisch incasso")
GUICtrlSetData(-1, "In het vervolg via periodieke overboeking")
GUICtrlSetData(-1, "Betaling in het vervolg op tijd")
$Label25 = GUICtrlCreateLabel("Review", 18, 440, 100, 100)
$review = GUICtrlCreateInput("000", 60, 437, 40, 21)


GUICtrlCreateGroup("", -99, -99, 1, 1) ; wtf is dit?

$Button1 = GUICtrlCreateButton("Afspraak bevestigen", 40, 500, 115, 30, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Annuleren", 170, 500, 115, 30, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
; Hier eindigt de GUI en begint de rest
; dus als je ok klik, gebeurd het volgende

Do
$msg = GUIGetMsg()

Until $msg = $Button2 Or $msg = $Button1



;afspraak wordt genoteerd in 4
Select
Case $msg = $Button1
    GUIDelete() 
    
 
$review = GUICtrlRead($review)
$bet1 = GUICtrlRead ($bet1)
$Date1 = GUICtrlRead($date1)

    
Send ("{F7}4{ENTER}")
If $review = "000" then send ("{TAB}")
If $review > "000" then send ("M")
If $review = "000" then send ("INFO")
If $review > "000" AND GUICtrlGetState($Radioarr) = $GUI_CHECKED then send ("ARR {TAB}")
If $review > "000" AND $Radiolreg = "1" then send ("LREG {TAB}")
Send ($review)
If $Radiolreg = 1 then send ("Bet Z9")
If GUICtrlGetState($Radioarr) = $GUI_CHECKED then send ("Bet $Bet1 $Date1")
Send ("{ENTER}{ENTER}")

;opvolging wordt genoteerd in 4
Send ("4 {TAB} INFO {TAB}")

;lreg wordt genoteerd in 16
If $Radiolreg = 1 then Send ("16 {ENTER} {F12} {DOWN} Lreg met db/p getroffen: $bet1  $date1, $bet2 $date2, $bet3 $date3, $bet4 $date4, $bet5 $date5 {ENTER}{ENTER}")

Case $msg = $Button2
GUIDelete()
EndSelect
EndFunc

Share this post


Link to post
Share on other sites

Look at the help file for GUICrtlRead


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Look at the help file for GUICrtlRead

Yeah I tried, but the help file isn't really that helpfull. I searched in Google for a tutorial and found the following example:

#include <GUIConstants.au3>

Guicreate("Your info", 250, 500)
GuisetState(@sw_Show)

GuictrlCreateLabel("Your first name is:", 1, 11)
GuictrlCreateLabel("Your second name is:", 1, 35)
$firstName = GUICtrlCreateInput( "First name",85, 8)
$secondname = GuiCtrlCreateInput( "Second name",105, 30)
GuictrlCreateGroup("Age", 8, 50,140, 200)
$radio = GuictrlCreateradio("0-10", 13, 65)
$radio = GuictrlCreateradio("11-20", 13, 85)
$radio = GuictrlCreateradio("21-30", 13, 105)
$radio = GuictrlCreateradio("31-40", 13, 125)
$radio = GuictrlCreateradio("41-50", 13, 145)
$radio = GuictrlCreateradio("51-60", 13, 165)
$radio = GuictrlCreateradio("61-70", 13, 185)
$radio = GuictrlCreateradio("71-80", 13, 205)
$radio = GuictrlCreateradio("81-90", 13, 225)
 

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_1
            $name1 = Guictrlread($firstname)
            $name2 = Guictrlread($secondname)
            $RadioNumber = GuiCtrlRead($radio)
            Select
                case $radionumber = 0 
                    $age = "Between 0 and 10"
                    
                
                case $radionumber = 1 
                    $age = "Between 11 and 20"
                    
                    
                case $radionumber = 2
                    $age = "Between 21 and 30"
                    
                case $radionumber = 3
                    $age = "Between 31 and 40"
                    
                case $radionumber = 4
                    $age = "Between 41 and 50"
                    
                case $radionumber = 5
                    $age = "Between 51 and 60"
                    
                case $radionumber = 6 
                    $age = "Between 61 and 70"
                    
                case $radionumber = 7 
                    $age = "Between 71 and 80"
                    
                case $radionumber = 8 
                    $age = "Between 81 and 90"
                
                EndSelect
            msgbox(0, "Your info", "Your name is:" & $name1 & " " & $name2 & " "& "Your age is:" & $age)
    EndSelect
Wend

So I tried to follow this example and made this (only posted the relevant parts):

GUICtrlCreateGroup ( "Betaling of regeling", 8, 2, 250, 45)
$Radio1 = GUICtrlCreateRadio("Eenmalige betaling", 16, 25, 113, 17) 
$Radio1 = GUICtrlCreateRadio("Regeling", 132, 25, 113, 17) 

$Soort = GuiCtrlRead($Radio1)
Select 
Case $Soort = 0 
    $Soort2 = "arr"
Case $Soort = 1
    $Soort2 = "lreg"
EndSelect

Msgbox (1, "test", $Soort2); to test if soort2 was correct

but it only returns arr =/. I really don't have a clue anymore. If anyone has a relevant tutorials where this is explained it would be more then welcome. I really tried to figure it out myself and I understand that you guys frown upon such a simple question, but I really tried everything I could :mellow:.

Share this post


Link to post
Share on other sites

GuiCtrlRead() on a checkbox returns bit-mapped status. You need to extract $GUI_CHECKED:

If BitAnd(GuiCtrlRead($Radio1), $GUI_CHECKED) Then
     MsgBox(64, "Checked", "Checked")
Else
     MsgBox(64, "Unchecked", "Unchecked")
EndIf

:mellow:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

if GUICtrlRead($radio1) = $GUI_CHECKED then ;radio button has been checked
Other status bits might be set with/instead of $GUI_CHECKED, so that is not a thorough enough test.

:mellow:

P.S. Another way to get a Boolean answer is by ControlCommand($WindowID, "", $radio1, "IsChecked")

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

If GUICtrlGetState($Radioarr) = $GUI_CHECKED then send ("Bet $Bet1 $Date1")

Try it this way, If BitAND(GUICtrlRead($Radioarr), $GUI_CHECKED) = $GUI_CHECKED Then Send("Bet " & $Bet1 & " " & $Date1)

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Okay, first off, thank you all for suggesting several options. But they don't seem to be working. I'm afraid that I made a mistake somewhere but I can't seem to figure it out.

So these are the radio's I'm trying to read:

$Radioarr = GUICtrlCreateRadio("Eenmalige betaling", 16, 25, 113, 17) 
$Radiolreg = GUICtrlCreateRadio("Regeling", 132, 25, 113, 17)

I tried all of the options and to see if they are working I wanted to see a msgbox

If BitAnd(GuiCtrlRead($Radioarr), $GUI_CHECKED) Then  MsgBox(64, "Arr is checked", "checked")

I've added the GUI constant part and tried this:

if GUICtrlRead($Radioarr) = $GUI_CHECKED then Msgbox (64, "arr", "arr")

And also

If BitAND(GUICtrlRead($Radioarr), $GUI_CHECKED) = $GUI_CHECKED then Msgbox (64, "arr", "arr")

None of them display a msgbox, so I don't think they are reading the radio's =/. I really don't have a clue where I'm wrong, any help would be great!

Share this post


Link to post
Share on other sites

Rigest,

This is as simple as I can get it. :P

Here we check when you press a button:

#include <GUIConstantsEx.au3>

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

GUICtrlCreateGroup ( "Betaling of regeling", 8, 2, 250, 45)
$Radioarr = GUICtrlCreateRadio("Eenmalige betaling", 16, 25, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED) ; we need to set a default checked radio
$Radiolreg = GUICtrlCreateRadio("Regeling", 132, 25, 113, 17)

$hButton = GUICtrlCreateButton("Check", 10, 50, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            If GUICtrlRead($Radioarr) = 1 Then ; If arr is checked
                MsgBox(64, "checked", "Arr is checked")
            Else ; Because the 2 radios are a group, if the other is not checked, this one MUST be
                MsgBox(64, "checked", "Reg is checked")
            EndIf
    EndSwitch

WEnd

And here we check as soon as a radio is clicked:

#include <GUIConstantsEx.au3>

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

GUICtrlCreateGroup ( "Betaling of regeling", 8, 2, 250, 45)
$Radioarr = GUICtrlCreateRadio("Eenmalige betaling", 16, 25, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Radiolreg = GUICtrlCreateRadio("Regeling", 132, 25, 113, 17)

GUISetState()

$iCurrRadio = $Radioarr

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    If GUICtrlRead($Radioarr) = 1 Then
        If $iCurrRadio = $Radiolreg Then
            $iCurrRadio = $Radioarr
            MsgBox(64, "checked", "Arr is checked")
        EndIf
    Else
        If $iCurrRadio = $Radioarr Then
            $iCurrRadio = $Radiolreg
            MsgBox(64, "checked", "Reg is checked")
        EndIf
    EndIf

WEnd

Do they help? :mellow:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Rigest,

This is as simple as I can get it. :P

Here we check when you press a button:

#include <GUIConstantsEx.au3>

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

GUICtrlCreateGroup ( "Betaling of regeling", 8, 2, 250, 45)
$Radioarr = GUICtrlCreateRadio("Eenmalige betaling", 16, 25, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED) ; we need to set a default checked radio
$Radiolreg = GUICtrlCreateRadio("Regeling", 132, 25, 113, 17)

$hButton = GUICtrlCreateButton("Check", 10, 50, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            If GUICtrlRead($Radioarr) = 1 Then ; If arr is checked
                MsgBox(64, "checked", "Arr is checked")
            Else ; Because the 2 radios are a group, if the other is not checked, this one MUST be
                MsgBox(64, "checked", "Reg is checked")
            EndIf
    EndSwitch

WEnd

And here we check as soon as a radio is clicked:

#include <GUIConstantsEx.au3>

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

GUICtrlCreateGroup ( "Betaling of regeling", 8, 2, 250, 45)
$Radioarr = GUICtrlCreateRadio("Eenmalige betaling", 16, 25, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Radiolreg = GUICtrlCreateRadio("Regeling", 132, 25, 113, 17)

GUISetState()

$iCurrRadio = $Radioarr

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    If GUICtrlRead($Radioarr) = 1 Then
        If $iCurrRadio = $Radiolreg Then
            $iCurrRadio = $Radioarr
            MsgBox(64, "checked", "Arr is checked")
        EndIf
    Else
        If $iCurrRadio = $Radioarr Then
            $iCurrRadio = $Radiolreg
            MsgBox(64, "checked", "Reg is checked")
        EndIf
    EndIf

WEnd

Do they help? :mellow:

M23

Melba you are my hero! Thank you so much. I think that the mistake that I made was that I didn't set a state for the radio's. Now I can finaly go on with my script :party:

Share this post


Link to post
Share on other sites

Rigest,

Glad I could help. :mellow:

A small point - when you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. :P

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Ok, will do that :mellow:

Share this post


Link to post
Share on other sites

Thanks, still useful to this day :blink:


\

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