AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ImageSearch transparency confusion

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
dcurran
Guest





PostPosted: Sun Jan 31, 2010 2:30 pm    Post subject: ImageSearch transparency confusion Reply with quote

The basic idea of this program is to be able to do an ImageSearch on the cursor.

For some reason the transparency is not working for ImageSearch.

I have taken a screenshot of the cursor for arrow.png and then turned the background red so that I can search for the arrow on any background.

The problem is that I get an "Image Found" message only when the arrow is on the original background that I took the screenshot with, no other backgrounds match.

Does anyone know what I am doing wrong with ImageSearch? I have tried increasing the values of *n but that really does nothing.

The image I am searching for is:


ScreenCapture.ahk comes from http://www.autohotkey.com/forum/topic18146.html

The program I am using:
Code:
#Include ScreenCapture.ahk

CoordMode Mouse, Screen
CoordMode Pixel, Screen

Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Add, Picture, x35 h35 vPic, image.jpg
Gui, Add, Text, vMyText cLime, XXXXXXXXXXXXXXXXXXXX
SetTimer, UpdateOSD, 500
Gosub, UpdateOSD 
Gui, Show, x0 y400 NoActivate
return

UpdateOSD:
   MouseGetPos x, y
   x1 := x - 5
   x2 := x + 30
   y1 := y - 5
   y2 := y + 30
   rect = %x1%,%y1%,%x2%,%y2%
   CaptureScreen(rect,True, "image.jpg")
   GuiControl,, Pic, *w35 *h35 image.jpg
   ImageSearch px, py, 0, 0, A_ScreenWidth, A_ScreenHeight, *Trans0xFF0000 *n150 arrow.png ;try increasing the value of n
   if ErrorLevel = 2
      msg = No search performed
   else if ErrorLevel = 1
      msg = Image not found
   else
      msg = Image found
   GuiControl,, MyText, %msg%
return
Back to top
Ace Coder



Joined: 26 Oct 2009
Posts: 361

PostPosted: Sun Jan 31, 2010 6:23 pm    Post subject: Reply with quote

Code:
ImageSearch px, py, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, *Trans0xFF0000 *n150 arrow.png ;try increasing the value of n

_________________
Check out the new AHK forum competition!
Back to top
View user's profile Send private message
dcurran
Guest





PostPosted: Sun Jan 31, 2010 11:54 pm    Post subject: Reply with quote

The change to including the % sign around the system variables did not result in a change in the behavior.

Is there something else I might be missing? Am I handling transparency incorrectly?
Back to top
closed



Joined: 07 Feb 2008
Posts: 509

PostPosted: Mon Feb 01, 2010 11:56 am    Post subject: Reply with quote

Just some thoughts ...........

If you look at the capturescreen.ahk program ( excellent stuff btw!!!) you can see that the capture cursor seems to be a separate function.

From what i can make of it ( not much knowledge with drawing) is that the cursor is a separate image created from a bitmap and then draw on the screenshot if required if so you could draw it on a black(red?) background (instead of the screenshot )and use the imagesearch on that.

It loads the cursor bitmap so maybe yould compare this bitmap without creating an image to an array of cursor bitmaps.That would speed things up a bit.

There is also some "getcursorinfo" in the dll maybe you can extract info from it that is unique to the cursor you want to identify.

I also played around with the x and y of the cursor and you can position it very easily over the startbutton so that the background will always be the same for the imagesearch.


Code:
If   bShow
      DllCall("DrawIcon", "Uint", hDC, "int", 0, "int",820, "Uint", hCursor)
   If   hBMMask
      DllCall("DeleteObject", "Uint", hBMMask)
   If   hBMColor
      DllCall("DeleteObject", "Uint", hBMColor)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group