Skip to content

Commit

Permalink
Switch the default desktop controller from AutoPy to PyAutoGUI
Browse files Browse the repository at this point in the history
AutoPy's Rust dependencies are harder to build and have long term
standing issues and PyAutoGUI is more popular nowadays.
  • Loading branch information
pevogam committed Jan 19, 2022
1 parent 7780400 commit dc5818d
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Supported Computer Vision (CV) backends are based on

Supported Display Controller (DC) backends are based on

- [AutoPy](https://github.com/msanders/autopy)
- [PyAutoGUI](https://github.com/asweigart/pyautogui)
- [AutoPy](https://github.com/msanders/autopy)
- [VNCDoTool](https://github.com/sibson/vncdotool)
- [XDoTool](https://www.semicomplete.com/projects/xdotool)

Expand Down
16 changes: 10 additions & 6 deletions guibot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class GlobalConfig(type):
_image_quality = 3

# backends shared between all instances
_display_control_backend = "autopy"
_display_control_backend = "pyautogui"
_find_backend = "hybrid"
_contour_threshold_backend = "adaptive"
_template_match_backend = "ccoeff_normed"
Expand Down Expand Up @@ -312,14 +312,18 @@ def display_control_backend(self, value=None):
:raises: :py:class:`ValueError` if value is not among the supported backends
Supported backends:
* autopy - Windows, Linux (and OS X) compatible with both the GUI
* pyautogui - Windows, Linux, and OS X compatible with both the GUI
actions and their calls executed on the same machine
* autopy - Windows, Linux, and OS X compatible with both the GUI
actions and their calls executed on the same machine.
* qemu - guest OS independent with GUI actions on a virtual machine
through Qemu Monitor object (provided by Autotest) and
their calls on the host machine.
* vncdotool - guest OS independent or Linux remote OS with GUI
actions on a remote machine through vnc and their
calls on a vnc client machine.
* xdotool - Linux X server compatible with both the GUI
actions and their calls executed on the same machine.
* qemu - guest OS independent with GUI actions on a virtual machine
through Qemu Monitor object (provided by Autotest) and
their calls on the host machine.
.. warning:: To use a particular backend you need to satisfy its dependencies,
i.e. the backend has to be installed or you will have unsatisfied imports.
Expand All @@ -342,7 +346,7 @@ def find_backend(self, value=None):
:param value: name of the computer vision backend
Supported backends:
* autopy - simple bitmap matching provided by autopy
* autopy - simple bitmap matching provided by AutoPy
* contour - contour matching using overall shape estimation
* template - template matching using correlation coefficients,
square difference, etc.
Expand Down
8 changes: 4 additions & 4 deletions packaging/guibot.spec
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ Requires: python3-opencv

%description
A tool for GUI automation using a variety of computer vision and desktop control backends.
Supported CV backends are based on OpenCV, PyTorch, and autopy, and supported DC backends
on autopy, vncdotool, and qemu.
Supported CV backends are based on OpenCV, PyTorch, and AutoPy, and supported DC backends
on PyAutoGUI, AutoPy, VNCDoTool, and XDoTool.

%package -n python3-guibot
Summary: GUI automation tool
Group: Development/Tools
%description -n python3-guibot
A tool for GUI automation using a variety of computer vision and desktop control backends.
Supported CV backends are based on OpenCV, PyTorch, and autopy, and supported DC backends
on autopy, vncdotool, and qemu.
Supported CV backends are based on OpenCV, PyTorch, and AutoPy, and supported DC backends
on PyAutoGUI, AutoPy, VNCDoTool, and XDoTool.

#Patch1: first_fix.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Expand Down
3 changes: 1 addition & 2 deletions packaging/packager_pip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ dnf -y install tesseract tesseract-devel
dnf -y install gcc-c++
# screen controlling
dnf -y install xdotool xwd ImageMagick
# TODO: PyAutoGUI's scrot dependencies are broken on CentOS/Rocky
# TODO: PyAutoGUI's scrot dependencies are broken on CentOS/Rocky, currently provided offline
#dnf -y install scrot
export DISABLE_PYAUTOGUI=1
dnf -y install x11vnc

# dependencies that could be installed using pip
Expand Down
7 changes: 3 additions & 4 deletions packaging/packager_rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ else
fi
pip3 install vncdotool==0.12.0
dnf -y install xdotool xwd ImageMagick
# TODO: PyAutoGUI's scrot dependencies are broken on Fedora
export DISABLE_PYAUTOGUI=1
#dnf -y install python3-tkinter scrot
#pip3 install pyautogui==0.9.52
# TODO: PyAutoGUI's scrot dependencies are broken on Fedora 33-, currently provided offline
dnf -y install python3-tkinter #scrot
pip3 install pyautogui==0.9.52
dnf -y install x11vnc

# rpm packaging and installing of current guibot source
Expand Down
18 changes: 11 additions & 7 deletions tests/test_region_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@

import common_test
from guibot.region import Region
from guibot.controller import Controller, AutoPyController
from guibot.controller import Controller, PyAutoGUIController


@unittest.skipIf(os.environ.get('DISABLE_AUTOPY', "0") == "1", "AutoPy disabled")
@unittest.skipIf(os.environ.get('DISABLE_PYAUTOGUI', "0") == "1", "PyAutoGUI disabled")
class RegionTest(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.screen = PyAutoGUIController()

def test_position_calc(self):
region = Region(10, 20, 300, 200)

Expand All @@ -49,7 +53,7 @@ def test_position_calc(self):
self.assertEqual(220, bottom_right.y)

def test_screen_clipping(self):
screen = AutoPyController()
screen = RegionTest.screen
screen_width = screen.width
screen_height = screen.height

Expand Down Expand Up @@ -93,7 +97,7 @@ def test_empty_screen_clipping(self):
self.assertEqual(region.height, 200)

def test_nearby(self):
screen = AutoPyController()
screen = RegionTest.screen
screen_width = screen.width
screen_height = screen.height

Expand All @@ -117,7 +121,7 @@ def test_nearby(self):
self.assertEqual(10, region.height)

def test_nearby_clipping(self):
screen = AutoPyController()
screen = RegionTest.screen
screen_width = screen.width
screen_height = screen.height

Expand Down Expand Up @@ -170,7 +174,7 @@ def test_above(self):
self.assertEqual(110, region.height)

def test_below(self):
screen_height = AutoPyController().height
screen_height = RegionTest.screen.height

region = Region(200, 100, 20, 10).below(50)
self.assertEqual(200, region.x)
Expand Down Expand Up @@ -212,7 +216,7 @@ def test_left(self):
self.assertEqual(10, region.height)

def test_right(self):
screen_width = AutoPyController().width
screen_width = RegionTest.screen.width

region = Region(200, 100, 20, 10).right(50)
self.assertEqual(200, region.x)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_region_expect.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
from guibot.match import Match
from guibot.target import Image, Text
from guibot.inputmap import Key
from guibot.finder import *
from guibot.controller import *
from guibot.finder import AutoPyFinder, TemplateFinder, TextFinder
from guibot.controller import PyAutoGUIController
from guibot.errors import *


Expand Down Expand Up @@ -102,10 +102,10 @@ def wait_end(self, subprocess_pipe, timeout=30):

time.sleep(0.2)

@unittest.skipIf(os.environ.get('DISABLE_AUTOPY', "0") == "1", "AutoPy disabled")
@unittest.skipIf(os.environ.get('DISABLE_PYAUTOGUI', "0") == "1", "PyAutoGUI disabled")
def test_initialize(self):
screen_width = AutoPyController().width
screen_height = AutoPyController().height
screen_width = PyAutoGUIController().width
screen_height = PyAutoGUIController().height

self.assertEqual(0, self.region.x)
self.assertEqual(0, self.region.y)
Expand Down

0 comments on commit dc5818d

Please sign in to comment.