Thread: Here's my script need help with the courser.

  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 03:11 AM. Reason: spelling

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    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, 11: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