aa2zz6 Posted August 28, 2015 Posted August 28, 2015 I was playing around with this piece of code and the idea was to minimize the amount of text. I tried adding two variables with different images into one function. This unfortunately didn't work. I was hoping the script would look for which ever image appeared first and then apply a mouse click at location x,y. I thought that applying either a "comma", "Or", and "And" between the variable would attempt a search for each one. Please feel free to share if anyone has any ideas.$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA,$hImageB)Full Code<>test() Func test() #include <ImageSearch.au3> #include <GDIPlus.au3> $icon1 = @ScriptDir & "\Image\Icon1.png" $icon2 = @ScriptDir & "\Image\Icon2.png" _GDIPlus_Startup() $hImageA = _GDIPlus_ImageLoadFromFile($icon1) $hImageB = _GDIPlus_ImageLoadFromFile($icon2) $hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA,$hImageB) $x = 0 $y = 0 $result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) If $result > 0 Then MouseClick($MOUSE_CLICK_PRIMARY, $x, $y, 1) Sleep(1000) EndIf EndFunc ;==>test
kaisies Posted August 28, 2015 Posted August 28, 2015 _GDIPlus_BitmapCreateHBITMAPFromBitmap() Doesn't work that way. See the documentation. Second Arg is: [optional] Color object that specifies the background color. Nothing to do with a bitmap. Also, ImageSearch doesn't need a handle, just an actual bitmap. It might work with PNG's, I'm not honestly sure. Why not use an array for your bitmaps? test() Func test() #include <ImageSearch.au3> Local $aIcons[2], $i $aIcons[0] = @ScriptDir & "\Image\Icon1.png" ;again, may have to be BMP's here. $aIcons[1] = @ScriptDir & "\Image\Icon2.png" $x = 0 $y = 0 For $i = 0 to UBound($aIcons) - 1 $result = _ImageSearch($aIcons[$i], 1, $x, $y, 20, 0) If $result > 0 Then MouseClick($MOUSE_CLICK_PRIMARY, $x, $y, 1) ExitLoop Sleep(1000) EndIf Next EndFunc ;==>test
aa2zz6 Posted August 31, 2015 Author Posted August 31, 2015 Thanks kaisies, I didn't think to use an array for multiple picture searches.
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