Skip to content

Instantly share code, notes, and snippets.



Last active Dec 25, 2015
What would you like to do?
# 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";
print "Get ready to click...\n";
sleep 5;
print "Clicking forever... hit any key to stop...\n";
while (1) {
print "Done!\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.