guibot.desktopcontrol module

class guibot.desktopcontrol.DesktopControl(configure=True, synchronize=True)[source]

Bases: guibot.config.LocalConfig

Desktop control backend, responsible for performing desktop operations like mouse clicking, key pressing, text typing, etc.

__init__(configure=True, synchronize=True)[source]

Build a desktop control backend.

width

Getter for readonly attribute.

Returns:width of the connected screen
Return type:int
height

Getter for readonly attribute.

Returns:height of the connected screen
Return type:int
keymap

Getter for readonly attribute.

Returns:map of keys to be used for the connected screen
Return type:inputmap.Key
mousemap

Getter for readonly attribute.

Returns:map of mouse buttons to be used for the connected screen
Return type:inputmap.MouseButton
modmap

Getter for readonly attribute.

Returns:map of modifier keys to be used for the connected screen
Return type:inputmap.KeyModifier
mouse_location

Getter for readonly attribute.

Returns:location of the mouse pointer
Return type:location.Location
configure_backend(backend=None, category='control', reset=False)[source]

Custom implementation of the base method.

See base method for details.

synchronize_backend(backend=None, category='type', reset=False)[source]

Custom implementation of the base method.

See base method for details.

Select a backend for the instance, synchronizing configuration like screen size, key map, mouse pointer handling, etc. The object that carries this configuration is called screen.

capture_screen(*args)[source]

Get the current screen as image.

Parameters:args ([int] or region.Region or None) – region’s (x, y, width, height) or a region object or nothing to obtain an image of the full screen
Returns:image of the current screen
Return type:image.Image
Raises:NotImplementedError if the base class method is called
mouse_move(location, smooth=True)[source]

Move the mouse to a desired location.

Parameters:
  • location (location.Location) – location on the screen to move to
  • smooth (bool) – whether to sue smooth transition or just teleport the mouse
Raises:

NotImplementedError if the base class method is called

mouse_click(button=None, count=1, modifiers=None)[source]

Click the selected mouse button N times at the current mouse location.

Parameters:
  • button (int or None) – mouse button, e.g. self.mouse_map.LEFT_BUTTON
  • count (int) – number of times to click
  • modifiers ([str]) – special keys to hold during clicking (see inputmap.KeyModifier for extensive list)
Raises:

NotImplementedError if the base class method is called

mouse_down(button)[source]

Hold down a mouse button.

Parameters:button (int) – button index depending on backend (see inputmap.MouseButton for extensive list)
Raises:NotImplementedError if the base class method is called
mouse_up(button)[source]

Release a mouse button.

Parameters:button (int) – button index depending on backend (see inputmap.MouseButton for extensive list)
Raises:NotImplementedError if the base class method is called
keys_toggle(keys, up_down)[source]

Hold down or release together all provided keys.

Parameters:
  • keys ([str] or str (no special keys in the second case)) – characters or special keys depending on the backend (see inputmap.Key for extensive list)
  • up_down (bool) – hold down if true else release
Raises:

NotImplementedError if the base class method is called

keys_press(keys)[source]

Press (hold down and release) together all provided keys.

Parameters:keys ([str] or str (no special keys in the second case)) – characters or special keys depending on the backend (see inputmap.Key for extensive list)
keys_type(text, modifiers)[source]

Type (press consecutively) all provided keys.

Parameters:
  • text ([str] or str (second case is preferred and first redundant)) – characters only (no special keys allowed)
  • modifiers ([str]) – special keys to hold during typing (see inputmap.KeyModifier for extensive list)
Raises:

NotImplementedError if the base class method is called

class guibot.desktopcontrol.AutoPyDesktopControl(configure=True, synchronize=True)[source]

Bases: guibot.desktopcontrol.DesktopControl

Desktop control backend implemented through AutoPy which is a small python library portable to Windows and Linux operating systems.

__init__(configure=True, synchronize=True)[source]

Build a DC backend using AutoPy.

configure_backend(backend=None, category='autopy', reset=False)[source]

Custom implementation of the base method.

See base method for details.

synchronize_backend(backend=None, category='autopy', reset=False)[source]

Custom implementation of the base method.

See base method for details.

capture_screen(*args)[source]

Custom implementation of the base method.

See base method for details.

mouse_move(location, smooth=True)[source]

Custom implementation of the base method.

See base method for details.

mouse_click(button=None, count=1, modifiers=None)[source]

Custom implementation of the base method.

See base method for details.

mouse_down(button)[source]

Custom implementation of the base method.

See base method for details.

mouse_up(button)[source]

Custom implementation of the base method.

See base method for details.

keys_toggle(keys, up_down)[source]

Custom implementation of the base method.

See base method for details.

keys_type(text, modifiers)[source]

Custom implementation of the base method.

See base method for details.

class guibot.desktopcontrol.XDoToolDesktopControl(configure=True, synchronize=True)[source]

Bases: guibot.desktopcontrol.DesktopControl

Desktop control backend implemented through the xdotool client and thus portable to Linux operating systems.

__init__(configure=True, synchronize=True)[source]

Build a DC backend using XDoTool.

configure_backend(backend=None, category='xdotool', reset=False)[source]

Custom implementation of the base method.

See base method for details.

synchronize_backend(backend=None, category='xdotool', reset=False)[source]

Custom implementation of the base method.

See base method for details.

capture_screen(*args)[source]

Custom implementation of the base method.

See base method for details.

mouse_move(location, smooth=True)[source]

Custom implementation of the base method.

See base method for details.

mouse_click(button=None, count=3, modifiers=None)[source]

Custom implementation of the base method.

See base method for details.

mouse_down(button)[source]

Custom implementation of the base method.

See base method for details.

mouse_up(button)[source]

Custom implementation of the base method.

See base method for details.

keys_toggle(keys, up_down)[source]

Custom implementation of the base method.

See base method for details.

keys_type(text, modifiers)[source]

Custom implementation of the base method.

See base method for details.

class guibot.desktopcontrol.VNCDoToolDesktopControl(configure=True, synchronize=True)[source]

Bases: guibot.desktopcontrol.DesktopControl

Desktop control backend implemented through the VNCDoTool client and thus portable to any guest OS that is accessible through a VNC/RFB protocol.

__init__(configure=True, synchronize=True)[source]

Build a DC backend using VNCDoTool.

configure_backend(backend=None, category='vncdotool', reset=False)[source]

Custom implementation of the base method.

See base method for details.

synchronize_backend(backend=None, category='vncdotool', reset=False)[source]

Custom implementation of the base method.

See base method for details.

capture_screen(*args)[source]

Custom implementation of the base method.

See base method for details.

mouse_move(location, smooth=True)[source]

Custom implementation of the base method.

See base method for details.

mouse_click(button=None, count=3, modifiers=None)[source]

Custom implementation of the base method.

See base method for details.

mouse_down(button)[source]

Custom implementation of the base method.

See base method for details.

mouse_up(button)[source]

Custom implementation of the base method.

See base method for details.

keys_toggle(keys, up_down)[source]

Custom implementation of the base method.

See base method for details.

keys_type(text, modifiers)[source]

Custom implementation of the base method.

See base method for details.

class guibot.desktopcontrol.QemuDesktopControl(configure=True, synchronize=True)[source]

Bases: guibot.desktopcontrol.DesktopControl

Desktop control backend implemented through the Qemu emulator and thus portable to any guest OS that runs on virtual machine.

Note

This backend can be used in accord with a qemu monitor object (python) provided by a library like virt-test.

__init__(configure=True, synchronize=True)[source]

Build a DC backend using Qemu.

configure_backend(backend=None, category='qemu', reset=False)[source]

Custom implementation of the base method.

See base method for details.

synchronize_backend(backend=None, category='qemu', reset=False)[source]

Custom implementation of the base method.

Raises:ValueError if control backend is ‘qemu’ and no monitor is selected

See base method for details.

capture_screen(*args)[source]

Custom implementation of the base method.

See base method for details.

mouse_move(location, smooth=True)[source]

Custom implementation of the base method.

See base method for details.

mouse_click(button=None, count=3, modifiers=None)[source]

Custom implementation of the base method.

See base method for details.

mouse_down(button)[source]

Custom implementation of the base method.

See base method for details.

mouse_up(button)[source]

Custom implementation of the base method.

See base method for details.

keys_toggle(keys, up_down)[source]

Custom implementation of the base method.

See base method for details.

keys_type(text, modifiers)[source]

Custom implementation of the base method.

See base method for details.