Skip to content

Commit

Permalink
rename main command from vncdotool to vncdo
Browse files Browse the repository at this point in the history
  • Loading branch information
sibson committed Nov 13, 2012
1 parent 7d6f34e commit 554d955
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 55 deletions.
10 changes: 7 additions & 3 deletions NEWS.txt
@@ -1,14 +1,18 @@
vncdotool - 0.3.0 (unreleased)
------------------------------------
- main program renamed to vncdo, vncdotool continues an alias for now
- read/play commands from stdin or file
- proxy/record modes to create scripts from interactive sessions
- better control over mouse in screen captures with --nocursor
and --localcursor
- mousemove, sleep command aliases to match xdotool
- keyup/keydown commands for more control over keypresses
- send SetEncodings on connect, thanks Matias Suarez for fix
- read/play commands from stdin or file
- debian packaging
- allow default delay between all commands
- proxy/record modes to create scripts from interactive sessions
- type "Hello World" now preserves capitalization
- mousemove, sleep command aliases to match xdotool
- don't immediately give up on VNC 4.0 servers
- improved frameUpdate handling

vncdotool - 0.2.0 (2012-08-07)
--------------------------------
Expand Down
49 changes: 26 additions & 23 deletions README.rst
Expand Up @@ -35,49 +35,49 @@ 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::

> vncdotool key a
> vncdotool key 5
> vncdotool key .
> vncdotool key enter
> vncdotool key shift-a
> vncdotool key ctrl-C
> vncdotool key ctrl-alt-del
> 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::

> vncdotool type "hello world"
> 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::

> vncdotool move 100 100 click 1
> 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.

> vncdotool move 100 100
> vncdotool click 1
> vncdo move 100 100
> vncdo click 1

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

> vncdotool capture screenshot.png
> vncdo capture screenshot.png

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

> vncdotool expect somescreen.png 0
> 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::

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

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" | vncdotool -
> echo "type hello" | vncdo -

> cat some_file.vdo
# select the name text box, enter your name and submit
Expand All @@ -86,26 +86,29 @@ The file format is simply a collection of actions::
# grab the result
capture screenshot.png

> vncdotool some_file.vdo
> vncdo some_file.vdo

Creating long lists of commands can be time consuming so vncdotool provides
a record mode that logs messages and screen captures.
For best results set your client to use the RAW encoding.
Others encoding may work but are not fully supported at this time.

As the log is a text file you can edit it to tweak the behaviour.::

> vncdotool record 6000 vnc.vdo
> vncdo record 6000 vnc.vdo
> vncviewer localhost:6000
> sed -i s/click 1/click 2/ vnc.vdo
> vncdotool vnc.vdo
> vncdo vnc.vdo

For convience you can launch a VNCViewer connected to a vncdotool in record mode with::
It may be more convient to automatically launch a VNC client connected to vncdotool in record mode with::

> vncdotool viewer somefile.vdo
> vncdo viewer somefile.vdo

By running in service mode vncdotool 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.::

> vncdotool service 6000
> vncviewer localhost:6000
> vncdo service 6000
> vncviewer localhost:6000 # then exit and start new session
> vncviewer localhost:6000

Feedback
Expand Down
5 changes: 0 additions & 5 deletions scripts/vncdotool

This file was deleted.

7 changes: 6 additions & 1 deletion setup.py
Expand Up @@ -21,7 +21,12 @@
author_email='sibson+vncdotool@gmail.com',
download_url='',

scripts=['scripts/vncdotool'],
entry_points={
"console_scripts": [
'vncdo=vncdotool.command:main',
'vncdotool=vncdotool.command:main',
],
},
packages=['vncdotool'],

classifiers=[
Expand Down
12 changes: 6 additions & 6 deletions tests/functional/test_proxy.py
Expand Up @@ -10,7 +10,7 @@ def setUp(self):
self.server = pexpect.spawn(cmd, timeout=2)
self.server.logfile_read = sys.stdout

cmd = 'vncdotool -d 99 record 1842 -'
cmd = 'vncdo -d 99 record 1842 -'
self.logger = pexpect.spawn(cmd, timeout=2)
self.logger.logfile_read = sys.stdout

Expand All @@ -19,8 +19,8 @@ def tearDown(self):
if self.logger:
self.logger.terminate(force=True)

def run_vncdotool(self, commands):
cmd = 'vncdotool -s localhost:1842 ' + commands
def run_vncdo(self, commands):
cmd = 'vncdo -s localhost:1842 ' + commands
vnc = pexpect.spawn(cmd, logfile=sys.stdout, timeout=2)
retval = vnc.wait()
assert retval == 0, (retval, str(vnc))
Expand All @@ -38,7 +38,7 @@ def assertMouse(self, x, y, buttonmask):
self.server.expect(output)

def test_key_alpha(self):
self.run_vncdotool('key z')
self.run_vncdo('key z')

self.assertKeyDown(ord('z'))
self.assertKeyUp(ord('z'))
Expand All @@ -47,14 +47,14 @@ def test_key_alpha(self):
self.logger.expect('keyup z')

def test_key_ctrl_a(self):
self.run_vncdotool('key ctrl-a')
self.run_vncdo('key ctrl-a')
self.assertKeyDown(rfb.KEY_ControlLeft)
self.assertKeyDown(ord('a'))
self.assertKeyUp(rfb.KEY_ControlLeft)
self.assertKeyUp(ord('a'))

def test_mouse(self):
self.run_vncdotool('move 111 222 click 1')
self.run_vncdo('move 111 222 click 1')
self.assertMouse(111, 222, 1)
self.logger.expect('move 111 222')
self.logger.expect('click 1')
18 changes: 9 additions & 9 deletions tests/functional/test_screen.py
Expand Up @@ -34,8 +34,8 @@ def run_server(self, server):
self.server = pexpect.spawn(cmd, timeout=2)
self.server.logfile_read = sys.stdout

def run_vncdotool(self, commands, exitcode=0):
cmd = 'vncdotool -d 10 ' + commands
def run_vncdo(self, commands, exitcode=0):
cmd = 'vncdo -d 10 ' + commands
vnc = pexpect.spawn(cmd, logfile=sys.stdout, timeout=5)
vnc.logfile_read = sys.stdout
vnc.expect(pexpect.EOF)
Expand All @@ -53,42 +53,42 @@ def assertFilesEqual(self, filename, othername):
def testCaptureExample(self):
fname = self.mktemp()
self.run_server('example')
self.run_vncdotool('move 150 100 capture %s' % fname)
self.run_vncdo('move 150 100 capture %s' % fname)
self.assertFilesEqual(fname, EXAMPLE_PNG)

def testCaptureCapture(self):
f1 = self.mktemp()
f2 = self.mktemp()

self.run_server('example')
self.run_vncdotool('move 150 100 capture %s capture %s' % (f1, f2))
self.run_vncdo('move 150 100 capture %s capture %s' % (f1, f2))
self.assertFilesEqual(f1, EXAMPLE_PNG)
self.assertFilesEqual(f2, f1)

def testCaptureNoCursor(self):
fname = self.mktemp()
self.run_server('example')
self.run_vncdotool('--nocursor move 150 100 pause 0.1 capture %s' % fname)
self.run_vncdo('--nocursor move 150 100 pause 0.1 capture %s' % fname)
self.assertFilesEqual(fname, EXAMPLE_NOCURSOR_PNG)

def testCaptureLocalCursor(self):
fname = self.mktemp()
self.run_server('example')
self.run_vncdotool('--localcursor move 150 100 pause 0.1 capture %s' % fname)
self.run_vncdo('--localcursor move 150 100 pause 0.1 capture %s' % fname)
self.assertFilesEqual(fname, EXAMPLE_PNG)

def testExpectExampleExactly(self):
self.run_server('example')
self.run_vncdotool('move 150 100 pause 0.1 expect %s 0' % EXAMPLE_PNG)
self.run_vncdo('move 150 100 pause 0.1 expect %s 0' % EXAMPLE_PNG)

def testExpectExampleSloppy(self):
self.run_server('example')
self.run_vncdotool('move 200 100 expect %s 25' % EXAMPLE_PNG)
self.run_vncdo('move 200 100 expect %s 25' % EXAMPLE_PNG)

def testExpectFailsExample(self):
self.run_server('example')
try:
self.run_vncdotool('expect %s 0' % SIMPLE_PNG, exitcode=10)
self.run_vncdo('expect %s 0' % SIMPLE_PNG, exitcode=10)
except pexpect.TIMEOUT:
pass
else:
Expand Down
16 changes: 8 additions & 8 deletions tests/functional/test_send_events.py
Expand Up @@ -35,20 +35,20 @@ def assertDisconnect(self):
disco = 'Client 127.0.0.1 gone'
self.server.expect(disco)

def run_vncdotool(self, commands):
cmd = 'vncdotool -d 33 ' + commands
def run_vncdo(self, commands):
cmd = 'vncdo -d 33 ' + commands
vnc = pexpect.spawn(cmd, logfile=sys.stdout, timeout=5)
retval = vnc.wait()
assert retval == 0, retval

def test_key_alpha(self):
self.run_vncdotool('key z')
self.run_vncdo('key z')
self.assertKeyDown(ord('z'))
self.assertKeyUp(ord('z'))
self.assertDisconnect()

def test_key_ctrl_a(self):
self.run_vncdotool('key ctrl-a')
self.run_vncdo('key ctrl-a')
self.assertKeyDown(int(0xffe3))
self.assertKeyDown(ord('a'))
self.assertKeyUp(int(0xffe3))
Expand All @@ -57,25 +57,25 @@ def test_key_ctrl_a(self):

def test_type(self):
string = 'abcdefghij'
self.run_vncdotool('type %s' % string)
self.run_vncdo('type %s' % string)
for key in string:
self.assertKeyDown(ord(key))
self.assertKeyUp(ord(key))
self.assertDisconnect()

def test_mouse_move(self):
# vncev only prints click events, but will include the position
self.run_vncdotool('move 10 20 click 1')
self.run_vncdo('move 10 20 click 1')
self.assertMouse(10, 20, 0x1)
self.assertDisconnect()

def test_mouse_click_button_two(self):
self.run_vncdotool('click 2')
self.run_vncdo('click 2')
self.assertMouse(0, 0, 0x2)
self.assertDisconnect()

def test_read_files(self):
self.run_vncdotool('key x %s key y %s' % (KEYA_VDO, KEYB_VDO))
self.run_vncdo('key x %s key y %s' % (KEYA_VDO, KEYB_VDO))
for key in 'xayb':
self.assertKeyDown(ord(key))
self.assertKeyUp(ord(key))

0 comments on commit 554d955

Please sign in to comment.