Skip to main content

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

tilia-1.0.6.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tilia-1.0.6-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file tilia-1.0.6.tar.gz.

File metadata

  • Download URL: tilia-1.0.6.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

Hashes for tilia-1.0.6.tar.gz
Algorithm Hash digest
SHA256 102d1d4eac315b1c6280be26749ac544d5120cab0bb0fdd9bcb320bb168ab6c8
MD5 8b037806a398a1a432835c5de204e057
BLAKE2b-256 88ad0c1fa195ad33f9ac7e8232261b9e6696ae4763c4792cad6254aa3eb454ac

See more details on using hashes here.

File details

Details for the file tilia-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: tilia-1.0.6-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

Hashes for tilia-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9753a4de93e636643ba2fc75ab2027c87045b57fe7856caec2334cebf2d51aff
MD5 f603986d040f7f7d7cea6a318332b3a0
BLAKE2b-256 d0053bdbda13b856098de7fca253cf3b97556a3dc620c0ad2cca11cf7f77873b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page