topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 7:25 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: C++ Help  (Read 4050 times)

Codebyte

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 160
  • "Premature Optimization is the root of all evil."
    • View Profile
    • CodeByter.com
    • Donate to Member
C++ Help
« on: February 12, 2010, 08:30 PM »
Alright so here it goes... I've been experimenting with creating macros based on pixel color changes... I'm not understanding why GetPixel() is returning 0 constantly when I have the target game open... I can see the cursor coordinates, but not the color value... What am I doing wrong? I need to find the color of the pixel underneath the cursor while in a full screen game window.

Here is my example I wrote in a couple minutes to output coordinates and color:

Code: C [Select]
  1. //------------------------------------------------------------------------------
  2. #include <windows.h>
  3. #include <iostream>
  4. //------------------------------------------------------------------------------
  5. using namespace std;
  6. //------------------------------------------------------------------------------
  7. int main(void)
  8. {
  9.         HWND wowHandle = FindWindow(NULL, "World of Warcraft");
  10.         if(!wowHandle)
  11.         {
  12.                 cout << "WoW is not open atm..." << endl;
  13.                 system("pause");
  14.                 return 0;
  15.         }
  16.         else
  17.         {
  18.                 cout << "WoW is OPEN..." << endl;
  19.                 ShowWindow(wowHandle, SW_SHOWNORMAL);
  20.                 SetForegroundWindow(wowHandle);
  21.                
  22.                 while(1)
  23.                 {
  24.                         POINT cursorPoint;
  25.                         GetCursorPos(&cursorPoint);
  26.                         COLORREF color = GetPixel(GetDC(wowHandle), cursorPoint.x, cursorPoint.y);
  27.                         system("cls");
  28.                         cout << "(" << cursorPoint.x << ", " << cursorPoint.y << ")" << endl;
  29.                         cout << "COLOR: " << color;
  30.                 }      
  31.         }
  32.        
  33. }
  34. //------------------------------------------------------------------------------

it's probably sloppy... don't hate on the 5 minute "im at work and in a hurry on my break" coding...
CodeByter.com - http://www.codebyter.com

Codebyte

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 160
  • "Premature Optimization is the root of all evil."
    • View Profile
    • CodeByter.com
    • Donate to Member
Re: C++ Help
« Reply #1 on: February 12, 2010, 08:53 PM »
nevermind... after doing some research I figured out that gameguard blocks the API calls and filters what is returned... this would make sense as to why its returning 0 for a color call...
CodeByter.com - http://www.codebyter.com

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: C++ Help
« Reply #2 on: February 12, 2010, 10:47 PM »
nevermind... after doing some research I figured out that gameguard blocks the API calls and filters what is returned... this would make sense as to why its returning 0 for a color call...
I'd be a bit surprised if GetPixel worked, GameGuard/whatever or not, as soon as you're dealing with Direct3D (and possibly even DirectDraw) accelerated games.
- carpe noctem