TrickyDeath Posted February 15, 2014 Share Posted February 15, 2014 Hello everyone, First of all, i just start to learning this language by myself, via help file and google search! So my lame question is, how i can store the mouse coordinate into a 2D array multiple times? My friend ask me to make an auto clicker script for him. If i simple codeing the mouse coordinates it is work fine, but every time if the mouse coordinates will change, need to change them in code as well. So i decide to make a function for recording it till it needed, then i can use that array in a loop for make the mouse cursor move and click on right position. Code: expandcollapse popup#include <Array.au3> HotKeySet("{F1}", "TogglePause") HotKeySet("{F2}", "RecordingMouseCoordinate") HotKeySet("{F3}", "Display") HotKeySet("{F5}", "RunScript") HotKeySet("{ESC}", "Terminate") Global $Paused Local $MouseX, $MouseY Global $MouseRecord[1][2], $MouseRecordXY[1][2] Local $i = 0 MsgBox(0, "Info", "F1 - Pause" & @LF & "F2 - Record coordinate" & @LF & "F3 - Display Coordinates" & @LF & "F5 - Run the Script" & @LF & "ESC - Exit script") While 1 Sleep(100) WEnd Func RunScript() Do #cs ; loop for make mouse work with stored coordinates // Something like this but it is not work, cause of error what i will fix when i have the array for it For $x = 1 To $MouseRecordXY[$x] MouseClick("left", $MouseRecordXY[$x][0], $MouseRecordXY[$x][1], 1, 1) Next #ce Until $i = 1 EndFunc ;==>RunScript Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("Script is Paused", 0, 0) EndFunc ;==>TogglePause Func RecordingMouseCoordinate() Local $MousePos = MouseGetPos() $MouseX = $MousePos[0] $MouseY = $MousePos[1] ToolTip("Mouse Coordinate - " & $MousePos[0] & " x " & $MousePos[1], 0, 0) $MouseRecord[0][0] = $MousePos[0] $MouseRecord[0][1] = $MousePos[1] #cs _ArrayAdd($MouseRecordXY, $MouseRecord) ; tried to add 2D array into another 2D array to store the coordinates in $MouseRecordXY array _ArrayConcatenate($MouseRecordXY, $MouseRecord) ; Non of them want to work or i am just simple lame :) _ArrayAdd($MouseRecordXY[0][0], $MouseX) _ArrayAdd($MouseRecordXY[0][1], $MouseY) #ce _ArrayDisplay($MouseRecordXY, "") ;_ArrayDisplay($MouseRecord, "");this one is working EndFunc ;==>RecordingMouseCoordinate Func Display() EndFunc ;==>Display Func Terminate() Exit 0 EndFunc ;==>Terminate Other question, how i can use _ArrayAdd for adding 2D array into another 2d array? Or shell i use this _ArrayConcatenate instead of _ArrayAdd? Unfortuantely AutoIT help have no examples for / with multi dimensional arrays what i need. Till now i tried many crazy different way to make it work but keep geting different errors. Probably the solution is simple, but i am not seeing it, since i am beginer on programing and still have a lot of thing to try to understand. As i read somewhere AutoIT can use send order only on the active window. Do we have maybe any way to use it on multi clients with out activateing the windows itself? And / Or can we use it on 2 window at same time? I would be happy if i get little explain on help, how does it work, or what i did wrong, so i can learn from it. Tricky, Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :) [u]Tricky[/u] You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei) Link to comment Share on other sites More sharing options...
water Posted February 15, 2014 Share Posted February 15, 2014 Welcome to AutoIt and the forum! Can you please tell us which program you try to automate with your auto-clicker? Working with mouse coordinates isn't very reliable. It's dependant on screen resolution and window coordinates. Most of the time there more reliable ways to automate an application. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
TrickyDeath Posted February 15, 2014 Author Share Posted February 15, 2014 (edited) Thank You, He wana use it for a game called dekaron for talking with NPC (non player character) to picking up replaceable quests or conversation. With coded coordinates worked fine. I know MouseGetPos Screen (resolution) for that i can check the actual screen size with: Func ScreenSize() Local $ScreenSizeWidth Local $ScreenSizeHeight $ScreenSizeWidth = @DesktopWidth $ScreenSizeHeight = @DesktopHeight MsgBox(0, "Screen Size", StringFormat("Width %u Hight %u", $ScreenSizeWidth, $ScreenSizeHeight)) EndFunc ;==>ScreenSize And found on forum how to get mouse pos on specificated window. I have trouble with adding 2d array into another 2d array. Can not understand why it is not working, or how it have to work. (dont have the require knowleadge yet :-/) Tricky, Edited February 15, 2014 by TrickyDeath Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :) [u]Tricky[/u] You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei) Link to comment Share on other sites More sharing options...
water Posted February 15, 2014 Share Posted February 15, 2014 The next step I suggest is to read the forum rules. A link can be found in the lower right corner of each page. Game automation of any kind is prohibited here. Sorry. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 15, 2014 Moderators Share Posted February 15, 2014 TrickyDeath,water is quite right - please read the Forum rules (the link is also at bottom right of each page) - particularly the bit about not discussing game automation - before you post again. Thread locked. But welcome to the AutoIt forum - and see you soon with a legitimate question I hope. 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 Link to comment Share on other sites More sharing options...
Recommended Posts