Python-Script for automated click-sequences and text entry
Project description
Clickomat 1.0.0
Python-Script for automated click-sequences and text entry.
Building on top of the brilliant lib "pyautogui" by Al Sweigart it offers the possibility to perform mouse clicks, text input and more with very simplified commands.
The purpose of Clickomat is to map the sometimes relatively long python commands from pyautogui with short, single-line commands that are processed in a simple text list.
New in 1.0.0:
lookup: Multiple targets possible
blacklist: Define target(s) which abort complete script immediately if found.
whitelist: Define target(s) which HAVE TO BE visible on screen. If not, script is also aborted immediately.These functions will be executed as separate threads which means they will not slow down the performance of the main running section.
blacklist
andwhitelist
can be used to implement panic-switches.pop: User defined popup messages.
Plus: Proper implementation of pyautogui's failsave -> if the mouse is manually positioned in one of the screen corners a panic-switch fires.
Next Milestone: v1.0.0
- No new features
- Hunt bugs to make a stable 1.0.0
Installation
$ pip install clickomat
Run Testscript
Open https://checkboxolympics.com/ in Firefox (Chrome should work also).
It must now be ensured that ALT-TAB (Win) or CMD-TAB (Mac) can be used to switch directly back and forth between the terminal and the website.
- Install Clickomat package
$ pip install clickomat
- Change directory into testcases/checkboxolympics/
$ cd [path-to-clickomat-folder]/testcases/checkboxolympics
- Run the script by typing
$ python c.py
OR simply put
$ pip install clickomat
...
$ clickomat -p [path-to-clickomat-folder]/testcases/checkboxolympics
Run Clickomat
From command-line as CLI
If run directly from command-line Clickomat takes arguments like this:
$ clickomat -p C:/path/to/case/dir -c clicklist.txt -i imagefolder
Defaults would simply be '.','t1.txt','images' if called w/o arguments.
If you only like to change the clicklist-file:
$ clickomat -c clicklist.txt
More details in the Docs -> CLI
From python-file
To run from python-script you need to have at least this construct:
from clickomat import Clickomat
c = Clickomat('.','t1.txt',"images")
c.main()
- You have to specify the location of your clicklist with the first param. Here it is a dot because the python file is in the same directory as the Clickomat script txt-file (clicklist).
- Next is the name of the clicklist (text-file) to read instructions from
t1.txt
- You CAN specify a folder for your target-images but those can also be located on txt-file level. Then you would write a dot here.
More details in the Docs -> Python
Commands
Command | Result |
---|---|
##SECTION | you can divide your script into sections |
switch | Alt-Tab on WIN / Command-Tab on Mac |
click | normal click at current position |
click -images | click on imagename.png if present |
click ! -images | forced click on imagename.png |
doubleclick | normal doubleclick at current position |
doubleclick -images | doubleclick on imagename.png if present |
doubleclick ! -images | forced doubleclick on imagename.png |
shiftclick | shift-click at current position |
shiftclick -images | shift-click on imagename.png if present |
shiftclick ! -images | forced shift-click on imagename.png |
mdown | Mouse-Down - Stays down until released by mup ! |
mup | Mouse-Up |
pos -image | place mouse on imagename.png |
posX 20 | move mouses X-coordinate to 20px from left |
posY 20 | move mouses Y-coordinate to 20px from top |
right 20 | pushes mouse 20px to the right |
left 20 | pushes mouse 20px to the left |
up 20 | pushes mouse 20px up |
down 20 | pushes mouse 20px down |
drag -image | click-drag across imagename.png (top/left to bottom/right) |
drag up -image | click-drag across imagename.png (bottom/left to top/right) |
await -images | waits for image to appear |
write "text" | types text |
pop "text" | pops up a message, pauses until button is pressed |
enter | press enter |
scroll 20 | scroll 20 steps up |
scroll -20 | scroll 20 steps down |
stop | breaks the script (for debugging) |
del | deletes file |
del dir | deletes directory |
[number] | pauses for [number] seconds |
# | you can comment-out lines by using hash as first char (followed by space) |
#command | you can also comment-out lines by using hash as first char followed by command (no space) |
lookup -image ->SECTION | set a target to lookout for the entire runtime. If found -> end current section, start SECTION (name) |
if -images ->SECTION | If (multiple possible) target found -> end current section, start SECTION (name) |
go ->SECTION | end current section, start SECTION (name) |
end | you CAN pop a message when script is finished - optional |
Images:
-imagename can either be a single image or a list of images separated by /
. The list will be iterated and the first finding will be used. See example in checkboxolympics testcase.
Shorthands
Command | Shorthand | Command | Shorthand | Command | Shorthand | ||
---|---|---|---|---|---|---|---|
switch | > | posX | x | await | a | ||
click | c | posY | y | write | w | ||
doubleclick | dc | right | r | enter | . | ||
shiftclick | sc | left | l | scroll | sl | ||
mdown | md | up | u | del | d | ||
mup | mu | down | d | del dir | dd | ||
lookup | lu |
More commands coming...
Full Documentation
Dependencies:
* pyautogui
* keyboard
* click
* opencv-python (on windows pyautogui works only with opencv)
* pillow (on windows pyautogui works only with pillow)
Examples:
- examplescript.txt
- Testcase: checkboxolympics
On the Website https://checkboxolympics.com/ you can run the very simplyfied script of the testcase and get a score around 2.2 seconds...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for clickomat-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f0fa55a1bb92d8a59cbef8aa79141d871920b4b0eee7442b87bf5c79325152c |
|
MD5 | 561bac92fbe48553b82bf7c655d17fc0 |
|
BLAKE2b-256 | 4e43045fcb69447b5a2d6cc3e935234568627ccbb1a0a42c6a74e041db498ddf |