kjpolker Posted October 15, 2009 Posted October 15, 2009 So I made a simple auto mouse clicker and I was wondering how I can define my radio1 as a left mouse click and my radio2 as a right mouse click, so when reading the function: Func Sendinformation() Local $X, $Y MouseClick('', GUICtrlRead($X), GUICtrlRead($Y), 1, GUICtrlRead($Input3) * 100) EndFunc It will input either left or right mouse in the first set of brackets, any help? Thanks!
Moderators Melba23 Posted October 15, 2009 Moderators Posted October 15, 2009 kjpolker, This should give you an idea of how to go about it: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) GUIStartgroup($hGUI) $hRadio_L = GUICtrlCreateRadio("Left", 10, 10, 50, 20) GUICtrlSetState(-1, $GUI_CHECKED) $hRadio_R = GUICtrlCreateRadio("Right", 10, 50, 50, 20) $hLabel = GUICtrlCreateLabel("", 10, 100, 200, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch If GUICtrlRead($hRadio_L) = 1 Then GUICtrlSetData($hLabel, "Left") Else GUICtrlSetData($hLabel, "Right") EndIf WEnd M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
kjpolker Posted October 15, 2009 Author Posted October 15, 2009 (edited) Ok now I just can't get it to loop the selected number of times, here is the code: While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit If GUICtrlRead($LeftRadio) = 1 Then GUICtrlSetData($hLabel, "Left") Else GUICtrlSetData($hLabel, "Right") EndIf Case $Button1 MouseClick(GUICtrlRead($hLabel), GUICtrlRead($Xinput), GUICtrlRead($Yinput), 1, GUICtrlRead($Input3) * 1000) EndSwitch WEnd It will go to the coord and I assume it will click but it will only click once, I want it to read $input3 and multiply it by 1000 to get the miliseconds, and it wont continuously click for some reason. And sorry Melba23 EDIT: O and I just found out that it won't read right or left mouse clicks, it just makes it left click no matter what radio button is checked, so what do I do there? My guess is there is something wrong with the GUICtrlReads I have, because if there are no coordinates given in the inputs than it will click at 0,0. And I want it to click where the mouse currently is on the screen. Please help! Edited October 15, 2009 by kjpolker
Moderators Melba23 Posted October 15, 2009 Moderators Posted October 15, 2009 kjpolker, This code is much closer to what you say you need: expandcollapse popup#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) GUIStartgroup($hGUI) $hRadio_L = GUICtrlCreateRadio("Left", 10, 10, 50, 20) GUICtrlSetState(-1, $GUI_CHECKED) $hRadio_R = GUICtrlCreateRadio("Right", 10, 50, 50, 20) $iInput_X = GUICtrlCreateInput("", 200, 10, 100, 20) $iInput_Y = GUICtrlCreateInput("", 200, 40, 100, 20) $iInput_T = GUICtrlCreateInput("", 200, 70, 100, 20) GUICtrlCreateLabel("X", 170, 10, 30, 20) GUICtrlCreateLabel("Y", 170, 40, 30, 20) GUICtrlCreateLabel("T", 170, 70, 30, 20) $hButton1 = GUICtrlCreateButton("Start", 10, 200, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton1 ; read radios and set correct mouse button If GUICtrlRead($hRadio_L) = 1 Then $sMouse_Button = "left" Else $sMouse_Button = "right" EndIf ; Get position parameters $iX_Pos = GUICtrlRead($iInput_X) $iY_Pos = GUICtrlRead($iInput_Y) ; If no inputs then click at mouse position If $iX_Pos = "" And $iY_Pos = "" Then $aMouse_Pos = MouseGetPos() $iX_Pos = $aMouse_Pos[0] $iY_Pos = $aMouse_Pos[1] EndIf ; Read repeat delay in seconds and transform to ms $iT_ms = GUICtrlRead($iInput_T) * 1000 ; Start a loop to repeatedly click the mouse While 1 ; Click mouse ;MouseClick($sMouse_Button, $iX_Pos, $iY_Pos, 1) ; <<<<<<<<<<<<<<<<<<<<<<<<<<< uncomment this ConsoleWrite($sMouse_Button & " - " & $iX_Pos & " - " & $iY_Pos & " - " & $iT_ms & @CRLF) ; <<<<<<<< delete this ; We need a second loop to wait for $iT_ms - if we use Sleep. the script is unresponsive and we cannot stop it $iBegin = TimerInit() While TimerDiff($iBegin) < $iT_ms If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit ; Exit if teh gui is closed WEnd ; or we keep looping to click the mouse again WEnd EndSwitch WEnd If you do not enter any position input, the mouse will click where the mouse is - which, as you have to press the Start button, is always on the Start button at about 650 x 500. You will have change the code a lot if you want it to follow the mouse around - or if you want to alter the parameters of the click. Please do not take this the wrong way, but looking at your last post and seeing how you just stuffed a few lines from my hint at random into your existing code, I think you could do with learning a bit more about scripting. Could I suggest the excellent tutorials that you will find here and here. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
kjpolker Posted October 15, 2009 Author Posted October 15, 2009 I will take a look at those tutorials and thanks for the help, but the reason I ask questions on forums is cause I literally don't have any idea on it, I can come up with a near finished program but there are just those little fancy things that I don't know of, and I don't stuff codes from people into mine, cause I don't learn anything that way, what I do is I read it and manually retype it and try to understand it, but for the radion buttons, I didn't understand them at all on how they work. Now that I have seen your coding I found out what you did and why, and why mine wasn't working so now in the future I don't need to ask how a radio buttons interacts with other parts.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now