Archived

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

Monolith

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

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;
	 current_fgc=attributes[0]%0x10;
	 current_bgc=attributes[0]/0x10;
	 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