# Lackey #
## A Graphical Python Automation Suite ##
[![Documentation Status](https://readthedocs.org/projects/lackey/badge/?version=latest)](http://lackey.readthedocs.io/en/latest/?badge=latest) [![Develop Documentation Status](https://readthedocs.org/projects/lackey/badge/?version=develop)](http://lackey.readthedocs.io/en/latest/?badge=develop) [![Build status](https://ci.appveyor.com/api/projects/status/l1q68dnp6vm8sre9?svg=true)](https://ci.appveyor.com/project/glitchassassin/lackey) ![Coverage](https://cdn.rawgit.com/glitchassassin/lackey/develop/coverage.svg)
Developed by [Jon Winsley](https://github.com/glitchassassin)
## Third Party Library Requirements ##
* numpy
* pillow
* opencv
* keyboard
## Introduction ##
Lackey is a Python implementation of Sikuli script, allowing you to run automation scripts developed in the Sikuli editor with pure Python. If you're trying to run Sikuli scripts in a Java-free environment or integrate them into an existing Python testing structure, this is the library for you.
## Usage ##
### Installation ##
Installation is easy:
pip install Lackey
Then you can just import Lackey at the head of your Sikuli-script python file:
from lackey import *
**WARNING** Be aware that this will create global methods that will *overwrite certain Python functions*, such as `type()`. For more information, see the **Sikuli Patching** section below.
### General ###
The Lackey library is divided up into classes for finding and interacting with particular regions of the screen. Patterns are provided as bitmap files (supported formats include `.bmp`, `.pbm`, `.ras`, `.jpg`, `.tiff`, and `.png`). These patterns are compared to a Region of the screen, and, if they exist, can target a mouse move/click action.
If you've used Sikuli, you'll feel right at home. Lackey is designed to be a drop-in shim for Sikuli.
Sample code (note that you'll need to provide your own PNGs):
from lackey import *
click("Start_Button.png")
wait("Control_Panel.png", 5) # Maybe the Start menu is slow
click("Notepad.png")
### Working with Elevated Privileges ###
In most cases, you won't need to run Lackey with elevated privileges. However, Windows will not let a non-elevated script send mouse/keyboard events to a program with elevated privileges (an installer running as administrator, for example). If you run into this problem, running Lackey as administrator (for example, by calling it from an Administrator-level Powershell instance) should solve your issue.
## Documentation ##
Full API documentation can be found at [ReadTheDocs](http://lackey.readthedocs.io/en/latest/).
## Rationale ##
In my line of work, I have a lot of tasks walking through line-of-business applications to do boring things that any computer could do. Laziness being the mother of invention, I decided to script what I could. I found [SikuliX](http://sikulix.com/) to be a tremendously valuable tool for the job, but its Java dependencies and limited Python coupling posed problems in several cases. So, I decided to create a pure Python implementation of Sikuli script.
There are some existing libraries for this purpose, like `pywinauto` and `autopy`, but they didn't work for me for one reason or another. I wasn't doing a lot of Windows GUI interaction with these particular applications, so `pywinauto`'s approach wouldn't help. I needed something that could search for and use images on screen. `autopy` was closer, but it had quite a few outstanding issues and hadn't been updated in a while.
Most of my automation is in Windows, so I've begun this library with only Windows support. As of version 0.7.0, it also includes Mac OS X support,and it's designed to eventually be extended with support for Linux by implementing an additional "PlatformManager" class. I'll get around to this at some point, but if you'd like to contribute one sooner, please feel free!
### Sikuli Patching ###
My goal with this project is to be able to reuse my existing library of Sikuli scripts with minimal modifications. To that end, Lackey will map certain functions of the screen region (`find()`, `click()`, etc.) to the global scope. This means you can use the Sikuli IDE for development, and run the final product with pure Python! Add the following line to your Sikuli python script, and you should be able to run it in Python largely without issue:
from lackey import *
Note that I *have* had to adjust some of my image search similarity settings in a couple cases. Your mileage may vary. Please report any issues that you encounter and I'll try to get them patched.
Be aware that **some Sikuli-script methods actually overwrite Python-native functions**, namely `type()` and `input()`. Where this is the case, I've remapped the native functions by adding a trailing underscore. They can be accessed as follows:
from lackey import *
username = input_("Enter your username: ") # built-in Python input
## Structure ##
Each platform (Windows/OSX/Linux) needs its own PlatformManager (see documentation above) to abstract OS-level functionality, like simulating mouse clicks or key presses. Ideally, these should be implemented with as few 3rd-party library dependencies as possible. If you'd like to contribute a PlatformManager for your OS, feel free to submit a pull request!
Don't forget to update the unit tests and verify that they still run.
## Fair Warning ##
This library is currently under development, and may have some bugs. Check the Issues list to find features/bugs you can help with!
## Build Instructions ##
To build the wheel from source, `cd` to the project directory and run:
python setup.py bdist_wheel
To link directly to the repository (if you want to work with the `develop` ring, for example), `cd` to the project directory and run:
pip install -e ./
(Note that you may need to install the `wheel` package.)
## Special thanks ##
Debugging contributions:
* [maxdule](https://github.com/maxdule)
* [nejch](https://github.com/nejch)
* [suvit](https://github.com/suvit)
没有合适的资源?快使用搜索试试~ 我知道了~
Python-LackeyPython图形桌面自动化
共51个文件
py:21个
png:14个
md:4个
需积分: 50 24 下载量 51 浏览量
2019-08-10
04:39:16
上传
评论 2
收藏 453KB ZIP 举报
温馨提示
Lackey是Python的一个自动化库,专为易用性和Sikuli自动化脚本的交叉兼容而生。它提供了一个简单但强大的API,用来查找屏幕上的图片,以及使用鼠标和键盘的基本用户输入。
资源推荐
资源详情
资源评论
收起资源包目录
Python-LackeyPython图形桌面自动化.zip (51个子文件)
glitchassassin-lackey-7adadfa
lackey
ImportHandler.py 2KB
InputEmulation.py 13KB
SikuliGui.py 8KB
KeyCodes.py 2KB
PlatformManagerDarwin.py 16KB
_version.py 99B
__init__.py 8KB
RegionMatching.py 80KB
Geometry.py 5KB
App.py 10KB
Exceptions.py 367B
TemplateMatchers.py 10KB
SettingsDebug.py 7KB
PlatformManagerWindows.py 26KB
coverage.svg 904B
.gitattributes 378B
TODOS.md 930B
requirements.txt 172B
.travis.yml 1KB
LICENSE.md 1KB
setup.py 2KB
README.md 6KB
local_tests.ps1 198B
docs
source
platformmanager.rst 4KB
conf.py 10KB
index.rst 368B
lackey.rst 3KB
appveyor.yml 3KB
tests
test_file_rtf.png 10KB
notepad.png 6KB
test_file_txt.png 3KB
appveyor_test_cases.py 27KB
textedit_save.png 17KB
multiprocessing_test.py 886B
test_text.png 937B
textedit.png 14KB
textedit_save_2.png 15KB
preview_open.png 12KB
mac_test_text.png 5KB
test_pattern.png 4KB
__init__.py 66B
test_file_text.png 588B
preview_open_2.png 12KB
test_cases.py 8KB
select_all.PNG 2KB
test_import.sikuli
1514401659995.png 275KB
test_import.py 59B
test.html 2KB
.gitignore 898B
osx_requirements.txt 173B
CHANGELOG.md 983B
共 51 条
- 1
资源评论
- 靓仔又抵死2021-11-04一点说明文字都没有,别人下载了也不知道怎么用,差评,无聊
weixin_39841882
- 粉丝: 443
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功