Thread: Cursor React to Screen Display

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    3

    Cursor React to Screen Display

    I want to write a program (to run on Windows XP) that can react to screen output by moving the mouse cursor to a certain position and "clicking" with the cursor.

    I need some way of getting a screenshot of what's being displayed on the screen into memory where the program can use it. I also need to learn how to interpret the screenshot (obviously).

    I have no idea where to begin. Any help would be greatly appreciated.

  2. #2
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    im not to sure on the screenshot but as for the cursor and all that here are some functions which may help

    GetCursorPos
    WindowFromPoint

    from here on its pretty simple, use them to get the control you want, in your case a button, then use SendMessage or PostMessage to do the actions you would like,
    Good Luck.
    Last edited by Rare177; 10-21-2004 at 12:22 AM.
    Good Help Source all round
    Good help for win programmers
    you will probably find something in here
    this thing also helps

    if you have never tried any of the above then maybe you should, they help alot

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    >>moving the mouse cursor to a certain position and "clicking" with the cursor.

    Not hard, as long as you know the position. See Above and/or send a left button down message.

    >>getting a screenshot of what's being displayed on the screen
    >>into memory where the program can use it.

    Not that hard. Do a search here for some code.

    >>I also need to learn how to interpret the screenshot (obviously).

    Here is the hard part.
    Depending on what you are looking for and how fast you have to find it.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Registered User
    Join Date
    Oct 2004
    Posts
    3
    Quote Originally Posted by novacain
    Not that hard. Do a search here for some code.
    I tried searching, but I didn't come up with anything, maybe because I don't know what to search for. Things like "screenshot", "screen into memory", "manipulate screen output" didn't return anything uselful.

    Quote Originally Posted by novacain
    Here is the hard part.
    Depending on what you are looking for and how fast you have to find it.
    Here's an example that would do everything I want to do:
    Let's say there's a Whack-A-Mole game on the internet, and for some reason I lose terribly thousands of times and swear undying revenge upon it, so I decide to make a game to cheat at it. The background of the game has no green or blue in it, but all the moles have green or blue in their eyes. I would want the program to record the position of the cursor the first two times I click, which would be at the top-left and bottom-right corners of the game's area so I know where to search (very easy to do). Then I would want to continually load a screen shot (don't have a clue about) and scan that area (just ignore coords not in that area) and click any locations that are green or blue. Clicking is easy, but comparing the color of a location with a preset color is something I don't have a clue about.

    I really appreciate your willingness to help. ^_^ If there's something here that can help with the screenshot thing, I'll guess I'll start scanning through the pages.

  5. #5
    Registered User
    Join Date
    Feb 2004
    Posts
    72
    try searching for 'aimbot' 'source' or similar variants

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    >>background of the game has no green or blue in it, but all the moles have green or blue in their eyes.
    >>but comparing the color of a location with a preset color is something I don't have a clue about.


    So you need the screen colour depth so you can work out how many bits relate to the RGB value.
    Reduce to the area you want to scan.
    Then run thru the image looking for the colour you want
    Convert to screen coods to send mouse click.

    look here;
    http://cboard.cprogramming.com/showt...ight=getDIbits
    and here
    http://cboard.cprogramming.com/showt...ight=getDIbits

    Trouble is that many images have small patches of colours you can't realy see. I think you will need a better pattern matching system.
    One way is to convert both images to the same colour depth and compare them. Trouble is speed.

    >>which would be at the top-left and bottom-right corners of the game's area so I know where to search

    Look at using the client rect (GetClientRect() ) and ClipCursor(), SetCapture() to ensure the mouse stays in the desired app.

    EDIT:
    Look here
    http://msdn.microsoft.com/library/de...tmaps_7zfp.asp
    Last edited by novacain; 10-22-2004 at 09:56 PM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linux Problem Screen Resoultion
    By Matus in forum Tech Board
    Replies: 1
    Last Post: 01-29-2009, 04:39 PM
  2. output display in screen required
    By imagetvr in forum C++ Programming
    Replies: 9
    Last Post: 08-19-2008, 09:55 PM
  3. Updating display on screen?
    By shadow1515 in forum C Programming
    Replies: 2
    Last Post: 06-06-2008, 10:24 AM
  4. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  5. Output to screen display issues
    By spazjr01 in forum C++ Programming
    Replies: 3
    Last Post: 12-16-2002, 05:45 PM