|
NAMENet::VNC - A simple VNC clientSYNOPSISuse 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"); DESCRIPTIONVirtual 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, <http://www.realvnc.com/docs/rfbproto.pdf>. That document has an error in the DES encryption description, which is clarified via <http://www.vidarholen.net/contents/junk/vnc.html>. METHODSnewThe constructor. Given a hostname and a password returns a 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. loginLogs into the remote computer:$vnc->login; nameReturns the name of the remote computer:print $vnc->name . ": " . $vnc->width . ' x ' . $vnc->height . "\n"; widthReturns the width of the remote screen:print $vnc->name . ": " . $vnc->width . ' x ' . $vnc->height . "\n"; heightReturns the height of the remote screen:print $vnc->name . ": " . $vnc->width . ' x ' . $vnc->height . "\n"; captureCaptures the screen of the remote computer, returning an Image::Imlib2 object:my $image = $vnc->capture; $image->save("out.png"); You may call capture() multiple times. Each time, the $image buffer is overwritten with the updated screen. So, to create a series of ten screen shots: for my $n (1..10) { my $filename = sprintf 'snapshot%02d.png', $n++; $vnc->capture()->save($filename); print "Wrote $filename\n"; } depthSpecify the bit depth for the screen. The supported choices are 24, 16 or 8. If unspecified, the server's default value is used. This property should be set before the call to login().save_bandwidthAccepts a boolean, defaults to false. Specifies whether to use more CPU-intensive algorithms to compress the VNC datastream. LAN or localhost connections may prefer to leave this false. This property should be set before the call to login().list_encodingsReturns a list of encoding number/encoding name pairs. This can be used as a class method like so:my %encodings = Net::VNC->list_encodings(); send_key_event_downSend a key down event. The keys are the same as the corresponding ASCII value. Other common keys:BackSpace 0xff08 Tab 0xff09 Return or Enter 0xff0d Escape 0xff1b Insert 0xff63 Delete 0xffff Home 0xff50 End 0xff57 Page Up 0xff55 Page Down 0xff56 Left 0xff51 Up 0xff52 Right 0xff53 Down 0xff54 F1 0xffbe F2 0xffbf F3 0xffc0 F4 0xffc1 ... ... F12 0xffc9 Shift (left) 0xffe1 Shift (right) 0xffe2 Control (left) 0xffe3 Control (right) 0xffe4 Meta (left) 0xffe7 Meta (right) 0xffe8 Alt (left) 0xffe9 Alt (right) 0xffea $vnc->send_key_event_down('A'); send_key_event_upSend a key up event:$vnc->send_key_event_up('A'); send_key_eventSend a key down event followed by a key up event:$vnc->send_key_event('A'); send_key_event_stringSend key events for every character in a string:$vnc->send_key_event_string('Hello'); send_pointer_event( $button_mask, $x, $y )Send pointer event (usually a mouse). This is used to move the pointer or make clicks or drags.It is easier to call the "mouse_move" or <mouse_click> methods instead. mouse_move_to($x, $y)Send the pointer to the given position. The cursor instantly jumps there instead of smoothly moving to there.mouse_clickClick on current pointer position.mouse_right_clickRight-click on current pointer position.BUGS AND LIMITATIONSBit depthWe do not yet support 8-bit true-colour mode, which is commonly supported by servers but is rarely employed by clients.Byte orderWe have currently tested this package against servers with the same byte order as the client. This might break with a little-endian server/big-endian client or vice versa. We're working on tests for those latter cases. Testing and patching help would be appreciated.EfficiencyWe've implemented a subset of the data compression algorithms supported by most VNC servers. We hope to add more of the high-compression transfer encodings in the future.AUTHORSLeon Brocard acme@astray.comChris Dolan clotho@cpan.org Apple Remote Desktop authentication based on LibVNCServer Maurice Castro maurice@ipexchange.com.au Many thanks for Foxtons Ltd for giving Leon the opportunity to write the original version of this module. Copyright (C) 2006, Leon Brocard This module is free software; you can redistribute it or modify it under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |