![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
capturing pixel colors at specific coordinates
Hi, I play online video games, sometimes waiting for other players to team up can take hours, i don't want to have to sit and stare at my computer so i thought maybe i could write a little application that alerts me by playing a sound whenver someone sends me a message on my screen.
The text on the screen will appear in the same pixel coordinates everytime and be the same color everytime. so i figured if i could get my program to determine if that color appears at that location, then play the sound for my algorithm. the problem is, i'm not sure how to capture a specific color at a specific pixel location on my screen, how would you go about doing this? this is more of a fun little project than it is something that i really need. I know i could get a little scripting tool to do it easily but I want to have fun with VB .NET code examples aren't really necessary, just a brief overview of how i might go about it would be nice and i can research the rest myself. thanks |
|
|
|
|
|
#2 |
|
Expert Programmer
|
To do this, as your game probably handles its own draw methods, is to use the BitBlt unmanaged API. If your application doesn't use DirectX fullscreen mode (or you can set it to windowed) and you know the exact coordinates, you can use this API to copy a rectangle of the screen (in this case 1x1) onto any object with a device context (like a form). The api also requires the device context (hdc) which can be found with the GetHDC method, of the graphics class. In practice you'd put this in the OnPaint event: if you look at the arguments here there's a Forms.PaintEventArgs which has the required instance of the Graphics class.
Just remember to call ReleaseHDC() after the API to actually draw it, and also to raise the Paint event regularly (refresh) e.g. using a timer. Once the pixel is on the form you can use the normal graphics Point method to get the colour, and do whatever. If on the other hand your game does use D3D or makes use of overlays you're basically screwed unless you want to play around with kernel mode video drivers or try and memory hack the game. Either way, good luck! ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|