File: usage.rst

package info (click to toggle)
vncdotool 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 384 kB
  • sloc: python: 3,066; makefile: 195
file content (113 lines) | stat: -rw-r--r-- 3,648 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
Usage
==============


Basic Usage
-------------
Once installed you can use the vncdotool command to send key-presses.
Alphanumerics are straightforward just specify the character.  For other
keys longer names are used::

    > vncdo key a
    > vncdo key 5
    > vncdo key .
    > vncdo key enter
    > vncdo key shift-a
    > vncdo key ctrl-C
    > vncdo key ctrl-alt-del

To type longer strings when entering data or commands you can use the type c
command, which does not support special characters::

    > vncdo type "hello world"

You can control the mouse pointer with move and click commands.
NOTE, you should almost always issue a move before a click, as in::

    > vncdo move 100 100 click 1

The following would seem to be equivalent but would actually click at (0, 0).
This occurs due to how click events are encoded by VNC, meaning you need to initialise the position of the mouse.::

    > vncdo move 100 100
    > vncdo click 1

If you have the Python Imaging Library (Pillow_) installed you can also
make screen captures of the session::

    > vncdo capture screenshot.png

With Pillow_ installed, you can wait for the screen to match a known image::

    > vncdo expect somescreen.png 0

Putting it all together you can specify multiple actions on a single
command line.  You could automate a login with the following::

    > vncdo type username key enter expect password_prompt.png
    > vncdo type password move 100 150 click 1 expect welcome_screen.png

Sometimes you only care about a portion of the screen, in which case you can
use rcapture and rexpect. For instance, if your login window appears at
x=100, y=200 and is 400 pixels wide by 250 high you could do::

    > vncdo rcapture region.png 100 200 400 250
    > vncdo rexpect region.png 100 200 0


Running Scripts
-------------------
For more complex automation you can read commands from stdin or a file.
The file format is simply a collection of actions::

    > echo "type hello" | vncdo -

Or if you had a file called login.vdo with the following content::

    # select the name text box, enter your name and submit
    move 100 100 click 1 type "my name" key tab key enter

    # grab the result
    capture screenshot.png

You could run it with the following command::

    > vncdo login.vdo


Creating Scripts
------------------
While you can create scripts by hand it can often be a time consuming process.
To make the process easier vncdotool provides a log mode that allows a user to 
record a VNC session to a script which is playable by vncdo.  vnclog act as a
man-in-the-middle to record the VNC commands you issue with a client. So you
will have your vnclog connect to your server and your viewer connect to vnclog

    vncviewer ---> vnclog ---> vncserver

For best results be sure to set your vncviewer client to use the RAW encoding.
Others encoding may work but are not fully supported at this time.

The quickest way to get started is to run::

    > vnclog --viewer vncviewer keylog.vdo

For more control you can launch the viewer separately but be sure to connect
to the correct ports::

    > vnclog keylog.vdo
    > vncviewer localhost:2  # do something and then exit viewer
    > vncdo keylog.vdo

By running with --forever vnclog will create a new file for every client
connection and record each clients activity.
This can be useful for quickly recording a number of testcases.::

    > vnclog --forever --listen 6000 /tmp
    > vncviewer localhost::6000
    # do some stuff then exit and start new session
    > vncviewer localhost::6000
    # do some other stuff
    > ls /tmp/*.vdo

.. _Pillow: http://www.pythonware.com/products/pil