Jump to content

PixelSearch and @errors


blublub
 Share

Recommended Posts

if i make a func like this

Func bla()
$om = PixelSearch(32,32,36,36,0x000000,1,1)
$po = PixelSearch(50,50,60,60,0x000000,1,1)
EndFunc

then when i will try to make a sentence 0=@error it will be true if the pixel was in the second square but how will i respond to the first pixel search so i coudl type diffrent comands for diffrent situations like

@error1=@error2

(@error1 i mean the check from the first one search)

and some like

if @error1=1 and @error2=0 then
blablabla

so how coudl i do this or what are the command to get acces to diffrent pixel searches ?

Edited by blublub
Link to comment
Share on other sites

Func bla()
$om = PixelSearch(32,32,36,36,0x000000,1,1)
$po = PixelSearch(50,50,60,60,0x000000,1,1)
EndFuncoÝ÷ Ù8b²+!£¨»
.Ör©+!­"ØbL¨º¯zÆ¢u¦è½â,Ê«r^éhÂ+-ç(uëh¡»Z{az·¬º[lÊ°j{ZºÚ"µÍ[ÈJ
BØØ[  ÌÍÙÜK   ÌÍÙÜ    ÌÍÛÛHH^[ÙXÚ
ÌÌÍÍKJB ÌÍÙÜHHÜ    ÌÍÜÈH^[ÙXÚ
L
L

KJB ÌÍÙÜHÜY    ÌÍÙÜHHHS    ÌÍÙÜH[ÑÈÛÛY][Â[Y[[oÝ÷ Ø è¶«Á¬­¡Ú0«H¶§*.j·°j{b¬jÇèZ0±«­¢+ÙÕ¹± ¤(ÀÌØí½´ôA¥á±MÉ  ÌÈ°ÌÈ°ÌØ°ÌØ°ÁàÀÀÀÀÀÀ°Ä°Ä¤(%ÉɽÈôÄQ¡¸(ÀÌØíÁ¼ôA¥á±MÉ  ÔÀ°ÔÀ°ØÀ°ØÀ°ÁàÀÀÀÀÀÀ°Ä°Ä¤(%ÉɽÈôÀQ¡¸(í¼M½µÑ¡¥¹(¹%(¹%)¹Õ¹

Edit: The second example should save you a bit of time as the second search is only done if the first one errors to 1.

I hope that helps,

JS

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

superb that is exacly what i needed !

ill use the first one cuz i need many options and diffrent sytuations

really thx

and a little question can i check 2 colors with 1 pixelsearch like red or blue is 0 and others are 1 and it has to be in 1 becouse it fast changes in time and i need to check it in the same time

to make a my question more simple ill give an example

i need something like this

$om = PixelSearch(32,32,36,36,0x000000 or 0xFFFFFF,1,1)

i know that colors dont match :whistle:

Edited by blublub
Link to comment
Share on other sites

I suggest you use his first function

$om = PixelSearch(32,32,36,36,0x000000,1,1)

$error1 = @error

$po = PixelSearch(50,50,60,60,0x000000,1,1)

$error2 = @error

If you chain tons of if's you make it hard for yourself (exspecially if you read your code 2 weeks later).

If you can avoid "if NOT @error then " then avoid it.

Link to comment
Share on other sites

superb that is exacly what i needed !

ill use the first one cuz i need many options and diffrent sytuations

really thx

and a little question can i check 2 colors with 1 pixelsearch like red or blue is 0 and others are 1 and it has to be in 1 becouse it fast changes in time and i need to check it in the same time

to make a my question more simple ill give an example

i need something like this

$om = PixelSearch(32,32,36,36,0x000000 or 0xFFFFFF,1,1)

i know that colors dont match :whistle:

I dont think it can search for multiple colors at the same time. I tried looking up a work around for that situation, and I didnt find any answers.

The reason why I had the second example is because based on your first example you wanted to only do something if the first one error'd out, and the second didnt. That is why it would be faster. If you have other options other If's could be built.

GL,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

  • Moderators

If you really want to complicate things, and you don't want to keep writing out the function (just the arrays)

Dim $xt[3] = ['', 32, 50], $yt[3] = ['', 32, 50], $xb[3] = ['', 36, 60]
Dim $yb[3] = ['', 36, 60], $iC[3] = ['', 0x000000, 0x000000]
$iPix = _PixelSearchMulti($xt, $yt, $xb, $yb, $iC, 1, 1)
If Not @error Then MsgBox(64, 'Info', 'Found at: ' & @CR & 'x: ' & $iPix[0] & @CR & 'y: ' & $iPix[1])

Func _PixelSearchMulti($xTop, $yTop, $xBottom, $yBottom, $nColor, $iShade = 0, $iStep = 1)
    If Not IsArray($xTop) Then SetError(1, 0, 0)
    Local $iPixFind
    For $iCC = 1 To UBound($xTop) - 1
        $iPixFind = PixelSearch($xTop[$iCC], $yTop[$iCC], $xBottom[$iCC], _
                $yBottom[$iCC], $nColor[$iCC], $iShade, $iStep)
        If Not @error Then Return $iPixFind
    Next
    Return SetError(2, 0, 0)
EndFunc
Note, all coords and colors must be an array. I was too lazy to code exceptions.

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

and a little question can i check 2 colors with 1 pixelsearch like red or blue is 0 and others are 1 and it has to be in 1 becouse it fast changes in time and i need to check it in the same time

Have you considered just using PixelGetColor? I noticed your example is a very small area and if just 1 pixel changes and you can test off of it then that command would be easier. Something like:

$Color = Hex(PixelGetColor(1, 1), 6)
If $Color = "FF0000" Then
    ConsoleWrite($Color & " found")
ElseIf $Color = "FFFF00" Then
    ConsoleWrite($Color & "found" & @CRLF)
Else
    ConsoleWrite("not found.  Current color:" & $Color & @CRLF)
EndIf

Kohr

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...