Jump to content
Sign in to follow this  

Inputting and pulling array data

Recommended Posts


Hello, I'm new here. I'm also new to programming.

I've been trying to write a script for a Mortal Online (I know it's normally not allowed, but this games EULA has stated it's allowed for it's Beta (at least)). I am trying to have the script pull multiple MouseGetPos points and put them into an array. My intention was to have the array hold a number of X,Y coordinates decided by the user. However after a lot of work and research, I've come up with nothing. First of all, to verify, I can't use a variable like this?

$mousepos = MouseGetPos()

$x = $mousepos[0]

$y = $mousepos[1]

$mpa[$num][0] = $x

$mpa[$num][1] = $y

$num is the number of cursor placements the user chose. I realize I may be taking an extra step in what I am trying to accomplish here. I tried it without the extra step first. Neither work.

My real question is, after being given a 1D array for the X,Y cursor values, how can I put them into an array that is, for example, 4 [X,Y] points long?

[X, Y]

[X, Y]

[X, Y]

[X, Y]

Thanks in advance,


Share this post

Link to post
Share on other sites

Just to back him up, the EULA states he can bot/macro or W/E during beta ONLY

They call me MrRegExpMan

Share this post

Link to post
Share on other sites

Here is an example of entering coordinates and mouse coordinates into an array.

Comments are added to help you understand the script. Looking up unfamiliar functions in the AutoIt help file also helps.

#include <Misc.au3>
#include <Array.au3>

; The array holding the mouse points [10][2] holds ten x and y coordinates. Change 10
; to the number you want to have in the array. 

; Press SHIFT key to display array.
; Press LEFT MOUSE BUTTON + ALT key to add mouse position coordinates to array.
; Press ESC key to close script.

Local $aMPts[10][2] = [[0, 1],[10, 11],[20, 21],[30, 31]] ; Some coordinates entered here.

Local $aMPos, $iNum = 4
While 1
        Case _IsPressed("1B") ; Esc key
        Case _IsPressed("01") And _IsPressed("12") ; Left mouse button + Alt key
            Do ; Avoids multiple key presses
                Sleep(10) ; Slows down CPU Usage
            Until Not _IsPressed("01") ; Left mouse button goes up
            $aMPos = MouseGetPos() ; Get mouse position
            If $iNum >= UBound($aMPts) Then ; If array is full, make room at top, re-write array.
                For $i = 0 To UBound($aMPts) - 2
                    $aMPts[$i][0] = $aMPts[$i + 1][0] ;
                    $aMPts[$i][1] = $aMPts[$i + 1][1]
                $iNum = UBound($aMPts) - 1 ; Last index of the array
            $aMPts[$iNum][0] = $aMPos[0] ; Write X coordinate of mouse position to array
            $aMPts[$iNum][1] = $aMPos[1] ; Write Y coordinate of mouse position to array
            $iNum += 1 ; Increment index of the array
        Case _IsPressed("10") ; SHIFT key
    Sleep(10) ; Slows down CPU Usage within loop
Edited by Malkey

Share this post

Link to post
Share on other sites

Thank you Malkey. There is a lot in there to help me. Need to study it for a little bit though.

Share this post

Link to post
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
Sign in to follow this