Jump to content

radio Buttons


Guest tso_xaser
 Share

Recommended Posts

Guest tso_xaser

Hi i'm made a couple of scripts that and now i'm trying to build those scripts into 1 script with a gui interface.

the gui code is

#include <GuiConstants.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("TSO Teaching Script", 341, 316,(@DesktopWidth-341)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Radio_1 = GuiCtrlCreateRadio("Cooking", 140, 10, 80, 20)

$Radio_2 = GuiCtrlCreateRadio("Charisma", 140, 50, 80, 20)

$Radio_3 = GuiCtrlCreateRadio("Mechanical", 140, 90, 100, 20)

$Radio_4 = GuiCtrlCreateRadio("Creativity", 140, 130, 80, 20)

$Radio_5 = GuiCtrlCreateRadio("Body", 140, 170, 70, 20)

$Radio_6 = GuiCtrlCreateRadio("Logic", 140, 210, 60, 20)

$Button_7 = GuiCtrlCreateButton("Go", 140, 250, 50, 40)

$Label_8 = GuiCtrlCreateLabel("Label8", 170, 40, 1, 1)

GuiSetState()

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case Else

;;;

EndSelect

WEnd

Exit

What i need to do is get it so that i select a radio button and click the go button that it runs the right part of the script

I.e. if i select charisma button and click go it runs this

;Latin Steps

MouseMove(341, 292)

MouseClick("left")

MouseMove(275, 329)

MouseClick("left")

MouseMove(189, 373)

MouseClick("left")

;Charisma Teaching

MouseMove(410, 318)

MouseClick("left")

MouseMove(407, 390)

MouseClick("left")

MouseMove(405, 465)

MouseClick("left")

MouseMove(467, 423) ;skill select

MouseClick("Left")

I'm not sure how to get the second script to work when you select the button.

thanks for any help you give me

Link to comment
Share on other sites

When you create controls like radio buttons or list boxes, a handle is returned.

In your script the variable $msg can contain a handle or a special message.

After every loop AutoIt checks (using GUIGetMsg) if a control is clicked.

So if you want to do something if the "Go" button is clicked, you add a "Case" to the Select.. Case statement.

Case $msg = $Button_7
   MsgBox(64, 'Test', 'You clicked the Go button!')

If you want to know what radio button is selected (if any), you test each one of them using:

If GUICtrlRead(<Ctrl handle>) = $GUI_CHECKED Then
  ;This radio button/check box is selected/checked
Else
  ;This radio button/check box is not selected/checked
EndIf

You can find some info the help file.

If it's not sufficient, ask questions here.

Link to comment
Share on other sites

Try this one:

#include <GuiConstants.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GUICreate("TSO Teaching Script", 341, 316, (@DesktopWidth - 341) / 2, (@DesktopHeight - 316) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Radio_1 = GUICtrlCreateRadio("Cooking", 140, 10, 80, 20)

$Radio_2 = GUICtrlCreateRadio("Charisma", 140, 50, 80, 20)

$Radio_3 = GUICtrlCreateRadio("Mechanical", 140, 90, 100, 20)

$Radio_4 = GUICtrlCreateRadio("Creativity", 140, 130, 80, 20)

$Radio_5 = GUICtrlCreateRadio("Body", 140, 170, 70, 20)

$Radio_6 = GUICtrlCreateRadio("Logic", 140, 210, 60, 20)

$Button_7 = GUICtrlCreateButton("Go", 140, 250, 50, 40)

$Label_8 = GUICtrlCreateLabel("Label8", 170, 40, 1, 1)

GUISetState()

While 1

  $msg = GUIGetMsg()

  $Cooking = GUICtrlRead($Radio_1)

  $Charisma = GUICtrlRead($Radio_2)

  Select

      Case $msg = $Button_7

        If $Cooking = $GUI_CHECKED Then

            MsgBox(4096, "Radio1", "Cooking is checked", 10) ; event

        Else

            MsgBox(4096, "Radio1", "Cooking is unchecked", 10)

        EndIf

       

        If $Charisma = $GUI_UNCHECKED Then

            MsgBox(4096, "Radio2", "Charisma is unchecked", 10) ; event

        Else

            MsgBox(4096, "Radio1", "Charisma is checked", 10)

  EndIf

 

      Case $msg = $GUI_EVENT_CLOSE

        Exit

      Case Else ; (not needed)

        ;;;

  EndSelect

WEnd

Exit

; What i need to do is get it so that i select a radio button and click the go button that it runs the right part of the script

; I.e. if i select charisma button and click go it runs this

;Latin Steps

MouseMove(341, 292)

MouseClick("left")

MouseMove(275, 329)

MouseClick("left")

MouseMove(189, 373)

MouseClick("left")

;Charisma Teaching

MouseMove(410, 318)

MouseClick("left")

MouseMove(407, 390)

MouseClick("left")

MouseMove(405, 465)

MouseClick("left")

MouseMove(467, 423) ;skill select

MouseClick("Left")

(after events; change the state of gui not 'Exit' with GUISetState).
Link to comment
Share on other sites

Guest tso_xaser

Hi just a few more things

this is part of my script so far

Select
      Case $msg = $Button_7
        If $Cooking = $GUI_CHECKED Then
               ;Latin Steps
            MouseMove(341, 292)
            MouseClick("left")
            MouseMove(275, 329)
            MouseClick("left")
            MouseMove(189, 373)
            MouseClick("left")
    ; Teaching
                                MouseMove(410, 318)
                                MouseClick("left")
                                MouseMove(407, 390)
                                MouseClick("left")
                                MouseMove(405, 465)
                                MouseClick("left")
                                MouseMove(467, 423);skill select
                                MouseClick("Left")
        Else
            MsgBox(4096, "Radio1", "Cooking is unchecked", 10)
        EndIf

In total there is 6 radio buttons

instead of it saying that each button is unchecked.

Is there a way so that it will just say if there is no radio buttons checked.

and thank you very much

you guys have been a great help so far

Link to comment
Share on other sites

In total there is 6 radio buttons

instead of it saying that each button is unchecked.

Is there a way so that it will just say if there is no radio buttons checked.

Simple remove "MsgBox(4096, "Radio1", "Cooking is unchecked", 10)" and add events that You like, same for other buttons (if event for that button is not added script runs until "Case $msg = $GUI_EVENT_CLOSE").
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...