Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Matts (1087)

  (email not shown publicly)

I work for MessageLabs [] in Toronto, ON, Canada. I write spam filters, MTA software, high performance network software, string matching algorithms, and other cool stuff mostly in Perl and C.

Journal of Matts (1087)

Thursday September 07, 2006
12:21 PM

Shocking Presentations

[ #30914 ]

Just messing around with the Thinkpad Shock Manager. I decided to see if I could "next page" a presentation by whacking my laptop. It works :-)

use Win32API::File qw(:ALL);
use Win32::GuiTest qw(FindWindowLike GetWindowText
    SetForegroundWindow SendKeys);
$Win32::GuiTest::debug = 0; # Set to "1" to enable verbose mode
my @windows = FindWindowLike(0, "Mozilla Firefox", "");
die "No firefox open" unless @windows;
my $file = createFile("//./ShockMgr", "r ke") || die "createFile failed";
my @prev;
while(1) {
    DeviceIoControl($file, 0x733fc, [], 0, my($buf), 0x24, my($bytes), []);
    my ($x, $y, @extra) = unpack("x4s*", $buf);
    unless (arreq(\@extra, \@prev)) {
        print "Got: $x, $y\n@extra\n";
        my $text = GetWindowText($windows[0]);
    @prev = @extra;
    select(undef, undef, undef, 0.05);
sub arreq {
    my ($aa, $bb) = @_;
    for (0..$#$aa) {
        if ($aa->[$_] - $bb->[$_] > 5) {
    return 1;

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.