Net-VNC
view release on metacpan or search on metacpan
lib/Net/VNC.pm view on Meta::CPAN
sub mouse_move_to {
my ( $self, $x, $y ) = @_;
$self->send_pointer_event( 0, $x, $y );
my $cursordata = $self->_cursordata;
if ( !$cursordata ) {
$self->_cursordata( $cursordata = {} );
}
$cursordata->{x} = $x;
$cursordata->{y} = $y;
}
sub mouse_click {
my ($self) = @_;
my $cursordata = $self->_cursordata;
if ( !$cursordata ) {
$self->_cursordata( $cursordata = { x => 0, y => 0 } );
}
$self->send_pointer_event( 1, $cursordata->{x}, $cursordata->{y} );
$self->send_pointer_event( 0, $cursordata->{x}, $cursordata->{y} );
}
sub mouse_right_click {
my ($self) = @_;
my $cursordata = $self->_cursordata;
if ( !$cursordata ) {
$self->_cursordata( $cursordata = { x => 0, y => 0 } );
}
$self->send_pointer_event( 4, $cursordata->{x}, $cursordata->{y} );
$self->send_pointer_event( 0, $cursordata->{x}, $cursordata->{y} );
}
1;
__END__
=head1 NAME
Net::VNC - A simple VNC client
=head1 SYNOPSIS
use Net::VNC;
my $vnc = Net::VNC->new({hostname => $hostname, password => $password});
$vnc->depth(24);
$vnc->login;
print $vnc->name . ": " . $vnc->width . ' x ' . $vnc->height . "\n";
my $image = $vnc->capture;
$image->save("out.png");
=head1 DESCRIPTION
Virtual Network Computing (VNC) is a desktop sharing system which uses
the RFB (Remote FrameBuffer) protocol to remotely control another
computer. This module acts as a VNC client and communicates to a VNC
server using the RFB protocol, allowing you to capture the screen of
the remote computer.
This module dies upon connection errors (with a timeout of 15 seconds)
and protocol errors.
This implementation is based largely on the RFB Protocol
Specification, L<http://www.realvnc.com/docs/rfbproto.pdf>. That
document has an error in the DES encryption description, which is
clarified via L<http://www.vidarholen.net/contents/junk/vnc.html>.
=head1 METHODS
=head2 new
The constructor. Given a hostname and a password returns a L<Net::VNC> object:
my $vnc = Net::VNC->new({hostname => $hostname, password => $password});
Optionally, you can also specify a port, which defaults to 5900. For ARD
(Apple Remote Desktop) authentication you must also specify a username.
You must also install Crypt::GCrypt::MPI and Crypt::Random.
=head2 login
Logs into the remote computer:
$vnc->login;
=head2 name
Returns the name of the remote computer:
print $vnc->name . ": " . $vnc->width . ' x ' . $vnc->height . "\n";
=head2 width
Returns the width of the remote screen:
print $vnc->name . ": " . $vnc->width . ' x ' . $vnc->height . "\n";
=head2 height
Returns the height of the remote screen:
print $vnc->name . ": " . $vnc->width . ' x ' . $vnc->height . "\n";
=head2 capture
Captures the screen of the remote computer, returning an L<Image::Imlib2> object:
my $image = $vnc->capture;
$image->save("out.png");
You may call capture() multiple times. Each time, the C<$image>
buffer is overwritten with the updated screen. So, to create a
series of ten screen shots:
( run in 1.264 second using v1.01-cache-2.11-cpan-39bf76dae61 )