Vzy Posted February 16, 2010 Posted February 16, 2010 Hi, what I am trying to do is make a script that gets the mouse position from the GUI, then moves to that position, right clicks, then moves to the next set position and double left clicks, and being able to set the amount of loops. I cannot get the OK button to register, and I think I have done the loop wrong, any help would be great! Thanks! expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Auto1 = GUICreate("Auto1", 204, 198, 192, 124) $X1 = GUICtrlCreateInput("0", 40, 40, 41, 21) $Y1 = GUICtrlCreateInput("0", 120, 40, 41, 21) $CROSS1 = GUICtrlCreateLabel("X", 96, 40, 16, 24) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") $X2 = GUICtrlCreateInput("0", 40, 112, 41, 21) $Y2 = GUICtrlCreateInput("0", 120, 112, 41, 21) $CROSS2 = GUICtrlCreateLabel("X", 96, 112, 16, 24) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") $Auto = GUICtrlCreateButton("OK", 80, 144, 49, 25, $WS_GROUP) $LOOP = GUICtrlCreateInput("0", 96, 75, 20, 20) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Func Auto() $i = 0 Do MouseMove("X1", "Y1") MouseClick("right") Sleep(750) MouseMove("X2", "Y2") MouseCLick("left") MouseCLick("left") SLeep(500) Until $i = ("LOOP") EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
Valuater Posted February 16, 2010 Posted February 16, 2010 (edited) Maybe... expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Auto1 = GUICreate("Auto1", 204, 198, 192, 124) $X1 = GUICtrlCreateInput("0", 40, 40, 41, 21) $Y1 = GUICtrlCreateInput("0", 120, 40, 41, 21) $CROSS1 = GUICtrlCreateLabel("X", 96, 40, 16, 24) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") $X2 = GUICtrlCreateInput("0", 40, 112, 41, 21) $Y2 = GUICtrlCreateInput("0", 120, 112, 41, 21) $CROSS2 = GUICtrlCreateLabel("X", 96, 112, 16, 24) GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif") $Auto = GUICtrlCreateButton("OK", 80, 144, 49, 25, $WS_GROUP) $LOOP = GUICtrlCreateInput("0", 96, 75, 20, 20) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Auto $x = GUICtrlRead($X1) Auto($x) EndSwitch WEnd ; functions Func Auto($x) ; seperate by coima, example Auto ($Y1A, $Y2A, etc) ; test Return MsgBox(4096, "Test", $x, 5) $i = 0 Do MouseMove( $x, "Y1") MouseClick("right") Sleep(750) MouseMove("X2", "Y2") MouseClick("left") MouseClick("left") Sleep(500) Until $i = ("LOOP") EndFunc ;==>Auto 8) Edited February 16, 2010 by Valuater
Vzy Posted February 16, 2010 Author Posted February 16, 2010 Thanks for your reply, tested it out then had a quick look. Why do you need to define $X1/Y1 etc in Func? I am way more confused now lol! I am extremely tired, my mind is like EAHSUEIASDIASDI Will check back tomorrow when I am less tired! Hopefully I can make something of the code you pasted.
martin Posted February 16, 2010 Posted February 16, 2010 (edited) On 2/16/2010 at 7:14 AM, 'Vzy said: Thanks for your reply, tested it out then had a quick look. Why do you need to define $X1/Y1 etc in Func? I am way more confused now lol! I am extremely tired, my mind is like EAHSUEIASDIASDI Will check back tomorrow when I am less tired! Hopefully I can make something of the code you pasted. When you press the button $Auto it won't call the function Auto. It generates a message which is detectted by GuiGetMsg as $Auto so you have to add something to make it call Auto. While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Auto Auto();but it's a bit confusing jhaving a function name the same as a button for me. EndSwitch But, as Valuater has shown, you need to work out what the coordinates are you are going to use. "X1" will not be the value in the input $X1. To get the text from the input you have to use GuiCtrlRead MouseMove(GuiCtrlRead($X1),GuiCtrlRead($Y1)) Spend some time reading the examples in the help for buttons, inputs, mousemove and anything you decide that you want to use. Your problem at the moment is that you have not done that and you are trying to write a script by guessing how the language will work, and it can only end in tears . Edited February 16, 2010 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Vzy Posted February 17, 2010 Author Posted February 17, 2010 Thanks for your help! You were right, I did get ahead of myself! Almost got it now, just need to work out the loop.. Any ideas? expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $main = GUICreate("AOAuto", 222, 306, 192, 124) $boxlabel = GUICtrlCreateLabel("Box Coords", 56, 0, 113, 28) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") $x1 = GUICtrlCreateInput("X", 56, 32, 41, 21) $y1 = GUICtrlCreateInput("Y", 128, 32, 41, 21) $crosslabel1 = GUICtrlCreateLabel("X", 104, 32, 16, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $itemlabel = GUICtrlCreateLabel("Item Coords", 56, 80, 116, 28) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") $x2= GUICtrlCreateInput("X", 56, 128, 41, 21) $y2 = GUICtrlCreateInput("Y", 128, 128, 41, 21) $crosslabel2 = GUICtrlCreateLabel("X", 104, 128, 16, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $startbutton = GUICtrlCreateButton("Start", 64, 272, 89, 33, $WS_GROUP) $looplabel = GUICtrlCreateLabel("Loops", 80, 160, 61, 28) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") $loops = GUICtrlCreateInput("0", 88, 192, 41, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("z","mousepos") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $startbutton Startbutton() EndSwitch WEnd Func startbutton() $i = 0 Do MouseMove(GuiCtrlRead($X1),GuiCtrlRead($Y1)) MouseClick("right") Sleep(750) MouseMove(GuiCtrlRead($X2),GuiCtrlRead($Y2)) MouseClick("left", 0, 500, 2) SLeep(500) Until $i = GuiCtrlRead($loops) EndFunc Func mousepos() $pos = MouseGetPos() MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1]) EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc
Valuater Posted February 17, 2010 Posted February 17, 2010 You need to "add" 1 to $i each loop.... maybe $i = 0 Do $i = $i + 1 8)
Vzy Posted February 17, 2010 Author Posted February 17, 2010 (edited) Got it! Thanks for your help guys. EDIT: Is it possible to make it so when I press "z" to get the mouse position, that it saves those coords into the input on the gui? instead of writing it down? Edited February 17, 2010 by Vzy
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