Last active
December 25, 2015 07:59
-
-
Save kirsle/c4fea461359e8953dde1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# requires: libX11-devel, libXt-devel, libXtst-devel, /usr/bin/xinput | |
# sudo cpanm X11::GUITest | |
use threads; | |
use IO::Pty::Easy; | |
use IO::Handle; | |
use X11::GUITest qw(ClickMouseButton :CONST); | |
# Use `xinput list` and find the ID num of your keyboard | |
my $id = 10; | |
my $kbd = threads->new(sub { | |
my $tty = IO::Pty::Easy->new(); | |
$tty->spawn("xinput test $id"); | |
print "Watching keyboard...\n"; | |
my $start = time() + 2; | |
while ($tty->is_active) { | |
my $data = $tty->read(); | |
if (time() > $start) { | |
print $data . "\n"; | |
if ($data) { | |
print "Saw activity! Bail out!\n"; | |
exit(0); | |
} | |
} | |
} | |
}); | |
print "Get ready to click...\n"; | |
sleep 5; | |
print "Clicking forever... hit any key to stop...\n"; | |
while (1) { | |
select(undef,undef,undef,0.0005); | |
ClickMouseButton(M_LEFT); | |
} | |
print "Done!\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment