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.5.tar.gz (2.9 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.5-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tilia-1.0.5.tar.gz
  • Upload date:
  • Size: 2.9 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.5.tar.gz
Algorithm Hash digest
SHA256 0915ba57ab8246bdda9212856e742582401da356b246d24a434f26598a5426f4
MD5 86c19cde29bf320ee84da928d653cf7f
BLAKE2b-256 27825b9d83c7f7dd8dca288f74fb3d592bfd3b3f047b8d1214cb0c04d724f533

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tilia-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 2.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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3e2a2d98e91492e8de7517bce4d3be82951c044043f5dd219cc35bd1bca67ae5
MD5 ba15f1293e6385a886a3b564e2a0906e
BLAKE2b-256 931ce23fbc6f65d8e86ba4389c32ef2543ac5393f88bd3a1dfed12c08d4761e0

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