AutoHotkey Community

It is currently May 27th, 2012, 2:04 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: January 31st, 2010, 3:30 pm 
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:
Image

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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2010, 7:23 pm 
Offline

Joined: October 26th, 2009, 6:29 am
Posts: 362
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2010, 12:54 am 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2010, 12:56 pm 
Offline

Joined: February 7th, 2008, 9:48 pm
Posts: 509
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)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: engunneer, nimda, sjc1000 and 15 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group