This library provides a set of utilities designed to automate repetitive human interactions on a computer. By leveraging the power of the pyautogui library, this package allows for easy automation of simple tasks such as mouse movements, clicks, keyboard presses, window focus checks, and clipboard operations.
What’s Included
pyautogui_utils Functions
mouse_click(x, y, absolute=False, wait=0)
Simulate a mouse click at the specified coordinates.
press_key(key, times=1)
Simulate pressing a key multiple times.
enter_value(value, wait=0.2)
Type a value, wait a bit and press Enter.
wait_for_window(window_title, timeout=7, wait=0.5)
Wait for a window with a specific title to become active.
Example usage:
press_key('winleft')
wait_for_window("Search")
exit_if_not_window(value, timeout=7, wait=0.5)
Calls wait_for_window() and exits the program if it returns False.
relative_to_absolute(x_rel, y_rel)
Convert relative screen coordinates to absolute coordinates based on screen size.
Example usage:
relative_to_absolute(0.5, 0.5)
# Output: (960, 540) -- for a screen resolution of 2560 x 1440
save_from_clipboard(rel_start_x, rel_start_y, rel_end_x, rel_end_y, sap_paste=False, absolute=False)
Simulate selecting a portion of the screen and saving it to the clipboard.
Per default works with relative coordinates.
force_clipboard_content(rel_start_x, rel_start_y, rel_end_x, rel_end_y, sap_paste=False, absolute=False, direction='Down', horizontal=False, ratio=0.008)
Force the clipboard content by repeatedly calling save_from_clipboard() with slightly varying coordinates.
SAPAutomation Class (in sap_utils.py)
This class provides an interface for automating SAP tasks, allowing you to perform common actions such as logging into SAP, navigating through menus, and copying data to the clipboard. It uses the pyautogui_utils functions to simulate user actions in SAP.
Example usage:
from sap_utils import SAPAutomation
sap = SAPAutomation("username", "password")
sap.open_sap() # Opens SAP GUI Interface and logs with username and password
...
sap.go_to_main_page()
sap.close_sap()
Installation
To install the package, simply clone the repository and install the required dependencies:
git clone https://github.com/rafonsomartins/tilia
cd tilia
pip install -r requirements.txt
License
This project is licensed under the MIT License.
Next Steps and Potential Vulnerabilities
Error Handling
Implement structured exception handling (try/except) to ensure better error recovery and debugging.
Testing
Implement unit tests for all utility functions and mock interactions to allow testing without relying on real-world systems.
Dynamic Window Titles
Enhance window title-finding logic using regex or partial matches.
Performance Optimization
Avoid using time.sleep() and explore event-driven approaches to improve performance. Ensure that force_clipboard_content() doesn't loop infinitely by adding a maximum retry count or exit condition.
Robustness and Safety
Implement input validation for user inputs and add logging for events and errors to make debugging easier.
Metadata
Release files for tilia 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tilia-1.1.0.tar.gz | 5.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tilia-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.6 kB
Release files / tilia-1.1.0.tar.gz
| Download URL | tilia-1.1.0.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b7b48b5bd27286ad813bfd3f784ad8d6d3d2e3f4f1438c3e65cfcc9d623a387
|
|
BLAKE2b-256 checksum How to use checksums |
8a3ab9dca7c5c5d0e11ea17ba4ec02698b034acd9bb69dacf0a1b278d82af997
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.8
|
Release files / tilia-1.1.0-py3-none-any.whl
| Download URL | tilia-1.1.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2948679838ee3fbf116d88f35f009d54bfbbf5f885bb46648cd7cf6c28baad8
|
|
BLAKE2b-256 checksum How to use checksums |
6f389693e6a95b59c8b67d881eff5611fc6991e057df109c71c2e294ee8c2cec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.8
|