lxsg Posted June 29, 2011 Share Posted June 29, 2011 I'm getting inconsistent results from PixelSearch (PixelCoordMode left at default value of 1) where it would randomly fail to find pixels even though it's on screen. Any idea what could I have been doing wrong? (It's for a game bot, where the game is running in a windowed mode.) Code: (Console is a wrapper for ConsoleWrite) $pos = PixelSearch(0, 0, 1040, 640, 0xDD0000) If (Not @error) Then Console("Critical: " & $pos[0] & ", " & $pos[1]) EndIf $pos = PixelSearch(0, 0, 1040, 640, 0xFF3311) If (Not @error) Then Console("Damage: " & $pos[0] & ", " & $pos[1]) EndIf $pos = PixelSearch(0, 0, 1040, 640, 0x00FF00) If (Not @error) Then Console("Green: " & $pos[0] & ", " & $pos[1]) EndIf Console("240START") $pos = PixelSearch(0, 240, 1040, 640, 0xDD0000) If (Not @error) Then Console("Critical240: " & $pos[0] & ", " & $pos[1]) EndIf $pos = PixelSearch(0, 240, 1040, 640, 0xFF3311) If (Not @error) Then Console("Damage240: " & $pos[0] & ", " & $pos[1]) EndIf $pos = PixelSearch(0, 240, 1040, 640, 0x00FF00) If (Not @error) Then Console("Green240: " & $pos[0] & ", " & $pos[1]) EndIf Console("240END") $pos = PixelSearch(0, 1, 1040, 640, 0xDD0000) If (Not @error) Then Console("Critical1: " & $pos[0] & ", " & $pos[1]) EndIf $pos = PixelSearch(0, 1, 1040, 640, 0xFF3311) If (Not @error) Then Console("Damage1: " & $pos[0] & ", " & $pos[1]) EndIf $pos = PixelSearch(0, 1, 1040, 640, 0x00FF00) If (Not @error) Then Console("Green1: " & $pos[0] & ", " & $pos[1]) EndIf Output: [10:58:57] Critical: 406, 402 [10:58:57] 240START [10:58:57] 240END [10:58:57] Critical1: 413, 398 Link to comment Share on other sites More sharing options...
Realm Posted June 29, 2011 Share Posted June 29, 2011 Please read the Rules before posting My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
lxsg Posted June 29, 2011 Author Share Posted June 29, 2011 I've read the rules, but what I'm asking here is whether there's any possible causes that could result in inconsistent return values from PixelSearch. I mentioned that it was used for a game bot solely to provide more context to anyone reading this thread, since this technical issue could have occurred in many other situations as well (think: screen-scraping an ancient enterprise desktop application). Link to comment Share on other sites More sharing options...
Realm Posted June 29, 2011 Share Posted June 29, 2011 excerpt from the Rules 'Do not discuss automating games here'I don't write the rules...but if you do a quick search on the word game....you will see how every single post ended...mostly banned users.I am offering a peaceful suggestion, not to further this post since you already mention your automating a game.Its up to you what you do, but anyone that mentions game, or helps someone that mentioned game here, generally finds themselves on the short end of the stick fast!I'm not trying to be rude, or obnoxious to you, just trying to give you a heads up, before you find yourself suspended or banned from the forums.Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
lxsg Posted June 29, 2011 Author Share Posted June 29, 2011 (edited) I understand where you're coming from, but I must once again emphasize that the technical issue I'm facing is not limited to automation of games - it's the inconsistent values PixelSearch() return that is giving me a big headache here. I'm hoping that someone who has encountered and dealt with a similar issue while using PixelSearch to offer some advice here. I have no method of telling whether the issue is caused by: 1. A faulty implementation of PixelSearch 2. My code is logically screwed (I went through the code a dozen times and see nothing wrong; need another pair of eyes to look at it) 3. PixelSearch doesn't work well on DirectX applications One thing to add: I have tried looping through the pixels using PixelGetColor but it's really, really slow. Edited June 29, 2011 by lxsg Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 29, 2011 Share Posted June 29, 2011 @lxsg Rules are rules. Drop the subject or you will be "dropped" from the forum. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Recommended Posts