Disclaimer: This project is a portfolio piece based on a real-world automation scenario. All proprietary company data, internal process details, system names, and UI assets have been removed or anonymized to protect confidentiality. The code is presented for demonstrational purposes of technical skills and is not intended to be run "out-of-the-box".
To maintain company confidentiality, all .png image files captured from the proprietary ERP interface have been intentionally removed from this public repository.
The code still contains the logic and variable paths (*_PATH) used to interact with these images. This demonstrates the image recognition technique (find_and_click function) which is central to the automation's resilience, without exposing the proprietary user interface.
This project is a comprehensive Robotic Process Automation (RPA) suite designed to eliminate inefficient, error-prone manual tasks within a legacy ERP system. The core of the project is a modern GUI dashboard that serves as a centralized control panel, allowing non-technical users to launch, monitor, and manage complex automation workflows safely and efficiently.
The suite automates the batch printing of Production Orders and their corresponding Attachments, reading data from Excel files and performing all necessary UI interactions, including handling dynamic pop-ups and complex, multi-step sequences.
- Centralized GUI Dashboard: Built with
CustomTkinter, providing a modern, user-friendly single point of control. - Concurrent Process Execution: The dashboard uses the
multiprocessingmodule to run automations as independent, non-blocking processes, ensuring the UI remains responsive at all times. - Optimized Image-Based Automation: Core logic relies on
PyAutoGUI's image recognition, optimized with asearch_regionparameter to dramatically increase search speed by limiting searches to the application window. - Intelligent User Error Prevention: Proactively checks if
Caps Lockis active before password entry using thectypeslibrary, preventing a common cause of login failures. - Robust Login & Session Management: Features a secure login sequence that actively verifies success by detecting a specific post-login window, preventing the automation from proceeding with invalid credentials and avoiding account lockouts.
- Advanced Sequence Handling: Implements custom logic to handle complex, interleaved UI events, such as the repeating
Print -> REPORT_VIEWERdialog sequence. - Secure & Externalized Configuration: Manages credentials safely via
.envfiles and application settings via aconfig.inifile. - Designed for Distribution: Code paths are handled by a custom
resource_pathfunction, ensuring that all assets are correctly located when the project is bundled into a standalone executable withPyInstaller. - Graceful Process Termination: The dashboard safely tracks and terminates child processes, attempting a graceful shutdown before forcing a kill.
The project is designed with a clear separation of concerns, consisting of a presentation layer and an automation/logic layer.
- Presentation Layer (
dashboard_automation.py): The user-facing GUI. Its sole responsibility is to provide a simple interface to trigger actions and display status. It knows what to run, but not how the automation works internally. - Automation Layer (
app_*.pyscripts): Each script is a self-contained, specialized "robot" responsible for a single business process. It reads its own configuration and data, interacts with the ERP, and handles its own complex logic.
This decoupled architecture ensures that new automations can be added with minimal changes to the main dashboard.
The repository is organized to maintain a clear separation between the interface, the automation logic and the data resources.
automacoes/
├── assets/ # Icons, flowcharts and images for the README
├── impressao_anexo_sanduiche/
│ ├── app_impressao_anexo_sanduiche.py # Lógica da automação de anexos
│ └── *.png # UI images for this automation
│ └── *.xlsx # Data sheet for this automation
├── impressao_op/
│ ├── app_impressao_op.py # OP automation logic
│ └── *.png # UI images for this automation
│ └── *.xlsx # Data sheet for this automation
├── .venv/ # Python virtual environment
├── dashboard_automation.py # GUI main script
├── utils.py # Shared utility functions (login, find_and_click, etc.)
├── config.ini # Configuration file (paths, timeouts)
├── .env.example # Template for the credentials file
├── .env # Credentials file (ignored by Git)
├── requirements.txt # List of project dependencies
├── PainelAutomacoes.spec # PyInstaller configuration file for the build
└── README.md # This file
A key part of this project was overcoming the challenges of automating a legacy system.
-
Challenge 1: Interleaved Dialogs (
app_impressao_op.py)- Problem: Printing an order with multiple Production Orders (OPs) did not generate a simple series of print dialogs. Instead, it triggered an unpredictable, repeating sequence of
Print Dialog -> REPORT_VIEWER Confirmation -> Print Dialog -> .... - Solution: A specialized function,
handle_print_and_gxr_sequence, was developed. This function runs a master loop that continuously polls for either of the two dialogs. It only exits once a full loop completes without finding any actionable window, making it robust for any number of OPs.
- Problem: Printing an order with multiple Production Orders (OPs) did not generate a simple series of print dialogs. Instead, it triggered an unpredictable, repeating sequence of
-
Challenge 2: Brittle UI Navigation (
app_impressao_anexo_sanduiche.py)- Problem: The initial version of the script relied heavily on "blind" navigation (e.g.,
pyautogui.press('tab', presses=5)). This was extremely fragile and would break with any minor UI change. - Solution: The script was refactore-d to replace nearly all blind navigation with image-based
find_and_clickcalls. This involved creating a library of reference images for UI elements (input fields, checkboxes, buttons), making the script's interactions far more reliable.
- Problem: The initial version of the script relied heavily on "blind" navigation (e.g.,
A crucial part of the project was packaging it as a standalone, easily distributable executable (.exe) for non-technical users, utilizing PyInstaller.
- Packaging Challenge: When creating an executable, relative paths to data files (like .png images, .xlsx spreadsheets, and config.ini) break because the script runs from a temporary directory unpacked at runtime.
- Solution (utils.resource_path): A utility function, resource_path, was created to detect whether the script is running in development mode or as a "frozen" executable bundled by PyInstaller (by checking for sys._MEIPASS). It dynamically adjusts paths so that data files are always found, regardless of the execution context.
- .spec File: The PainelAutomacoes.spec file was customized to ensure that all data folders (impressao_op, impressao_anexo_sanduiche) and root files (config.ini, .env) are correctly included in the final package.
To generate the executable, run the following command:
pyinstaller PainelAutomacoes.spec
This project showcases skills across several domains of software development and automation.
-
GUI Development:
CustomTkinter: For building the modern and responsive user interface.
-
Robotic Process Automation (RPA):
PyAutoGUI: The core engine for screen interaction, including optimized image recognition.PyGetWindow: Used for reliable window identification, activation, and management.
-
Data Handling & I/O:
Pandas: For efficiently reading and processing data from.xlsxspreadsheets.configparser: For managing external configurations from a.inifile.
-
System & Process Management:
multiprocessing: To launch and manage the lifecycle of automation scripts as independent, concurrent processes.os&sys: For building platform-agnostic, executable-aware file paths.psutil: For advanced process management, enabling the safe and targeted termination of processes by PID.ctypes: For low-level interaction with the Windows API to detect the state of keyboard keys likeCaps Lock.
-
Security:
python-dotenv: To load sensitive credentials from a local.envfile.
-
Software Engineering Principles:
- Modular Design: Separating the UI (
dashboard), reusable tools (utils), and specific business logic (app_*.py). - DRY (Don't Repeat Yourself): Centralizing common functions in
utils.py. - Robust Error Handling: Extensive use of
try...except...finallyblocks to manage failures gracefully. - Deployment Readiness: Designing the application to be bundled into a standalone executable using
PyInstaller.
- Modular Design: Separating the UI (
The implementation of this tool resulted in:
- A drastic reduction in the time required to print batches of documents.
- 100% elimination of manual typing errors during the process.
- Increased team productivity, allowing staff to focus on higher-value tasks.


