Image search help? - Printable Version +- The Bytecode Club - Reverse Engineering Forum (https://the.bytecode.club) +-- Forum: Lobby (https://the.bytecode.club/forumdisplay.php?fid=1) +--- Forum: Game Cheating, Botting & Reverse Engineering (https://the.bytecode.club/forumdisplay.php?fid=97) +--- Thread: Image search help? (/showthread.php?tid=1022) |
Image search help? - knowjack - 02-24-2015 I'm trying to install a Smashed TH check into the algorithmTH.au3 module. Been staring at the other modules that call the _ImageSearch function in ImageSearch.au3 and can't get a valid response or coordinates from _ImageSearch? After staring at 3-4 dozen images of smashed TH, it seems they all look same regardless of the TH level. Have tried several sizes/shapes of images cut directly from saved attack images. They are stored in BMP, and the 1 pixel tall version is same size as the TH check image. But I NEVER find a match even with 20% tolerance. I'm ready to give up. I am sure its some kind of noob mistake, can anyone help? Code: Func CheckSmashedTownhall() RE: Image search help? - Snarg - 02-24-2015 I don't think you are factoring in the offset with your X/Y coords. Try the script below. It will get the coords and copy them to the clipboard. Change the first $Title line to match the title of your BlueStacks. The F1 key will get the coords, taking into account the offset, of wherever you click. Code: #include <Misc.au3> RE: Image search help? - knowjack - 02-24-2015 Thanks for the reply! Sorry to be dense, I'm not following why I need offsets? Doesn't existing _CaptureRegion in _CaptureRegion.au3 automatically get BS offsets, and load global variable $hHBitmap with the image to be searched? I've been searching autoitscript forum as well, and imagesearch is still baffling me. Thanks Again! RE: Image search help? - Snarg - 02-24-2015 Because of the border around the window (title at the top, and the thin borders on the sides and bottom) there is a certain amount of X/Y offset you need, otherwise your coordinates will be incorrect. getBSPos() is supposed to get the correct values for the play screen. I don't know how you are using the function you posted. Are you using it stand-alone, or within a script? If you use just _CaptureRegion() it won't get the offset. It will call getBSPos(), but getBSPos() will be missing the $Title variable. The script I posted above ensures all the values needed are filled out. Edit: What size is your BlueStacks window? Have you changed it with the .reg file? If not, then the first line in _CaptureRegion() is screwing you up: Code: Func _CaptureRegion($iLeft = 0, $iTop = 0, $iRight = 860, $iBottom = 720, $ReturnBMP = False) See the hard-coded coords? If your window is not that size, it won't work. RE: Image search help? - knowjack - 02-24-2015 Thanks Snarg! Appreciate your continued effort to help. I'm using the function posted above just like checkTownHall.au3, except instead of searching for 5 different images, using only 1? All I do is look for successful return value and the x,y positions in the function call, like this: Code: If CheckSmashedTownhall() = 1 Then ; check to see if TH is smashed. The reason I used _CaptureRegion() like checkTownHall() function; is that it appears to get the BS offsets and loads $hHBitmap (showing only the non-background code) Code: getBSPos() Unless I am reading image search wrong, _ImageSearch calls _ImageSearchArea, and it checks to see if $hHBitmap has an image loaded from _captureRegion(), then executes DLLCALL to search for the image passed to it?? I was really hoping to reuse the existing image capture/search functions as the initially seemed pretty straight forward. But after beating my head against the wall on this off/on for a couple days, I'm just getting more confused. RE: Image search help? - Henk500 - 02-25-2015 (02-24-2015, 07:17 PM)knowjack Wrote: Thanks Snarg! Appreciate your continued effort to help. try writing the hBitmap to an .bmp _ScreenCapture_SaveImage("C:\COC-Bot-master\images\GdiPlus_Screen.bmp", $hHBitmap) i have some weird screenshots...Only the captureregion background mode option works for me. RE: Image search help? - knowjack - 02-25-2015 Thanks for the suggestion Henk500! Added the code, checked a dozen images and they all look normal? RE: Image search help? - Snarg - 02-25-2015 Any chance of posting all of your code? It's hard to debug a snippet. RE: Image search help? - terminus - 02-25-2015 jack have you given up? |