gcdot Posted February 18, 2010 Posted February 18, 2010 (edited) I am new to this scripting thing but yes i did do a search for this and cant find anything. Basically I am looking to create an automated program to click on 20 or more different points on the screen. I cant find the command or codes to allow me to input or store different x,y coordinates. can i declare $script_x = 0 $script_y = 0 $script_x2 = 0 $script_y2 = 0 $script_x3 = 0 $script_y3 = 0 and so on until $script_x20 = 0 $script_y20 = 0 and then set Func set_position() $script_x = MouseGetPos(0) $script_y = MouseGetPos(1) Func set_position2() $script_x2 = MouseGetPos(0) $script_y2 = MouseGetPos(1) Func set_position3() $script_x3 = MouseGetPos(0) $script_y3 = MouseGetPos(1) and so on? I tried this and kept getting errors. Any help/suggestions or ideas of coding examples would be appreciated! Thank you in advance Edited February 18, 2010 by gcdot
JohnOne Posted February 18, 2010 Posted February 18, 2010 (edited) I dont see any mouseclick() functions in that, just some variable declarations and incorrect use of mousegetpos, so there is no way I can tell what you might be doing wrong. You need to post part of the cod that is in error, and the error you are getting. EDIT: correct use of mousegetpos $var = MouseGetPos() $script_x = $var[0] $script_y = $var[1] Edited February 18, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
gcdot Posted February 19, 2010 Author Posted February 19, 2010 Here are parts of the script for 5 stored positions. $script_x = 0 $script_y = 0 $script_x2 = 0 $script_y2 = 0 $script_x3 = 0 $script_y3 = 0 $script_x4 = 0 $script_y4 = 0 $script_x5 = 0 $script_y5 = 0 ; Hotkeys HotKeySet("{1}", "set_position") HotKeySet("{2}", "set_position2") HotKeySet("{3}", "set_position3") HotKeySet("{4}", "set_position4") HotKeySet("{5}", "set_position5") HotKeySet("{F1}", "start_script") HotKeySet("{ESC}", "stop_script") ; Hotkey Functions 1 Func set_position() $script_x = MouseGetPos(0) $script_y = MouseGetPos(1) GUICtrlSetData($label_coordinate_x, $script_x) GUICtrlSetData($label_coordinate_y, $script_y) EndFunc ; Hotkey Functions 2 Func set_position2() $script_x2 = MouseGetPos(0) $script_y2 = MouseGetPos(1) GUICtrlSetData($label_coordinate_x2, $script_x2) GUICtrlSetData($label_coordinate_y2, $script_y2) EndFunc ; Hotkey Functions 3 Func set_position3() $script_x3 = MouseGetPos(0) $script_y3 = MouseGetPos(1) GUICtrlSetData($label_coordinate_x3, $script_x3) GUICtrlSetData($label_coordinate_y3, $script_y3) EndFunc ; Hotkey Functions 4 Func set_position4() $script_x4 = MouseGetPos(0) $script_y4 = MouseGetPos(1) GUICtrlSetData($label_coordinate_x4, $script_x4) GUICtrlSetData($label_coordinate_y4, $script_y4) EndFunc ; Hotkey Functions 5 Func set_position5() $script_x5 = MouseGetPos(0) $script_y5 = MouseGetPos(1) GUICtrlSetData($label_coordinate_x5, $script_x5) GUICtrlSetData($label_coordinate_y5, $script_y5) EndFunc When i press the key number (1) to record the positioningfor the first position it's fine then I press the second key (2) it errors out saying something like Line 56 (File "C:\Documents.........myfile.au"): GUICtrlSetData($label_coordinate_x2,$script_x2) GUICtrlSetData(>ERROR Error: Variable used without being declared.
kaotkbliss Posted February 19, 2010 Posted February 19, 2010 first change all the () in mousegetpos commands to [] and see if that helps. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy!
JohnOne Posted February 19, 2010 Posted February 19, 2010 (edited) EDIT: Bad info Sorry. Edited February 19, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
kaotkbliss Posted February 19, 2010 Posted February 19, 2010 (edited) When you use the MouseGetPos() it returns an array of 2 numbers, the x value and the y value. if you use the line $script=MouseGetPos() you would get the x and y by doing mousemove($script[0],$script[1],10) the [0] is the x position and the [1] is the y although I see what you are trying to do from the help file. this way you can get both numbers in one call the help file does state that you can use the (0) for x and (1) for y in the MouseGetPos() func. Edited February 19, 2010 by kaotkbliss 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy!
JohnOne Posted February 19, 2010 Posted February 19, 2010 Once again a massive fail on my part, I do apologise gcdot. It is I who should have re-read the help file. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
kaotkbliss Posted February 19, 2010 Posted February 19, 2010 (edited) On 2/19/2010 at 2:15 AM, 'JohnOne said: Once again a massive fail on my part, I do apologise gcdot.It is I who should have re-read the help file.I thought the same thing I think because I have never seen anyone use MouseGetPos in that manner. Everyone always uses the array method I believe because it is easier, less coding and less variables to deal with.having read over this, my help was wrong as well.With what was given of the code, it looks right.The variable not being declared is the $label_coordinate_x2somewhere there is a GUI? and are these label variables defined in another part of the script (they are not in what was given)? Edited February 19, 2010 by kaotkbliss 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy!
gcdot Posted February 20, 2010 Author Posted February 20, 2010 Thanks everyone for posting some inputs. I rechecked all my codes and finally figured out what the problem was. The codes above were fine there was an error elsewhere in the script but i did figure out what the problem was and was able to successfully store multiple click points on the test program. Again i appreciate your help!
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