Sign in to follow this  
Followers 0
Neato

Problem with PixelSearch

9 posts in this topic

Hi

I'm trying to check for a pixel. If it does not exsist then press the F2 button. But it seems it's pressing the F2 button all the time even when the pixel is visible. This is my code:

Have tried this:

$P1X = 953

$P1Y = 26

$P2X = 953

$P2Y = 26

$Color=4866361

While 1

sleep (500)

PixelSearch( $P1X, $P1Y, $P2X, $P2Y, $Color)

If @Error Then

Sleep(5000)

Send("{F2}")

sleep(5000)

EndIf

WEnd

And this:

While 1

Do

sleep (200)

PixelSearch( $P1X, $P1Y, $P2X, $P2Y, $Color)

Until @error

Sleep(5000)

Send("{F2}")

WEnd

Thank you.

Neato.

Share this post


Link to post
Share on other sites

$P1X = 953

$P1Y = 26

$P2X = 953

$P2Y = 26

$Color=4866361

While 1

sleep (500)

PixelSearch( $P1X, $P1Y, $P2X, $P2Y, $Color)

If @Error = 1 Then

Sleep(5000)

Send("{F2}")

sleep(5000)

EndIf

WEnd

While 1

Do

sleep (200)

PixelSearch( $P1X, $P1Y, $P2X, $P2Y, $Color)

Until @error = 1

Sleep(5000)

Send("{F2}")

WEnd


My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites

$P1X = 953

$P1Y = 26

$P2X = 953

$P2Y = 26

$Color=4866361

While 1

sleep (500)

PixelSearch( $P1X, $P1Y, $P2X, $P2Y, $Color)

If @Error = 1 Then

Sleep(5000)

Send("{F2}")

sleep(5000)

EndIf

WEnd

While 1

Do

sleep (200)

PixelSearch( $P1X, $P1Y, $P2X, $P2Y, $Color)

Until @error = 1

Sleep(5000)

Send("{F2}")

WEnd

<{POST_SNAPBACK}>

Sorry, but that didn't help. :idiot:

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Sure you have the pixel color correct? There have been changes fro BGR to RGB and stuff... double check the AU3Spy. Also, check your PixelCoordMode, also try just using PixelGetColor instead of pixelsearch...

Lar

<{POST_SNAPBACK}>

I have tried PixelGetColor and using a script you made to get the color of the pixel. And also did some research my self as you can see in the code. The game is in fullscreen.

This is what you have been made:

HotKeySet("+!d","logpixel") ; SHIFT+ALT+d

Opt("MouseCoordMode",0)

Opt("PixelCoordMode",0)

While 1

Sleep(10)

Wend

Func logpixel()

$xy = MouseGetPos()

If @error Then Return

$pix = PixelGetColor($xy[0],$xy[1])

FileWriteLine("pixellog.txt",$xy[0] & "," & $xy[1] & " = " & $pix)

EndFunc

The code I have made is exampel from guys in this forum.

The attachment you can see what I want. It is that little gun I want to check if it is there.

This is what I have tried in my code:

Common:

;

; AutoIt Version: 3.0

; Language: English

; Platform: Win9x/NT

; Author: A.N.Other (myemail@nowhere.com)

;

; Script Function:

; Template AutoIt script.

;

;AdlibEnable("myadlib")

;Opt("WinDetectHiddenText", 1)

Opt("TrayIconDebug", 1)

;Opt("TrayIconHide", 1) ;0=show, 1=hide tray icon

HotKeySet("+!d", "Terminate") ;Shift-Alt-d

;set resolution

$res = 0

Do

$res = InputBox("Choose your IN-GAME resolution:", "1 = 640x480" & @CR & "2 = 800x600" & @CR & "3 = 1024x768" & @CR & "4 = 1152x864" & @CR & "5 = 1280x960" & @CR & "6 = 1280x1024" & @CR & "7 = 1600x1200" & @CR & @CR & @CR, "", "", 200, 200)

If $res = 1 Then

$P1X = 940

$P1Y = 19

ElseIf $res = 2 Then

$xx = 400

$yy = 303

ElseIf $res = 3 Then

$xx = 511

$yy = 387

ElseIf $res = 4 Then

$xx = 575

$yy = 435

ElseIf $res = 5 Then

$xx = 640

$yy = 485

ElseIf $res = 6 Then

$P1X = 955

$P1Y = 25

$P2X = 955

$P2Y = 25

$Color=0x423C39

; $Color=3750978

ElseIf $res = 7 Then

$xx = 798

$yy = 605

EndIf

Until $res = 1 or $res = 2 or $res = 3 or $res = 4 or $res = 5 or $res = 6 or $res = 7

Sleep(10000)

;TrayTip("", "GO!", 1)

$Color=PixelgetColor($P1X,$P1Y)

MsgBox(4096, "Test1", $Color)

and tried this

While 1

sleep (200)

$Coord=PixelSearch( $P1X, $P1Y, $P2X, $P2Y, $Color)

If @Error = 1 Then

Sleep(5000)

Send("{F2}")

sleep(5000)

EndIf

WEnd

And this:

Do

While @Error

sleep (200)

PixelSearch( $P1X, $P1Y, $P2X, $P2Y, $Color)

WEnd

Sleep(5000)

Send("{F2}")

Until @Error = 1

And this:

While 1

Do

sleep (200)

PixelSearch( $P1X, $P1Y, $P2X, $P2Y, $Color)

If Not @Error Then ; To see if the script can see

MouseMove($P1X,$P1Y) ; color at the mouse position.

Sleep(2000) ; The mouse is moving as expected.

MouseMove($P1X,$P1Y+200) ; But the icon disapears when the first

EndIf ; MouseMove haven't reach the

; position :idiot:

Until @error = 1

Sleep(5000)

Send("{F2}")

WEnd

Common:

Func Terminate()

Exit 0

EndFunc

Pic3.bmp

Edited by Neato

Share this post


Link to post
Share on other sites

Hi

Now I have tried this:

HotKeySet("+!d", "Terminate") ;Shift-Alt-d

; ----------------------------------------------------------------------------

; Script Start

; ----------------------------------------------------------------------------

$P1X = 955

$P1Y = 25

$P2X = 955

$P2Y = 25

;$Color=0x393C42

Sleep(10000)

$Result=0

MouseMove($P1X,$P1Y,0)

Sleep(2000)

$Color=PixelGetColor($P1X,$P1Y)

$Color=Hex($Color,6)

$file = FileOpen("test.txt", 1)

FileWriteLine($file, $Color)

Do

Sleep(200)

PixelSearch($P1X,$P1Y,$P1X,$P1Y,$Color)

If @Error = 1 Then

FileWriteLine($file, "Pixel not found")

Else

FileWriteLine($file, "Pixel found")

EndIf

Until $Result = 1

Func Terminate()

FileClose($file)

Exit 0

EndFunc

; ----------------------------------------------------------------------------

; Script Stops

; ----------------------------------------------------------------------------

And this is result in the file:

394142

Pixel not found

Pixel not found

Pixel not found

Pixel not found

Pixel not found

Pixel not found

393C42

Pixel not found

Pixel not found

394142

Pixel not found

Pixel not found

Pixel not found

Pixel not found

Anyone who has an idea what's going on?

Share this post


Link to post
Share on other sites

Anyone who has an idea what's going on?

<{POST_SNAPBACK}>

Try: $Color = "0x" & Hex($Color, 6)

Phillip

Share this post


Link to post
Share on other sites

Doh, yes that is true. :D

Ok, now it founds the pixel sometimes. This is the result:

0x393C42

Pixel not found!

pixel found!

pixel found!

Pixel not found!

pixel found!

pixel found!

pixel found!

pixel found!

pixel found!

pixel found!

That is strange I think. :idiot: Is there something I'm not checking for? Is there something with the colors?

This is the script i'm using.

; ----------------------------------------------------------------------------

; Script Start

; ----------------------------------------------------------------------------

$P1X = 955

$P1Y = 25

$P2X = 955

$P2Y = 25

;$Color=0x393C42

Sleep(10000)

$Result=0

MouseMove($P1X,$P1Y,0)

Sleep(2000)

$Color=PixelGetColor($P1X,$P1Y)

$Color="0x"&Hex($Color,6)

$file = FileOpen("test.txt", 1)

FileWriteLine($file, $Color)

Do

Sleep(200)

PixelSearch($P1X,$P1Y,$P1X,$P1Y,$Color)

If @Error = 1 Then

FileWriteLine($file,"Pixel not found!")

Else

FileWriteLine($file,"pixel found!")

EndIf

$Result = $Result + 1

Sleep(1000)

Until $Result = 10

FileClose($file)

Exit

Func Terminate()

FileClose($file)

Exit 0

EndFunc

; ----------------------------------------------------------------------------

; Script Stops

; ----------------------------------------------------------------------------

Share this post


Link to post
Share on other sites

Doh, yes that is true. :idiot:

Ok, now it founds the pixel sometimes. This is the result:

0x393C42

Pixel not found!

pixel found!

pixel found!

I pasted and ran your script and it always returns "pixel found!", unless I cause the color at the test location to change. I even changed the loop to 20 and got the same results. Perhaps the screen colors are changing slightly and you need to apply the "shade-variation" option.

I am using version 3.0.103.129 which was released today. Yesterday I was using v3.0.103.128.


Phillip

Share this post


Link to post
Share on other sites

Yes, it could be true, cause the screen does sligtly moves a little bit in a squard to give the impression that you have floating in space.

I don't know the Shade-variation.

I try something else and this is the code:

HotKeySet("+!d", "Terminate") ;Shift-Alt-d

; ----------------------------------------------------------------------------

; Script Start

; ----------------------------------------------------------------------------

$P1X = 955

$P1Y = 25

$P2X = 955

$P2Y = 25

;$Color=0x393C42

Sleep(10000)

$Result=0

MouseMove($P1X,$P1Y,0)

$file = FileOpen("test.txt", 1)

Sleep(2000)

Do

Sleep(200)

$Color=PixelGetColor($P1X,$P1Y)

$Color="0x"&Hex($Color,6)

$PixRes=PixelSearch($P1X,$P1Y,$P1X,$P1Y,$Color)

If $PixRes = 1 Then

FileWriteLine($file, $Color)

FileWriteLine($file,"Pixel not found!")

Else

FileWriteLine($file, $Color)

FileWriteLine($file,"pixel found!")

EndIf

$Result = $Result + 1

Sleep(1000)

Until $Result = 10

FileClose($file)

Exit

Func Terminate()

FileClose($file)

Exit 0

EndFunc

; ----------------------------------------------------------------------------

; Script Stops

; ----------------------------------------------------------------------------

and this is the result:

0x394142

pixel found!

0x393C42

pixel found!

0x394142

pixel found!

0x311808

Pixel not found!

0x394142

pixel found!

0x394142

pixel found!

0x394142

pixel found!

0x394142

pixel found!

0x000000

Pixel not found!

0x004D9C

pixel found!

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  
Followers 0