Question

I'd like to know if there's any way to hide the closing button or at least make it non-clickable when using Perl in console. I know it's possible when using GUI, but I need to make a console-based application and don't want the user to close it on purpose.

Was it helpful?

Solution

use strict;
use Win32::Console::ANSI qw/ SetCloseButton /;

$SIG{INT}='IGNORE';   # no Ctrl-C interrupt
SetCloseButton(0);    # no close button

OTHER TIPS

I don't think you can prevent users from closing the Windows command prompt window. Not only would you have to hide the close button, but you'd have to hide the associated system menu items, context menu items (depending on the flavor of Windows), and capture the Alt + F4 keyboard shortcut.

If you had control over the entire end-to-end process, you could do something clever by making the console window hidden, capturing the output, and sending it to a window you created (without the close capability, of course).

Otherwise, you're just going to have to trust that your users are big boys and girls and won't close the window.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top