Perl

This allows you to peform a specific action when a specific sequence of mouse clicks is performed.
Set $data to the sequence of presses, 0-left 1-right click.
This at the moment simply causes the shell to echo hi when the pattern is reached. But it could be used to halt headless computers.


#!/usr/bin/perl
$left = "900800";$right = "1000800";$data="0";
open(FH,"/dev/input/mouse0");
$| = 1; #autoflush - to avoid line buffering
while(){
while($x = getc(FH)){
$n = ord($x);if($a>=1){$tmp.=$n; $a++;}
if($n==9 || $n==10){$a=1;$tmp=$n;$k = ($n eq "9"?"0":"1"); }
if($left eq $tmp || $right eq $tmp && ($a==6 || $a==7) ){ $d.=$k;
if(substr($d,$b,1) eq substr($data,$b,1)){$b++;if($d eq $data){$d="";$b=0;system("echo 'hi'");}} else {
if($k==substr($data,0,1)){$d=$k;$b=1;} else {$d = ""; $b=0; } }
$a=0;
$tmp="";
}}}

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: