Jump to content

Not useing the function after clicking GUICtrlCreateRadio.


Recommended Posts

Hi,

I'm learning about GUICtrlCreateRadio but i have one problem. When i click a radio button then it will start that function.

I have 4 radio buttons. Everybutton does something els. But i want to select a radio button then press start. The start function is something and then after that it needs to start the selected radio button.

I have no idea what or how to do.

A sample script.

HotkeySet ("{0}", "Stop")

Func Stop ()
        Exit 0
    EndFunc
    
    
#include <GUIConstantsEx.au3>
#include <windowsconstants.au3>

MENU()
Func MENU()


GUICreate("Stop spam", 400, 288) 
GUISetBkColor(0xaaaaaa)
GUICtrlCreateLabel((@MON & "/" & @MDAY & "/" & @YEAR), 325, 10)
$Mouse1 = GUICtrlCreateRadio("Mouse1", 30, 110, 150, 15)
$Mouse2 = GUICtrlCreateRadio("Mouse2", 30, 130, 150, 15)
$Mouse3 = GUICtrlCreateRadio("Mouse3", 30, 150, 150, 15)
$Mouse4 = GUICtrlCreateRadio("Mouse4", 30, 170, 150, 15)
$start = GUICtrlCreateButton("Start", 100, 200, 75, 45)


GUISetState()
    While 1
        

        $msg = GUIGetMsg()

            If $msg = $GUI_EVENT_CLOSE  Then ExitLoop
            If $msg = $start then starter()
            If $msg = $Mouse1 Then Mouse1()
            If $msg = $Mouse2 Then Mouse2()
            If $msg = $Mouse3 Then Mouse3()
            If $msg = $Mouse4 Then Mouse4()
wend
            
    GUIDelete()
EndFunc

Func starter()
MouseClick ("left",77,777) 
sleep (50)
MouseClick ("left",552,413)
Sleep (500)
EndFunc

Func Mouse1()
MouseClick ("left", 80,287) 
sleep (50)
MouseClick ("left", 500,183)
Sleep (500)
EndFunc

Func Mouse2()
MouseClick ("left", 94,302) 
sleep (50)
MouseClick ("left", 500,183)
Sleep (500)
EndFunc

Func Mouse3()
MouseClick ("left", 77,335) 
sleep (50)
MouseClick ("left", 500,183)
Sleep (500)
EndFunc

Func Mouse4()
MouseClick ("left", 94,412) 
sleep (50)
MouseClick ("left", 500,183)
Sleep (500)
EndFunc

thnx for helping.

Link to comment
Share on other sites

  • Moderators

SjaakTV,

Please do not bump your own posts within 24hrs. :mellow:

If I understand you correctly, this should do what you want:

#include <GUIConstantsEx.au3>
#include <windowsconstants.au3>

Global $Mouse1, $Mouse2, $Mouse3, $Mouse4

HotKeySet("{0}", "Stop")

Func Stop()
    Exit 0
EndFunc   ;==>Stop

MENU()

Func MENU()

    GUICreate("Stop spam", 400, 288)
    GUISetBkColor(0xaaaaaa)
    GUICtrlCreateLabel((@MON & "/" & @MDAY & "/" & @YEAR), 325, 10)
    GUIStartGroup() ; Starta group so only 1 radio at a time can be selected
    $Mouse1 = GUICtrlCreateRadio("Mouse1", 30, 110, 150, 15)
    $Mouse2 = GUICtrlCreateRadio("Mouse2", 30, 130, 150, 15)
    $Mouse3 = GUICtrlCreateRadio("Mouse3", 30, 150, 150, 15)
    $Mouse4 = GUICtrlCreateRadio("Mouse4", 30, 170, 150, 15)

    $start = GUICtrlCreateButton("Start", 100, 200, 75, 45)

    GUISetState()

    While 1

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $start
                ; Start button pressed, so run function starter()
                starter()
        EndSwitch
    WEnd

    GUIDelete()

EndFunc   ;==>MENU

Func starter()

    ; Do this each time the start button is pressed
    MouseClick("left", 77, 777)
    Sleep(50)
    MouseClick("left", 552, 413)
    Sleep(500)

    ; Now check and see which Radio is pressed and run the corresponding function
    If GUICtrlRead($Mouse1) = 1 Then Mouse1()
    If GUICtrlRead($Mouse2) = 1 Then Mouse2()
    If GUICtrlRead($Mouse3) = 1 Then Mouse3()
    If GUICtrlRead($Mouse4) = 1 Then Mouse4()

EndFunc   ;==>starter

Func Mouse1()
    MouseClick("left", 80, 287)
    Sleep(50)
    MouseClick("left", 500, 183)
    Sleep(500)
EndFunc   ;==>Mouse1

Func Mouse2()
    MouseClick("left", 94, 302)
    Sleep(50)
    MouseClick("left", 500, 183)
    Sleep(500)
EndFunc   ;==>Mouse2

Func Mouse3()
    MouseClick("left", 77, 335)
    Sleep(50)
    MouseClick("left", 500, 183)
    Sleep(500)
EndFunc   ;==>Mouse3

Func Mouse4()
    MouseClick("left", 94, 412)
    Sleep(50)
    MouseClick("left", 500, 183)
    Sleep(500)
EndFunc   ;==>Mouse4

If it does not, please explain again! :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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