diff options
author | dscho <dscho> | 2006-06-15 12:24:14 +0000 |
---|---|---|
committer | dscho <dscho> | 2006-06-15 12:24:14 +0000 |
commit | afcdc4f4b25f5568b4082d5c240bda1ea866d5e6 (patch) | |
tree | 78aae165b896b1e6c8c205f2541cbe528a085bf3 /VisualNaCro/recorder.pl | |
parent | 06a401f8f81b1fcf94bce6c99e4823d6e697881c (diff) | |
download | libtdevnc-afcdc4f4b25f5568b4082d5c240bda1ea866d5e6.tar.gz libtdevnc-afcdc4f4b25f5568b4082d5c240bda1ea866d5e6.zip |
add timing
Diffstat (limited to 'VisualNaCro/recorder.pl')
-rw-r--r-- | VisualNaCro/recorder.pl | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/VisualNaCro/recorder.pl b/VisualNaCro/recorder.pl index bbe3f25..3b86e40 100644 --- a/VisualNaCro/recorder.pl +++ b/VisualNaCro/recorder.pl @@ -9,10 +9,12 @@ $output="my_script"; $server="localhost"; $port=5900; $listen_port=5923; +$timing=0; if(!GetOptions( "script:s" => \$output, - "listen:i" => \$listen_port + "listen:i" => \$listen_port, + "timing" => \$timing ) || $#ARGV!=0) { print STDERR "Usage: $ARGV0 [--script output_name] [--listen listen_port] server[:port]\n"; exit 2; @@ -20,6 +22,11 @@ if(!GetOptions( $output=~s/\.pl$//; +if ($timing) { + use Time::HiRes qw(time); + $starttime=-1; +} + $server=$ARGV[0]; if($server=~/^(.*):(\d+)$/) { @@ -55,6 +62,9 @@ open OUT, ">$output.pl"; print OUT "#!/usr/bin/perl\n"; print OUT "\n"; print OUT "use nacro;\n"; +if ($timing) { + print OUT "use Time::HiRes;" +} print OUT "\n"; print OUT "\$x_origin=0; \$y_origin=0;\n"; print OUT "\$vnc=nacro::initvnc(\"$server\",$port,$listen_port);\n"; @@ -64,6 +74,16 @@ $image_counter=1; $magickey=0; $x_origin=0; $y_origin=0; +sub writetiming () { + if ($timing) { + $now=time(); + if ($starttime>0) { + print OUT "nacro::process(\$vnc," . ($now - $starttime) . ");\n"; + } + $starttime=$now; + } +} + while(1) { $result=nacro::waitforinput($vnc,999999); if($result==0) { @@ -77,6 +97,7 @@ while(1) { $keysym=nacro::getkeysym($vnc); $keydown=nacro::getkeydown($vnc); if(nacro::sendkey($vnc,$keysym,$keydown)) { + writetiming(); print OUT "nacro::sendkey(\$vnc,$keysym,$keydown);\n"; } if($keysym==0xffe3 || $keysym==0xffe4) { @@ -98,6 +119,7 @@ while(1) { $buttons=nacro::getbuttons($vnc); if(nacro::sendmouse($vnc,$x,$y,$buttons)) { $x-=$x_origin; $y-=$y_origin; + writetiming(); print OUT "nacro::sendmouse(\$vnc,\$x_origin" . ($x>=0?"+":"")."$x,\$y_origin" . ($y>=0?"+":"")."$y,$buttons);\n"; |