Here's my script need help with the courser.

This is a discussion on Here's my script need help with the courser. within the C++ Programming forums, part of the General Programming Boards category; Hay guys I need some help with this. Ok I have made a simple color picker for the CMD. It ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    43

    Here's my script need help with the courser.

    Hay guys I need some help with this. Ok I have made a simple color picker for the CMD. It gets the color of the pixel from were the mouse pointer is.

    This is what I’m trying to get to happen.
    When the script runs I wont it to wait for the mouse to click before it gets the color of the pixel from the mouse pointer

    This is what is does so far.
    When it runs it automatically gets the pixel from the mouse position with out waiting for a click.

    So can any of you help me with this??

    Code:
    #include <iostream>
    #include <stdlib.h>
    #include <windows.h>
    
    int main()
    {
        POINT pt;
        GetCursorPos(&pt);
        cout << pt.x << endl;
        cout << pt.y;
                 HDC hdc = GetDC(NULL);
                 DWORD color = GetPixel(hdc, pt.x, pt.y);
                 unsigned int r = GetRValue(color);
                 unsigned int g = GetGValue(color);
                 unsigned int b = GetBValue(color);
        cout << "red: " << r << endl;
        cout << "green: " << g << endl;
        cout << "blue: " << b << endl;
    cin.get();
    cin.ignore();
    return 0;
    }
    O yes and I’m using Dev-C++ and Windows XP.
    Last edited by JordanCason; 11-24-2007 at 02:11 AM. Reason: spelling

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Well, there could be a number of ways to read a mouse press. One way is to change the console input to also include mouse input. For reading: http://msdn2.microsoft.com/EN-US/library/ms685035.aspx

    One possible limit is that the mouse might have to be on the console window, which kind of defeats the purpose.

    It might be better to have your program pause with a "Please press <Enter> when you are pointing at the color in question..." type of message instead of relying on a click.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    43
    all right thanke you.
    Iím Dyslexic and I know that I donít spell well so quit telling to learn my English because I do my best at it all right.

    Windows XP with Dev-C++ for now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 04-10-2009, 12:57 AM
  2. Script in games
    By Shakti in forum Game Programming
    Replies: 7
    Last Post: 09-27-2006, 12:27 AM
  3. In a game Engine...
    By Shamino in forum Game Programming
    Replies: 28
    Last Post: 02-19-2006, 10:30 AM
  4. Passing arguments to script.....
    By suwie in forum C Programming
    Replies: 5
    Last Post: 09-25-2004, 11:10 PM
  5. Game structure, any thoughts?
    By Vorok in forum Game Programming
    Replies: 2
    Last Post: 06-07-2003, 01:47 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21