Results 1 to 9 of 9

Thread: Locating pictures anywhere on the screen!

  1. #1

    Thread Starter
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347

    Exclamation

    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

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    That sounds incredibly complicated to do.

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

    "From one thing, know ten thousand things."

  3. #3

    Thread Starter
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347

    Exclamation

    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

  4. #4
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181

    Red face

    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!
    Sanity is a full time job

    Puh das war harter Stoff!

  5. #5
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    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
    Harry.

    "From one thing, know ten thousand things."

  6. #6
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181

    You're right!

    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 :-)

    Sanity is a full time job

    Puh das war harter Stoff!

  7. #7

    Thread Starter
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347

    Exclamation

    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

  8. #8
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    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.
    Harry.

    "From one thing, know ten thousand things."

  9. #9

    Thread Starter
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347

    Exclamation

    Now it works! The BitBlt() function has done it.
    Thank you very much!

    thx, sub-zero


    Visual Studio 6.0 Enterprise Edition - SP3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width