$CONSOLE->Alloc();
$attr = $CONSOLE->Attr(); $CONSOLE->Attr($FG_YELLOW | $BG_BLUE);
$LINK->Close();
$CONSOLE->Cls(); $CONSOLE->Cls($FG_WHITE | $BG_GREEN);
($x, $y, $size, $visible) = $CONSOLE->Cursor(); # Get position only ($x, $y) = $CONSOLE->Cursor(); $CONSOLE->Cursor(40, 13, 50, 1); # Set position only $CONSOLE->Cursor(40, 13); # Set size and visibility without affecting position $CONSOLE->Cursor(-1, -1, 50, 1);
$CONSOLE->Display();
$CONSOLE->FillAttr($FG_BLACK | $BG_BLACK, 80*25, 0, 0);
$CONSOLE->FillChar("X", 80*25, 0, 0);
$CONSOLE->Flush();
$CONSOLE->Free();
CTRL_BREAK_EVENT CTRL_C_EVENTthey signal, respectively, the pressing of Control + Break and of Control + C; if not specified, it defaults to CTRL_C_EVENT.
# break this script now $CONSOLE->GenerateCtrlEvent();
$events = $CONSOLE->GetEvents();
@info = $CONSOLE->Info(); print "Cursor at $info[3], $info[4].\n";
See also: GetEvents, InputChar,
Mode,
PeekInput, WriteInput.
Example:
@event = $CONSOLE->Input();
$key = $CONSOLE->InputChar(1);
$codepage = $CONSOLE->InputCP(); $CONSOLE->InputCP(437); # you may want to use the non-instanciated form to avoid confuzion :) $codepage = Win32::Console::InputCP(); Win32::Console::InputCP(437);
($maxCol, $maxRow) = $CONSOLE->MaxWindow();
ENABLE_LINE_INPUT ENABLE_ECHO_INPUT ENABLE_PROCESSED_INPUT ENABLE_WINDOW_INPUT ENABLE_MOUSE_INPUT ENABLE_PROCESSED_OUTPUT ENABLE_WRAP_AT_EOL_OUTPUTFor more informations on the meaning of those flags, please refer to the Microsoft's Documentation.
$mode = $CONSOLE->Mode(); $CONSOLE->Mode(ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT);
print "Your mouse has ", $CONSOLE->MouseButtons(), " buttons.\n";
STD_OUTPUT_HANDLE STD_ERROR_HANDLE STD_INPUT_HANDLEThe second form, instead, 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 one or both of the following values for accessmode:
GENERIC_READ GENERIC_WRITEwhich are the permissions you will have on the created buffer, and one or both of the following values for sharemode:
FILE_SHARE_READ FILE_SHARE_WRITEwhich affect the way the console can be shared. If you don't specify any of those parameters, all 4 flags will be used.
$STDOUT = new Win32::Console(STD_OUTPUT_HANDLE); $STDERR = new Win32::Console(STD_ERROR_HANDLE); $STDIN = new Win32::Console(STD_INPUT_HANDLE); $BUFFER = new Win32::Console(); $BUFFER = new Win32::Console(GENERIC_READ | GENERIC_WRITE);
$codepage = $CONSOLE->OutputCP(); $CONSOLE->OutputCP(437); # you may want to use the non-instanciated form to avoid confuzion :) $codepage = Win32::Console::OutputCP(); Win32::Console::OutputCP(437);
@event = $CONSOLE->PeekInput();
$colors = $CONSOLE->ReadAttr(80*25, 0, 0);
$chars = $CONSOLE->ReadChar(80*25, 0, 0);
$rect = $CONSOLE->ReadRect(0, 0, 80, 25);
# scrolls the screen 10 lines down, filling with black spaces $CONSOLE->Scroll(0, 0, 80, 25, 0, 10, " ", $FG_BLACK | $BG_BLACK);
STD_INPUT_HANDLE STD_OUTPUT_HANDLE STD_ERROR_HANDLEReturns undef on errors, a nonzero value on success.
$CONSOLE->Select(STD_OUTPUT_HANDLE);
($x, $y) = $CONSOLE->Size(); $CONSOLE->Size(80, 25);
$title = $CONSOLE->Title(); $CONSOLE->Title("This is a title");
($left, $top, $right, $bottom) = $CONSOLE->Window(); $CONSOLE->Window(1, 0, 0, 80, 50);
$CONSOLE->Write("Hello, world!");
$CONSOLE->WriteAttr($attrs, 0, 0); # note the use of chr()... $attrs = chr($FG_BLACK | $BG_WHITE) x 80; $CONSOLE->WriteAttr($attrs, 0, 0);
$CONSOLE->WriteChar("Hello, worlds!", 0, 0);
$CONSOLE->WriteInput(@event);
$CONSOLE->WriteRect($rect, 0, 0, 80, 25);
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_HANDLEAdditionally, 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_INVERSEATTR_NORMAL is set to gray foreground on black background (DOS's standard colors).
A reference of the available functions is at:
http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/sys/src/conchar_34.htm
07 Apr 1997, Aldo Calpini <dada@perl.it>