• Advertisement


This topic is now archived and is closed to further replies.

How do I get the color attributes... ? (win console thing)

This topic is 5990 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to get the color value from one position on the console screen (x,y). This is the best I can think of, but it doesn't seem to work:
unsigned char console::getcolor(unsigned char x,unsigned char y) {
     COORD coordinate={x,y};
	 unsigned short attributes[1]={0};
	 LPDWORD charsRead=0;

	 if (!ReadConsoleOutputAttribute(outH,&attributes[0],1,coordinate,charsRead))
	    return current_fgc+0x10*current_bgc;
	 return (unsigned char)(attributes[0]);
The ReadConsoleOutputAttribute function seems to always fail. (outH is a handle to the standard console output) Edited by - Monolith on October 29, 2001 6:17:14 PM

Share this post

Link to post
Share on other sites

  • Advertisement