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]); SetForegroundWindow($windows[0]); SendKeys("{DOWN}"); sleep(1); } @prev = @extra; select(undef, undef, undef, 0.05); }
sub arreq { my ($aa, $bb) = @_; for (0..$#$aa) { if ($aa->[$_] - $bb->[$_] > 5) { return; } } return 1; }
Re:Ha!
Matts on 2006-09-08T13:24:55
I stole the original control code from your Plagger svn:-)