Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 2nd, 2005, 11:07 PM   #1
melbolt
Hobbyist Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 237
Rep Power: 4 melbolt is on a distinguished road
Send a message via AIM to melbolt Send a message via Yahoo to melbolt
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
melbolt is offline   Reply With Quote
Old May 3rd, 2005, 2:05 PM   #2
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
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!
Rory is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:14 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC