Jump to content

How do i use pixel search?


Recommended Posts

How do i use pixel search???, the autoit help file is not explaining it well, this is the code autoit help was saying
PixelSearch ( left, top, right, bottom, color [, shade-variation [, step [, hwnd]]] )
and now I'm really confused what that is, left top right bottom? i don't understand, but i understand the colour,its like 0xFF0000(which is pure red) so can someone please help me?
Link to comment
Share on other sites

How do i use pixel search???, the autoit help file is not explaining it well, this is the code autoit help was saying

PixelSearch ( left, top, right, bottom, color [, shade-variation [, step [, hwnd]]] )
and now I'm really confused what that is, left top right bottom? i don't understand, but i understand the colour,its like 0xFF0000(which is pure red) so can someone please help me?

I know that left is a coordinate of a rectangle and same for the others, but i just don't get it.
Link to comment
Share on other sites

say you want to search an area of your screen from the top left corner, 50 pixels across and 50 pixels down for red.

$aResult = PixelSearch(0,0,50,50,0xFF0000)

Returns an array of coroordinates to the pixel if it finds one.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Okay so is this like this?

$frozen = PixelSearch(0, 326, 0, 317, 0xFF0000)
I am so confused right now

you said that 0, 0 is the X coordinates and 50, 50 is the Y Coordinates.

I just dont get it.

Please explain it better so i can understand, I am really confused right now.

Link to comment
Share on other sites

  • Moderators

Left = the x top left of the rectangle to search starting position

Top = the y top left of the rectangle to search starting position

Right = the x bottom right of the rectangle to search starting position

Bottom = the y bottom right of the rectangle to search starting position

Example image:

http://www.autoitscript.com/forum/index.php?app=core&module=attach&section=attach&attach_rel_module=post&attach_id=11670

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

If you run this example, it should help you understand the screen coordinate system and the window or client coordinate system being used.

Move the cursor, and try to understand why the "x" and "y" values, (coordinates), change the way they do change.

Press Esc to exit.

#include <WinAPI.au3>

Opt("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client
HotKeySet("{ESC}", "Terminate")

Local $exit = 1

While $exit
    Sleep(10)
    TtColXY()
WEnd

; TtColXY() Tooltip shows colour, and cursor position relative to screen and window.
Func TtColXY()
    $aPos = MouseGetPos()
    Local $tPosS = _WinAPI_GetMousePos() ; similar to MouseGetPos() ;Screen mouse position
    $hHwnd = _WinAPI_WindowFromPoint($tPosS)
    Local $tPosC = _WinAPI_GetMousePos(True, $hHwnd)
    $sColor = "0x" & Hex(PixelGetColor(DllStructGetData($tPosS, "X"), DllStructGetData($tPosS, "Y")), 6)
    $iPosX = ($aPos[0] - 100) * ($aPos[0] > @DesktopWidth * 0.90) + ($aPos[0] <= @DesktopWidth * 0.90) * ($aPos[0] + 3)
    $iPosY = ($aPos[1] - 30) * ($aPos[1] > @DesktopHeight * 0.96) + ($aPos[1] <= @DesktopHeight * 0.96) * ($aPos[1] + 3)
    ToolTip("Color is: " & $sColor & @CRLF & "Screen: X: " & DllStructGetData($tPosS, "X") & " Y: " & DllStructGetData($tPosS, "Y") & @CRLF _
         & "Client: X: " & DllStructGetData($tPosC, "X") & " Y: " & DllStructGetData($tPosC, "Y"), $iPosX, $iPosY)
    Return
EndFunc ;==>TtColXY

Func Terminate()
    $exit = 0
EndFunc ;==>Terminate
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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