guibot.controller module

SUMMARY

Display controllers (DC backends) to perform user operations.

INTERFACE

class guibot.controller.Controller(configure=True, synchronize=True)[source]

Bases: guibot.config.LocalConfig

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

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

Build a screen controller 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='control', 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
mouse_scroll(clicks=10, horizontal=False)[source]

Scroll the mouse for a number of clicks.

Parameters:
  • clicks (int) – number of clicks to scroll up (positive) or down (negative)
  • horizontal (bool) – whether to perform a horizontal scroll instead (only available on some platforms)
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=None)[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.controller.AutoPyController(configure=True, synchronize=True)[source]

Bases: guibot.controller.Controller

Screen 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.

mouse_location

Custom implementation of the base method.

See base method for details.

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=None)[source]

Custom implementation of the base method.

See base method for details.

class guibot.controller.XDoToolController(configure=True, synchronize=True)[source]

Bases: guibot.controller.Controller

Screen 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.

mouse_location

Custom implementation of the base method.

See base method for details.

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=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=None)[source]

Custom implementation of the base method.

See base method for details.

class guibot.controller.VNCDoToolController(configure=True, synchronize=True)[source]

Bases: guibot.controller.Controller

Screen 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=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=None)[source]

Custom implementation of the base method.

See base method for details.

class guibot.controller.PyAutoGUIController(configure=True, synchronize=True)[source]

Bases: guibot.controller.Controller

Screen control backend implemented through PyAutoGUI which is a python library portable to MacOS, Windows, and Linux operating systems.

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

Build a DC backend using PyAutoGUI.

mouse_location

Custom implementation of the base method.

See base method for details.

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

Custom implementation of the base method.

See base method for details.

synchronize_backend(backend=None, category='pyautogui', 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.

mouse_scroll(clicks=10, horizontal=False)[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=None)[source]

Custom implementation of the base method.

See base method for details.