PDA

Click to See Complete Forum and Search --> : Locating pictures anywhere on the screen!


vbzero
Aug 19th, 2000, 05:44 AM
OK - I have a problem - I have a picture on the screen which I captured to a picture box in VB.
Now I want the program search for the picture on the screen which was captured before even if the original picture has moved to another point.
When it's located the mouse cursor should be moved into the middle of the picture on the screen.

I think it would work as a kind of comparison.
That means - the application compares the picture in the
picture box with any picture or object on the screen and if
it maches the mouse cursor moves into the middle of the picture on the screen even if it has moved.

------

I know the commands to move the mouse but I need help how to do this locating function.


thx, sub-zero


Visual Studio 6.0 Enterprise Edition - SP3

HarryW
Aug 19th, 2000, 08:18 AM
That sounds incredibly complicated to do.

Hmm, I expect there's some complex maths thing to look for patterns, probably using fractals.

vbzero
Aug 19th, 2000, 08:51 AM
If someone wants to know exactly what I mean...
- go to http://212.186.131.237/bitnap.zip

There you will find an application that works as
I explained. The problem is - I didn't program
the application and the source codes are in
Visual C++. I'm not a good Visual C++ programmer
so I really need help.

The guy who developped this program cannot write
an application in VB.

- Maybe anyone could help me?

thx, sub-zero


Visual Studio 6.0 Enterprise Edition - SP3

/\/\isanThr0p
Aug 19th, 2000, 08:45 PM
Hey!

Perhaps I misunderstood you, but if not I don't really see the problem. (only the speed!!!!!!!!!!!!!)

Just take a screenshot to a picturebox (good sample in the MSDN) than you can just compare the first line of the picture and if it matches try the second one and so on (to avoid problems with only white pics or so)

I hope I could help you a little bit!

HarryW
Aug 20th, 2000, 12:42 PM
So, you think it would be okay to just try every pixel on the screen until the picture was found? I would have thought that would take absolutely ages to execute. I suppose they're only integers (or longs, I'm talking about the CPU here ;)) so they should be quick to compare.

I'm sorry, I'm not helping. I'll shut up ;)

/\/\isanThr0p
Aug 20th, 2000, 04:35 PM
Yes it will take ages but if I need to do something...

Perhaps you could use the bitblt
if there is a way to compare whole pictures it woul be fine!

if you're interested in my idea write back and I'll try to explain it in a better english :-)

vbzero
Aug 20th, 2000, 08:58 PM
I'm sorry - I didn't write back - I was searching
for a solution for this and I just found it.

Now my program should compare 2 pictures even one of
them is located anywhere on the screen.
There's only one problem left:

I want the program to search for the picture on the
desktop and it doesn't search for it. It just
compares the whole screen with the picture in the
picture box. How do I search only for this picture
on the desktop?

You said something about the BitBlt function.
What does this function? Can I use it for that?

thx, sub-zero


Visual Studio 6.0 Enterprise Edition - SP3

HarryW
Aug 21st, 2000, 03:41 PM
BitBlt is short for bit-block transfer. It's an API call, a function in the library GDI32.DLL. It's used to paint images onto the screen.

I think you could basically take a screenshot of the screen, and then compare the top-left pixel in your screenshot with the top-left pixel in your image. If it's the same, check the pixels at coordinates (1, 2) in their relative images. If they don't match try starting one pixel along. Does that make sense? You keep trying basically.

You don't actually have to try every pixel, just every starting point. If you were to check every, say, 5 pixels I expect that would also work most of the time, and be a lot quicker.

vbzero
Aug 21st, 2000, 04:21 PM
Now it works! The BitBlt() function has done it.
Thank you very much!

thx, sub-zero


Visual Studio 6.0 Enterprise Edition - SP3