● CASE STUDY · IDENTIUM TECH SOLUTIONS
PayTime Auto Download
Unattended attendance download and PDF report from a legacy app
OVERVIEW
PayTime has no API and no scriptable interface, so the only way in is the GUI. The script talks to it through Microsoft UI Automation, addressing menu items, buttons and grid cells by name and automation id (MenuItem 'Download', Button 'Data Download', ChkAllEmployee, GrdEmployeeList) instead of clicking at computed screen positions. It logs every step, screenshots each milestone, and verifies the result of each action before moving on. A PowerShell installer registers it as a scheduled task so it can run on a timetable without anyone at the keyboard.
THE CHALLENGE
Windows draws the UAC consent dialog on the secure desktop, where no program of any privilege level can see or click it, so any screen driving tool stalls the moment PayTime launches RegisterOCX.exe. The fix was to never raise the prompt: start from an elevated scheduled task and the child process inherits the token. The app itself fights back in two other places. Its WinForms employee grid reports a stale MSAA toggle state, so a checkbox that visibly ticked still reads as unticked and a naive retry would undo the click, and the Crystal Reports toolbar often does not expose its buttons as Button controls at all.
WHAT I BUILT
- 01
A 1,893 line Python driver that walks PayTime's UIA tree and performs the whole flow: splash handling, login, data download, department and employee selection, preview, PDF export and shutdown, with per step screenshots and a timestamped log file
- 02
set_checkbox, a read then act then re-read loop that drives any checkbox to a target state through UIA TogglePattern, falling back to the MSAA default action and then a real click, and refuses to toggle blind so it can never tick and untick the same box
- 03
Prompt free elevation: install_task.ps1 registers a scheduled task with RunLevel Highest, so PayTime inherits an already elevated token and the RegisterOCX.exe UAC prompt is never raised at all
- 04
Completion detection that splits the Event Log text on ' | ' and regex matches individual segments (download\w*\s+complet\w*), scoped to text that appeared after the button press, so the ticking status bar clock cannot fake a finish and a stale message from a previous run cannot end the wait early
- 05
A Crystal Reports export step that searches the print preview toolbar across Button, SplitButton, MenuItem, Custom and Pane control types with a left most toolbar child fallback, presses each candidate three different ways, sets Save as type before the file name, answers the overwrite prompt and then checks the PDF exists on disk with a non zero size
OUTCOME
The full run works end to end on the target laptop: download, department and employee selection, preview, and a dated PDF written to the attendance folder. What was a manual, several minute job with a UAC prompt in the middle now runs unattended on a schedule and leaves a log and screenshots behind for every run.