Hello,
Just a quick question. I will create an array in a text file to use in AHK to move the mouse until it finds the desired object.
Im just wondering if i can make one file or if i need two. one for x and one for y
Or can i just do
x1, y1
x2, y2
and so on.
Also if there an easier way to save both coordinates in a single variable instead of using two like ive been doing?
Thanks in advance
Array for mouse coordinates.
-
- Posts: 6
- Joined: 09 May 2020, 22:56
Re: Array for mouse coordinates.
If you're looking for pixels or images, you can do that without moving the mouse at all. See documentation for PixelGetColor and ImageSearch. I'm not sure what you mean about making files.
-
- Posts: 6
- Joined: 09 May 2020, 22:56
Re: Array for mouse coordinates.
depending on whats under the mouse a description shows on the right side so i will be searching on the right side of the screen that changes as the mouse moves.
I want to move the mouse in a rotating outwards square pattern starting from the center of the screen. After reading about arrays and how to implement them, i thought it made sense to create a text file with my desired mouse coordinates one after the other.
I want to move the mouse in a rotating outwards square pattern starting from the center of the screen. After reading about arrays and how to implement them, i thought it made sense to create a text file with my desired mouse coordinates one after the other.
Re: Array for mouse coordinates.
Sure, you could use a text file, an AHK array in a script, or a formula if the coordinates can be represented by a systematic pattern.
https://www.autohotkey.com/docs/commands/LoopReadFile.htm
https://www.autohotkey.com/docs/commands/LoopReadFile.htm
-
- Posts: 6
- Joined: 09 May 2020, 22:56
Re: Array for mouse coordinates.
yes exactly, but my question remains.
can i put both x and y coordinates on the same line? everytime ive used mouse coordinates ive stored the x and y values in different variables but i dont like that. it also means i need an x array and y array.
can i put both x and y coordinates on the same line? everytime ive used mouse coordinates ive stored the x and y values in different variables but i dont like that. it also means i need an x array and y array.
Re: Array for mouse coordinates.
Sure. Why not?
Re: Array for mouse coordinates.
how about saving each element as an object with x and y properties? I do this often:
Code: Select all
allCoords := [{x:200, y:100}, {x:1000, y:800}]
for _, obj in allCoords {
msgbox, % obj.x " and " obj.y
}
-
- Posts: 6
- Joined: 09 May 2020, 22:56
Re: Array for mouse coordinates.
This is perfect thank you. i will implement thisChunjee wrote: ↑15 Sep 2020, 05:48how about saving each element as an object with x and y properties? I do this often:
Code: Select all
allCoords := [{x:200, y:100}, {x:1000, y:800}] for _, obj in allCoords { msgbox, % obj.x " and " obj.y }
Re: Array for mouse coordinates.
Incase needed; here is how to create objects and push them onto an array; in this case when an imagesearch successfully finds an x and y to add
Code: Select all
allCoords := []
ImageSearch, x, y, 100, 100, 900, 900, % A_ScriptDir "\imgage.png"
if (x) {
obj := {}
obj.x := x
obj.y := y
allCoords.push(obj)
}
Who is online
Users browsing this forum: Anput, DiegoSouto, mikeyww, Rohwedder, Sniperman, Swiftly9767 and 381 guests