home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


19.2 Win32::Console

Win32::Console implements the Win32 console and character mode functions. They give you full control on the console input and output, including: support of off-screen console buffers (e.g., multiple screen pages); reading and writing of characters, attributes, and whole portions of the screen; and complete processing of keyboard and mouse events.

The new constructor is used to create a console object. It can take two forms:

$con = Win32::Console->new(
standard_handle
); 
$con = Win32::Console->new(
accessmode
, 
sharemode
);
The first form creates a handle to a standard channel. standard_handle can be one of STD_OUTPUT_HANDLE , STD_ERROR_HANDLE , or STD_INPUT_HANDLE .

The second form creates a console screen buffer in memory, which you can access for reading and writing as a normal console, and then redirect on the standard output (the screen) with Display . In this case, you can specify accessmode to be GENERIC_READ , GENERIC_WRITE , or both, determining the permissions you will have on the created buffer.

sharemode affects the way the console can be shared. It can be specified either as FILE_SHARE_READ , FILE_SHARE_WRITE , or both. If you don't specify any of those parameters, all four flags will be used.

Methods supported by the Win32::Console module are:

19.2.1 Constants

The following constants are exported in the main namespace of your script using Win32::Console:

BACKGROUND_BLUE		        BACKGROUND_GREEN
BACKGROUND_INTENSITY	    BACKGROUND_RED
CAPSLOCK_ON		            CONSOLE_TEXTMODE_BUFFER    
ENABLE_ECHO_INPUT		    ENABLE_LINE_INPUT
ENABLE_MOUSE_INPUT		    ENABLE_PROCESSED_INPUT
ENABLE_PROCESSED_OUTPUT	    ENABLE_WINDOW_INPUT
ENABLE_WRAP_AT_EOL_OUTPUT	ENHANCED_KEY
FILE_SHARE_READ		        FILE_SHARE_WRITE
FOREGROUND_BLUE		        FOREGROUND_GREEN
FOREGROUND_INTENSITY	    FOREGROUND_RED
LEFT_ALT_PRESSED		    LEFT_CTRL_PRESSED
NUMLOCK_ON		            GENERIC_READ
GENERIC_WRITE		        RIGHT_ALT_PRESSED
RIGHT_CTRL_PRESSED		    SCROLLLOCK_ON
SHIFT_PRESSED		        STD_INPUT_HANDLE
STD_OUTPUT_HANDLE		    STD_ERROR_HANDLE
Additionally, the following variables can be used:
$FG_BLACK			$FG_BLUE
$FG_LIGHTBLUE		$FG_RED
$FG_LIGHTRED		$FG_GREEN
$FG_LIGHTGREEN		$FG_MAGENTA
$FG_LIGHTMAGENTA		$FG_CYAN
$FG_LIGHTCYAN		$FG_BROWN
$FG_YELLOW		$FG_GRAY
$FG_WHITE
$BG_BLACK			$BG_BLUE
$BG_LIGHTBLUE		$BG_RED
$BG_LIGHTRED		$BG_GREEN
$BG_LIGHTGREEN		$BG_MAGENTA
$BG_LIGHTMAGENTA		$BG_CYAN
$BG_LIGHTCYAN		$BG_BROWN
$BG_YELLOW		$BG_GRAY
$BG_WHITE
$ATTR_NORMAL		$ATTR_INVERSE
ATTR_NORMAL is set to gray foreground on black background (DOS's standard colors).