Good Morning Thanks for posting your solution
Erich -----Original Message----- From: Perl Help [mailto:[email protected]] Sent: Saturday, March 28, 2009 3:31 PM To: Bill Luebkert; Singer, Erich Cc: [email protected] Subject: Re: Reset in ANSIColor sets the background to black The following code gets the DOS current background and foreground color information and prints the error message in red color and then sets the text color back to original without changing its background color. use strict; use warnings; use Win32::Console; my $console = Win32::Console->new(STD_OUTPUT_HANDLE); my $CurrentConsoleColor = $console->Attr; my $BackgroundColor = $CurrentConsoleColor & (BACKGROUND_RED|BACKGROUND_BLUE|BACKGROUND_GREEN|BACKGROUND_INTENSITY); print "\nPrior to error: \n"; # This sets the text color on DOS in red with intensity $console->Attr(FOREGROUND_RED|FOREGROUND_INTENSITY|$BackgroundColor); print "\nError Msg: xyz \n"; $console->Attr($CurrentConsoleColor); print "\nAfter error\n"; Thanks, Jai! On 3/27/09, Bill Luebkert <[email protected]> wrote: > Perl Help wrote: >> Hi, >> >> I tried this code, but it shows the same results in cmd.exe. Also, is >> there a way I can read the current background and foreground color of >> dos window from perl? > > Not sure if it's in a module, but you can use Win32::API to get it > from GetConsoleScreenBufferInfo function. > > _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
