Jump to content

How to check by putting a function that returns 2 elements into an array


aeun01
 Share

Recommended Posts


 

hello
I'm making a macro that stores and finds a value for a pixel based on the mouse position.
However, I want to load several values at once and compare them in two-dimensional units ex) Pixel size 30x20
I'm testing on a one-dimensional array. By the way, pixelgetcolor returns two x and y values as one value and is stored in an array, but vice versa.
Since pixelsearch returns one value as two x and y values, if you put it in an array and print it out
It only comes out as {array} , so I can't tell if I coded it correctly. How can I see that value as an x,y value?

#RequireAdmin
#include <MsgBoxConstants.au3>
#include <Array.au3>

HotKeySet("{F6}","exit1")

Func exit1()
    Exit
EndFunc

Local $Color
Global $Mouse_Position
Global $array1[20]
Global $array2[20]

$Mouse_Position = MouseGetPos()
$Color = PixelGetColor($Mouse_Position[0],$Mouse_Position[1])

MsgBox($MB_SYSTEMMODAL,"", " " & $Mouse_Position[0] & "," & $Mouse_Position[1] )

Local $i = 0

    For $y = $Mouse_Position[1] To $Mouse_Position[1]+19
        $Color = PixelGetColor($Mouse_Position[0],$y)
        $array1[$i] = $Color
        $i = $i + 1
    Next

_ArrayDisplay($array1, "arr1")

Sleep(300)
    Global $xy[20]

For $k = 0 To 10
    $xy[$k] = PixelSearch(0, 0, 1920, 1080, $array1[$k], 0 )
    MsgBox($MB_SYSTEMMODAL, "", "X, Y : " & $xy[$k])
    _ArrayDisplay($xy, "xy")
Next

#cs

If Not @error Then
       MouseMove($Mouse_Position2[0],$Mouse_Position2[1])
EndIf

#ce
Edited by Jos
Please use standard fonts and post code in a codeblock <>
Link to comment
Share on other sites

Your loop should look like this :

Global $xy[20][2], $aTmp

For $k = 0 To 19
  $aTmp = PixelSearch(0, 0, 1920, 1080, $array1[$k])
  ;MsgBox($MB_SYSTEMMODAL, "", "X, Y : " & $aTmp[0] & "/" & $aTmp[1])
  $xy[$k][0] = $aTmp[0]
  $xy[$k][1] = $aTmp[1]
Next

_ArrayDisplay($xy, "xy")

But remember, it may take a long time to complete if you are on Win10 +.  You should consider using my Screen Scraping UDF  (see my signature).

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...