Results 1 to 7 of 7
  1. #1
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed

    [Help]GetPixel()

    Here is my code:
    Code:
    #include <iostream>
    #include <windows.h>
    #include "Getasynckeystates.h"
    int main()
    {
    	POINT a;
    	while(true)
    	{
    		HWND hwnd = FindWindow(NULL, NULL);
    		HDC hdc = GetDC(hwnd);
    		if(GetAsyncKeyState(sh) &1){
    		GetCursorPos(&a);
    		GetPixel(hdc, a.x, a.y);
    		
    		Sleep(20);
    		}
    		
    	}
    }
    My problem is that, idk how i would make it tell me the color. Like i would put cout<<blahblha, but idk what to do. Thanks for ur help.

  2. #2
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    This is kind of off the top of my head.

    GetPixel returns COLORREF btw.

    [php]
    COLORREF color = GetPixel(...);
    BYTE red = GetRValue( (DWORD)color );
    cout << red << endl;
    [/php]

  3. The Following 3 Users Say Thank You to Void For This Useful Post:

    'Bruno (09-29-2010),258456 (09-29-2010),therofl (10-01-2010)

  4. #3
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    thanks void,
    Code:
    #include <iostream>
    #include <windows.h>
    #include "Getasynckeystates.h"
    int main()
    {
    	POINT a;
    	while(true)
    	{
    		HWND hwnd = FindWindow(NULL, NULL);
    		HDC hdc = GetDC(hwnd);
    		if(GetAsyncKeyState(sh) &1){
    		GetCursorPos(&a);
    		COLORREF color = GetPixel(hdc, a.x, a.y);
    		BYTE red = GetRValue(color);
    		std::cout<<red<<"\n";
    		Sleep(20);
    		}
    		
    	}
    }
    here is my code, it's not sending the value to the console, i am pretty sure i did something wrong, thanks for your help, I really appreciate it.
    btw why aren't you a junior coder anymore? you know that purple title below ur name. They should make you it again, you are one of the few people on this forum that help in every thread.
    Last edited by 258456; 09-29-2010 at 10:10 AM.

  5. #4
    doofbla's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    Biel*****/Germany
    Posts
    369
    Reputation
    10
    Thanks
    179
    My Mood
    Psychedelic
    press F11 and go step by step through it and everytime you should check your vars...
    _____________________________________________

    READING TUTORIAL:

    1. READ MY POST
    2. THINK ABOUT MY POST
    3. PRESS THANKS
    4. MAYBE CORRECT MY POSTS :P




    Dijkstra:
    "Computer Science is no more about computers than astronomy is about
    telescopes."


    THANKS BUTTON RIGHT DOWN --->

  6. The Following 2 Users Say Thank You to doofbla For This Useful Post:

    258456 (09-29-2010),Stephen (09-29-2010)

  7. #5
    Stephen's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    Engine.exe
    Posts
    4,689
    Reputation
    184
    Thanks
    1,149
    My Mood
    Aggressive
    / .

  8. #6
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    Doofbla, the reason I posted here was because I couldn't figure out what was wrong, I tried everything I could I just wanted an answer. And Stephen, u didn't help whatsoever the only person that has actually helped was void. If anyone would like to help please post but if u will just spam don't because there is no point. Doofbla I will thank anyways because u were trying to help.

  9. #7
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    Quote Originally Posted by 258456 View Post
    Doofbla, the reason I posted here was because I couldn't figure out what was wrong, I tried everything I could I just wanted an answer. And Stephen, u didn't help whatsoever the only person that has actually helped was void. If anyone would like to help please post but if u will just spam don't because there is no point. Doofbla I will thank anyways because u were trying to help.
    "Not all devices support GetPixel. An application should call GetDeviceCaps to determine whether a specified device supports this function."

Similar Threads

  1. [Help Request] Combat arms Vid help
    By djw111 in forum Combat Arms Help
    Replies: 4
    Last Post: 12-24-2011, 05:06 PM
  2. [Help Request] AFK Bot [help]
    By fet in forum Combat Arms Help
    Replies: 7
    Last Post: 04-28-2011, 03:17 AM
  3. [Help Request] Ajuda / Help
    By - Battery' in forum Combat Arms BR Coding Help
    Replies: 3
    Last Post: 04-22-2011, 07:15 PM
  4. [Help Request] Help my!
    By Windowns7 in forum Combat Arms BR Coding Help
    Replies: 2
    Last Post: 04-18-2011, 01:41 PM
  5. [HELP (as usual)] Any faster Method than GetPixel()?
    By 258456 in forum C++/C Programming
    Replies: 8
    Last Post: 11-08-2010, 05:08 AM