One more layer for pyautogui. Utilities for SAP integration.
Project description
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.
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tilia-1.1.0.tar.gz.
File metadata
- Download URL: tilia-1.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b7b48b5bd27286ad813bfd3f784ad8d6d3d2e3f4f1438c3e65cfcc9d623a387
|
|
| MD5 |
a312efd069dbff874b050c37026a76df
|
|
| BLAKE2b-256 |
8a3ab9dca7c5c5d0e11ea17ba4ec02698b034acd9bb69dacf0a1b278d82af997
|
File details
Details for the file tilia-1.1.0-py3-none-any.whl.
File metadata
- Download URL: tilia-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2948679838ee3fbf116d88f35f009d54bfbbf5f885bb46648cd7cf6c28baad8
|
|
| MD5 |
ba812fee78a6073d8ccfb38f16293ed5
|
|
| BLAKE2b-256 |
6f389693e6a95b59c8b67d881eff5611fc6991e057df109c71c2e294ee8c2cec
|