# https://docs.microsoft.com/en-us/windows/console/reading-input-buffer-events\ # reference Perl Monks: https://www.perlmonks.org/?node_id=1212227 use strict; use warnings; use Win32::Console; my $OUT = new Win32::Console(STD_OUTPUT_HANDLE); my $IN = new Win32::Console(STD_INPUT_HANDLE); $OUT->Write("Perl version $^V \n"); $OUT->Write("more text could go here\n\n"); my $n_buttons = $IN->MouseButtons(); $OUT->Write("Your mouse has $n_buttons buttons\n"); $IN->Mode(ENABLE_MOUSE_INPUT); my $counter = 0; while ($counter++ < 5) #5x time out for testing... { if (my @console_events = $IN -> Input ()) { $OUT->Write ("calling input method!\n"); # my @console_events = $IN -> Input (); ##not needed goof (CORRECTION) $OUT->Write ("An Event was detected! number= ".@console_events."\n"); foreach my $event (@console_events) { $OUT->Write("event: $event\n"); } exit; # exit the program, do not fall through to that final print instruction } else { sleep 1; #should be fine to poll 1x per second for testing... } } $OUT->Write("Timed out! Bummer!\n");