Sign in to follow this  
Followers 0
Guest Hillbilly Hacker

Radio Button Input

1 post in this topic

Here is a script that will collect input from radio buttons in a GUI and pass them to Notepad. Maybe it will help save other newbies some time, or maybe you PROs will show us a quicker easier way..... anyway here it is hope it helps someone

;

; Sample script to pass GUI input from radio buttons to Notepad

; Written by - Eric Dawson 4/30/04

;

GuiCreate("Radio Input", 270, 160)

GuiShow()

Opt("GUICoordMode",1)

Opt("GUINotifyMode", 1)

;************************* Group One

$group_1 = GUISetControl( "group", "Group One Value", 10, 10, 100, 90)

$radio_1 = GUISetControl("radio", "1", 50, 30, 50, 20)

$radio_2 = GUISetControl("radio", "2", 50, 50, 50, 20)

$radio_3 = GUISetControl("radio", "3", 50, 70, 50, 20)

GuiSetControlEx(-1, 1)

$0 = GUISetControl("0", "0", 0,0, 0,0)

;************************* Group Two

$group_2 = GUISetControl( "group", "Group Two Value", 150, 10, 100, 90)

$radio_4 = GUISetControl( "radio", "A", 190, 30, 50, 20)

GuiSetControlEx(-1, 1)

$radio_5 = GUISetControl( "radio", "B", 190, 50, 50, 20)

$radio_6 = GUISetControl( "radio", "C", 190, 70, 50, 20)

;************************* Create action buttons

$buttonOK = GUISetControl( "button", "Ok", 90, 120, 35)

$buttonCancel = GUISetControl( "button", "Cancel", 140, 120, 60)

;************************* Collect Data

While 1

sleep(100)

$msg = GuiMsg(0)

Select

Case $msg = -3;user clicked the close button 'x' in corner

Exit

Case $msg = $group_1

;;;

Case $msg = $radio_1

;;;

Case $msg = $radio_2

;;;

Case $msg = $radio_3

;;;

Case $msg = $group_2

;;;

Case $msg = $radio_4

;;;

Case $msg = $radio_5

;;;

Case $msg = $radio_6

;;;

Case $msg = $buttonCancel

Exit

Case $msg = $buttonOK

ExitLoop

EndSelect

WEnd

;Exit

;************************* Assign variable for Group One

$nradio_1=GUIRead($radio_1)

$nradio_2=GUIRead($radio_2)

$nradio_3=GUIRead($radio_3)

DIM $nGroup1

If $nradio_1 = 1 Then

$nGroup1 = "1"

ElseIF $nradio_2 = 1 Then

$nGroup1 = "2"

ElseIF $nradio_3 = 1 Then

$nGroup1 = "3"

EndIf

;************************* Assign variable for Group Two

$nradio_4=GUIRead($radio_4)

$nradio_5=GUIRead($radio_5)

$nradio_6=GUIRead($radio_6)

DIM $nGroup2

If $nradio_4 = 1 Then

$nGroup2 = "a"

ElseIF $nradio_5 = 1 Then

$nGroup2 = "b"

ElseIF $nradio_6 = 1 Then

$nGroup2 = "c"

EndIf

;************************* Print the value of the groups in Notepad

Run("notepad.exe")

WinWaitActive("Untitled - Notepad")

Send("Group One's Selection: ")

Send($nGroup1)

Send("{ENTER 2}")

Send("Group Two's Selection: ")

Send($nGroup2)

Send("{ENTER 2}")

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