Neato Posted December 18, 2004 Share Posted December 18, 2004 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. Link to comment Share on other sites More sharing options...
the_lord_mephy Posted December 18, 2004 Share Posted December 18, 2004 $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] Link to comment Share on other sites More sharing options...
Neato Posted December 19, 2004 Author Share Posted December 19, 2004 $P1X = 953$P1Y = 26$P2X = 953$P2Y = 26$Color=4866361While 1sleep (500) PixelSearch( $P1X, $P1Y, $P2X, $P2Y, $Color)If @Error = 1 ThenSleep(5000)Send("{F2}")sleep(5000)EndIf WEndWhile 1Dosleep (200)PixelSearch( $P1X, $P1Y, $P2X, $P2Y, $Color)Until @error = 1Sleep(5000)Send("{F2}")WEnd<{POST_SNAPBACK}>Sorry, but that didn't help. Link to comment Share on other sites More sharing options...
Neato Posted December 19, 2004 Author Share Posted December 19, 2004 (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+dOpt("MouseCoordMode",0)Opt("PixelCoordMode",0)While 1Sleep(10)WendFunc logpixel()$xy = MouseGetPos()If @error Then Return$pix = PixelGetColor($xy[0],$xy[1])FileWriteLine("pixellog.txt",$xy[0] & "," & $xy[1] & " = " & $pix)EndFuncThe 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 iconHotKeySet("+!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 thisWhile 1 sleep (200) $Coord=PixelSearch( $P1X, $P1Y, $P2X, $P2Y, $Color) If @Error = 1 Then Sleep(5000) Send("{F2}") sleep(5000) EndIf WEndAnd this:Do While @Error sleep (200) PixelSearch( $P1X, $P1Y, $P2X, $P2Y, $Color) WEnd Sleep(5000) Send("{F2}")Until @Error = 1And 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 Until @error = 1 Sleep(5000) Send("{F2}")WEndCommon:Func Terminate() Exit 0EndFuncPic3.bmp Edited December 19, 2004 by Neato Link to comment Share on other sites More sharing options...
Neato Posted December 19, 2004 Author Share Posted December 19, 2004 HiNow I have tried this:HotKeySet("+!d", "Terminate") ;Shift-Alt-d; ----------------------------------------------------------------------------; Script Start; ----------------------------------------------------------------------------$P1X = 955$P1Y = 25$P2X = 955$P2Y = 25;$Color=0x393C42Sleep(10000)$Result=0MouseMove($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") EndIfUntil $Result = 1Func Terminate() FileClose($file) Exit 0EndFunc; ----------------------------------------------------------------------------; Script Stops; ----------------------------------------------------------------------------And this is result in the file:394142Pixel not foundPixel not foundPixel not foundPixel not foundPixel not foundPixel not found393C42Pixel not foundPixel not found394142Pixel not foundPixel not foundPixel not foundPixel not foundAnyone who has an idea what's going on? Link to comment Share on other sites More sharing options...
phillip123adams Posted December 19, 2004 Share Posted December 19, 2004 Anyone who has an idea what's going on?<{POST_SNAPBACK}>Try: $Color = "0x" & Hex($Color, 6) Phillip Link to comment Share on other sites More sharing options...
Neato Posted December 20, 2004 Author Share Posted December 20, 2004 Doh, yes that is true. Ok, now it founds the pixel sometimes. This is the result:0x393C42Pixel 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. 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=0x393C42Sleep(10000)$Result=0MouseMove($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 = 10FileClose($file)ExitFunc Terminate() FileClose($file) Exit 0EndFunc; ----------------------------------------------------------------------------; Script Stops; ---------------------------------------------------------------------------- Link to comment Share on other sites More sharing options...
phillip123adams Posted December 20, 2004 Share Posted December 20, 2004 Doh, yes that is true. Ok, now it founds the pixel sometimes. This is the result:0x393C42Pixel 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 Link to comment Share on other sites More sharing options...
Neato Posted December 21, 2004 Author Share Posted December 21, 2004 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=0x393C42Sleep(10000)$Result=0MouseMove($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 = 10FileClose($file)ExitFunc Terminate() FileClose($file) Exit 0EndFunc; ----------------------------------------------------------------------------; Script Stops; ----------------------------------------------------------------------------and this is the result:0x394142pixel found!0x393C42pixel found!0x394142pixel found!0x311808Pixel not found!0x394142pixel found!0x394142pixel found!0x394142pixel found!0x394142pixel found!0x000000Pixel not found!0x004D9Cpixel found! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now