VisualNaCro: add --compact and --compact-dragging

pull/1/head
dscho 18 years ago
parent 4af738e0c8
commit 5092a3b56f

@ -1,3 +1,11 @@
2006-10-10: Johannes Schindelin <Johannes.Schindelin@gmx.de>
* implement --compact and --compact-dragging to shut up the
script about mouse movements or drags.
2006-09-12: Johannes Schindelin <Johannes.Schindelin@gmx.de>
* the reference rectangle is selected with a rubber band,
and can be shown with 'd'.
2006-06-15: Johannes Schindelin <Johannes.Schindelin@gmx.de> 2006-06-15: Johannes Schindelin <Johannes.Schindelin@gmx.de>
* added timing: you can record the events with their timestamps now * added timing: you can record the events with their timestamps now

@ -3,22 +3,24 @@
use Getopt::Long; use Getopt::Long;
use nacro; use nacro;
# TODO: take options
$output="my_script"; $output="my_script";
$server="localhost"; $server="localhost";
$port=5900; $port=5900;
$listen_port=5923; $listen_port=5923;
$timing=0; $timing=0;
$symbolic=0; $symbolic=0;
$compact=0;
$compact_dragging=0;
if(!GetOptions( if(!GetOptions(
"script:s" => \$output, "script:s" => \$output,
"listen:i" => \$listen_port, "listen:i" => \$listen_port,
"timing" => \$timing, "timing" => \$timing,
"symbolic" => \$symbolic, "symbolic" => \$symbolic,
"compact" => \$compact,
"compact-dragging" => \$compact_dragging,
) || $#ARGV!=0) { ) || $#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; 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) { while(1) {
$result=nacro::waitforinput($vnc,999999); $result=nacro::waitforinput($vnc,999999);
if($result==0) { if($result==0) {
@ -129,13 +146,18 @@ while(1) {
$x=nacro::getx($vnc); $x=nacro::getx($vnc);
$y=nacro::gety($vnc); $y=nacro::gety($vnc);
$buttons=nacro::getbuttons($vnc); $buttons=nacro::getbuttons($vnc);
if(nacro::sendmouse($vnc,$x,$y,$buttons)) { if ($buttons != $last_buttons) {
$x-=$x_origin; $y-=$y_origin; if (!$buttons && $compact_dragging) {
writetiming(); handle_mouse($x, $y, $last_buttons);
print OUT "nacro::sendmouse(\$vnc,\$x_origin" }
. ($x>=0?"+":"")."$x,\$y_origin" $last_buttons = $buttons;
. ($y>=0?"+":"")."$y,$buttons);\n"; } else {
if (($buttons && $compact_dragging) ||
(!$buttons && $compact)) {
next;
}
} }
handle_mouse($x, $y, $buttons);
} }
if ($result & $nacro::RESULT_TEXT_CLIENT) { if ($result & $nacro::RESULT_TEXT_CLIENT) {
my $text = nacro::gettext_client($vnc); my $text = nacro::gettext_client($vnc);
@ -188,6 +210,7 @@ while(1) {
$x=nacro::getx($vnc); $x=nacro::getx($vnc);
$y=nacro::gety($vnc); $y=nacro::gety($vnc);
if($start_x==$x && $start_y==$y) { if($start_x==$x && $start_y==$y) {
# reset
print OUT "\$x_origin=0; \$y_origin=0;\n"; print OUT "\$x_origin=0; \$y_origin=0;\n";
} else { } else {
if($start_x>$x) { if($start_x>$x) {

Loading…
Cancel
Save