Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 15:34

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



bluestack and imagesearch

Discussion on bluestack and imagesearch within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Nov 2007
Posts: 18
Received Thanks: 0
bluestack and imagesearch

i cant get bluestack and imagesearch work please help


Global $MainScreenStart = @ScriptDir & "\Images\MainScreenStart.bmp"
_CaptureRegion()
Local $collx, $colly, $i = 0
If _ImageSearch($MainScreenStart, 1, $collx, $colly, 20) Then
SetLog("~~~~ ImageSearch Working~~~~")
EndIf




Func _CaptureRegion($iLeft = 0, $iTop = 0, $iRight = 900, $iBottom = 750, $ReturnBMP = False)
_GDIPlus_BitmapDispose($hBitmap)
_WinAPI_DeleteObject($hHBitmap)
Global $iW = Number($iRight) - Number($iLeft), $iH = Number($iBottom) - Number($iTop)
Local $hDC_Capture = _WinAPI_GetWindowDC(ControlGetHandle("BlueStacks App Player", "", "[CLASS:BlueStacksApp; INSTANCE:1]"))
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC_Capture)
$hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Capture, $iW, $iH)
Local $hObjectOld = _WinAPI_SelectObject($hMemDC, $hHBitmap)

DllCall("user32.dll", "int", "PrintWindow", "hwnd", $HWnD, "handle", $hMemDC, "int", 0)
_WinAPI_SelectObject($hMemDC, $hHBitmap)
_WinAPI_BitBlt($hMemDC, 0, 0, $iW, $iH, $hDC_Capture, $iLeft, $iTop, 0x00CC0020)

Global $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap)
_WinAPI_DeleteDC($hMemDC)
_WinAPI_SelectObject($hMemDC, $hObjectOld)
_WinAPI_ReleaseDC($HWnD, $hDC_Capture)
EndFunc ;==>_CaptureRegion

Func _ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $Tolerance)
Return _ImageSearchArea($findImage, $resultPosition, 0, 0, 840, 720, $x, $y, $Tolerance)
EndFunc ;==>_ImageSearch

Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $Tolerance)
Global $HBMP = $hHBitmap

$HBMP = 0
$x1 += $BSPos[0]
$y1 += $BSPos[1]
$right += $BSPos[0]
$bottom += $BSPos[1]

;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)

If IsString($findImage) Then
If $Tolerance > 0 Then $findImage = "*" & $Tolerance & " " & $findImage
If $HBMP = 0 Then
$result = DllCall($pImageLib, "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
Else
$result = DllCall($pImageLib, "str", "ImageSearchEx", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage, "ptr", $HBMP)
EndIf
Else
$result = DllCall($pImageLib, "str", "ImageSearchExt", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "int", $Tolerance, "ptr", $findImage, "ptr", $HBMP)
EndIf
If @error Then _logErrorDLLCall($pImageLib, @error)

; If error exit
If IsArray($result) Then
If $result[0] = "0" Then Return 0
Else
SetLog("Error: Image Search not working...")
Return 1
EndIf

SetLog("Error: Image Search not working...")
; Otherwise get the x,y location of the match and the size of the image to
; compute the centre of search
$array = StringSplit($result[0], "|")
If (UBound($array) >= 4) Then
$x = Int(Number($array[2]))
$y = Int(Number($array[3]))
If $resultPosition = 1 Then
$x = $x + Int(Number($array[4]) / 2)
$y = $y + Int(Number($array[5]) / 2)
EndIf

Return 1
EndIf
EndFunc ;==>_ImageSearchArea
lioncool is offline  
Old 04/07/2016, 02:38   #2
 
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 166
Don't know where u get that code with lots of errors but u only need this...

elmarcia is offline  
Thanks
1 User
Old 04/08/2016, 09:53   #3
 
elite*gold: 0
Join Date: Nov 2007
Posts: 18
Received Thanks: 0
got it work again thanks elmarcia
lioncool is offline  
Reply


Similar Threads Similar Threads
bluestack whatsapp
05/07/2015 - Technical Support - 0 Replies
hey ich habe ein problem ich wollte mir eben whatsapp auf mein laptop ziehen jedoch funktioniert das nicht ich habe mir bluestack runtergeladen funktioniert einwandfrei jedoch wenn ich dann auf whatsapp installieren klicke kommt folgender fehler . http://i.epvpimg.com/qdsbf.png kann mir da evt jemand helfen ?
Bluestack in VirtualBox
07/24/2014 - Technical Support - 2 Replies
Hey ho, ich habn Problem... Und zwar hab ich ne virtuelle Box aufm pc installiert, in der Bluestacks läuft. Ich hab die gefixxte Bluestack Setup benutzt, damit Bluestack in der virtuellen Box läuft. Leider wenn ich dort Instagram installieren möchte, bekomme ich eine Fehlermeldung, dass keine Grafikkarte vorhanden ist. ( andere Apps funktionieren problemlos ) Gibt es eine Möglichkeit, der VirtualBox eine Grafikkarte oder ähnliches zu zuweisen? Danke schon einmal für eure Hilfe :)
Bluestack Plague inc.
11/14/2013 - General Gaming Discussion - 0 Replies
Hey Leute! Ich sehe ganz viele videos auf Youtube die mein lieblings Spiel "Plague inc." in Bluestack zocken! Leider kann ich die app dort nicht finden. Gibt es da möglichkeiten das game über Bluestack zu Zocken ? Grüße Peter
bluestack
11/07/2013 - Technical Support - 0 Replies
failed to install kriege ich als... ja ich habe gegoggelt habe die files gelöscht und regedit einegfügt... nix gliche fehler



All times are GMT +2. The time now is 15:34.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.