diff options
author | dscho <dscho> | 2006-10-10 16:25:32 +0000 |
---|---|---|
committer | dscho <dscho> | 2006-10-10 16:25:32 +0000 |
commit | 5092a3b56fe7b5f0a6b181e98756e406aebe2dc6 (patch) | |
tree | 9767bd3af6dc3ef0630d08d8b14bbd63c1f1887d /VisualNaCro/recorder.pl | |
parent | 4af738e0c8b561b6f15c614037cc0ea5d1ccfd80 (diff) | |
download | libtdevnc-5092a3b56fe7b5f0a6b181e98756e406aebe2dc6.tar.gz libtdevnc-5092a3b56fe7b5f0a6b181e98756e406aebe2dc6.zip |
VisualNaCro: add --compact and --compact-dragging
Diffstat (limited to 'VisualNaCro/recorder.pl')
-rw-r--r-- | VisualNaCro/recorder.pl | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/VisualNaCro/recorder.pl b/VisualNaCro/recorder.pl index f138392..d83551e 100644 --- a/VisualNaCro/recorder.pl +++ b/VisualNaCro/recorder.pl @@ -3,22 +3,24 @@ use Getopt::Long; use nacro; -# TODO: take options - $output="my_script"; $server="localhost"; $port=5900; $listen_port=5923; $timing=0; $symbolic=0; +$compact=0; +$compact_dragging=0; if(!GetOptions( "script:s" => \$output, "listen:i" => \$listen_port, "timing" => \$timing, "symbolic" => \$symbolic, + "compact" => \$compact, + "compact-dragging" => \$compact_dragging, ) || $#ARGV!=0) { - print STDERR "Usage: $ARGV0 [--script output_name] [--listen listen_port] [--timing] [--symbolic] server[:port]\n"; + print STDERR "Usage: $ARGV0 [--script output_name] [--listen listen_port] [--timing]\n\t[--symbolic] [--compact] [--compact-dragging] server[:port]\n"; exit 2; } @@ -91,6 +93,21 @@ sub writetiming () { } } +$last_button = -1; + +sub handle_mouse { + my $x = shift; + my $y = shift; + my $buttons = shift; + 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"; + } +} + while(1) { $result=nacro::waitforinput($vnc,999999); if($result==0) { @@ -129,13 +146,18 @@ while(1) { $x=nacro::getx($vnc); $y=nacro::gety($vnc); $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"; + if ($buttons != $last_buttons) { + if (!$buttons && $compact_dragging) { + handle_mouse($x, $y, $last_buttons); + } + $last_buttons = $buttons; + } else { + if (($buttons && $compact_dragging) || + (!$buttons && $compact)) { + next; + } } + handle_mouse($x, $y, $buttons); } if ($result & $nacro::RESULT_TEXT_CLIENT) { my $text = nacro::gettext_client($vnc); @@ -188,6 +210,7 @@ while(1) { $x=nacro::getx($vnc); $y=nacro::gety($vnc); if($start_x==$x && $start_y==$y) { + # reset print OUT "\$x_origin=0; \$y_origin=0;\n"; } else { if($start_x>$x) { |