http://www.perlmonks.org?node_id=745114

My company laptop has some remnants from the previous IT regime's mindset (one that is all too common) and so I'm not allowed to adjust how quickly the screen-saver / desktop-locker kicks in.

I have shows that get recorded for me but that I rarely have the time to sit down and watch. So I transfer them to my work laptop and watch them (mostly just listen to them, actually) during my bus commute.

I finally got a really nice biking backpack I've wanted so now I can even listen to them when I commute by bicycle and I even have a little program to cue up cuts to skip over the commercials for me.

The first day that I tried that, playback stopped about half-way to the office. I stopped and checked the laptop and the screensaver had kicked in. At work I googled and got the suggestion that I run Windows Media Player with its volume turned down while it was configured to prevent screen-saver activation. The ride home demonstrated that this is not sufficient to prevent administratively mandated screen-saver timeouts.

More googling at home mostly found people noting that when one doesn't have administrative rights, one can't install a program to thwart the screen-saver activation anyway so no such programs are offered.

So I wrote the following Perl program:

#!/usr/bin/perl -w use strict; use Win32::GuiTest qw< GetCursorPos MouseMoveAbsPix >; sleep 5; my( $x, $y )= GetCursorPos(); my @dx= ( 10, -10, -10, 10 ); my @dy= ( 10, 10, -10, -10 ); while( 1 ) { sleep 1; my( $x1, $y1 )= GetCursorPos(); exit if( $x != $x1 || $y != $y1 ); $x += $dx[0]; push @dx, shift @dx; $y += $dy[0]; push @dy, shift @dy; MouseMoveAbsPix( $x, $y ); }

It just waits five seconds and then makes the mouse pointer move around in a nice little diamond pattern until you bump your mouse.

This morning's bike commute I enjoyed the audio from uninterrupted video playback. Thanks, Perl.

- tye