Topics - Codebyte [ switch to compact view ]

Pages: prev1 [2] 3 4 5 6next
6
Developer's Corner / 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...

7
Tonight a highly subjective question was proposed concerning "What Beautiful Code should be." There are a lot of important questions and while I understand this might be a very debatable topic, let's take some time to talk about this... Why? you might ask. Well, because it's important... Take a look at some of the following points made by our very own mouser, Gothi[c] and Deozaan:

1. It is better to have 20 lines of understandable clear simple code than 4 lines of complexity. - Mouser
2. The real question is does it make any non-negligable difference when it's all compiled down to bytecode anyway? If so, it probably needs to be evaluated for each programming language. - Deozaan
3. If it uses more memory, so what? Premature optimization is the root of all evil. Lets not optimize that until a problem is created by being too organized, which is near impossible. - CodeByter
4. Would you rather have a program use 100k extra memory or have the same program crash more often because its code is hard to understand? - mouser
5. If the program needs to read millions of pieces of data, then 1ms of delay can add up. - Deozaan
6. There's a balance between clear code and complex code with less lines. Just clarity at the cost of crazy insane slowdown would be silly. - Gothi[c]
7. Even when code is slower, you have to ask yourself, is it happening in a place that matters. There are very very few cases where it is better to have ugly short code than longer clearer code. - Mouser
8. We shouldn't strive to write longer code but rather to write code that is easy to understand. - Mouser
9. The goal should be: efficient easy to understand, short if possible, code. - Gothi[c]

In this discussion, Mouser mentions a list that I post on my site. Take a look at the list here: http://www.codebyter.com/2009/02/beautiful-code/

Now, you are completely briefed and ready to go. Post some thoughts you have concerning this highly debatable topic and keep in mind that no one is against you :)

8
Developer's Corner / Programming Paradigms
« on: February 02, 2009, 12:03 PM »
So I ran across some great content on youtube concerning a course offered at Stanford. The Title of the course is "Programming Paradigms" and the lecturer is Jerry Cain. I'm going to start watching this every day and wanted to share with you all... Enjoy!

Also, here are some other cute clips too:
Binky Pointer - http://www.youtube.com/watch?v=f-pJlnpkLp0
Write in C - http://www.youtube.com/watch?v=J5LNTTGDKYo&feature=related

9
Living Room / Culture of Computer Programmers
« on: January 26, 2009, 05:07 PM »
I have decided to do my first speech of this semester on the Culture of Computer Scientists... I wanted to get some feedback from you all (to include in my speech) by this Wednesday night. Post some personal opinions concerning what you think about the Culture of Computer Scientists! Just open thoughts for the time being and if I dont get enough feedback, ill propose some questions... I could really use a few good opinions so dont be afraid to share yours!

Thanks for the help,
CodeByter


Pages: prev1 [2] 3 4 5 6next
Go to full version