Prompt
How do I automate tasks in legacy desktop apps without APIs?
Latest observation
If a legacy desktop app has no API, you usually automate it through the user interface or by observing/changing its files and data stores. The best approach depends on how stable the app is and what kind of task you need to automate.
Main options
1) UI automation
Use scripts or tools that act like a user:
- click buttons
- fill fields
- read screen text
- select menu items
Common tools:
- Windows: AutoHotkey, Power Automate Desktop, UI Automation (UIA), pywinauto, WinAppDriver
- Cross-platform: SikuliX, Robot Framework with desktop libraries
Best for:
- repetitive workflows
- apps with standard controls
- tasks that require direct interaction
Cautions:
- brittle if the UI changes
- slow compared to APIs
- may break with resolution, theme, or timing changes
2) Keyboard/mouse macro automation
Record and replay actions:
- simple
- fast to set up
- useful for short, repetitive sequences
Tools:
- AutoHotkey
- AutoIt
- Power Automate Desktop
- built-in macro recorders
Best for:
- very repetitive tasks with little variation
Cautions:
- least robust
- sensitive to focus and timing
3) Screen-based automation
Use computer vision/OCR when controls aren’t accessible:
- detect images on screen
- read text with OCR
- click based on visual location
Tools:
- SikuliX
- OpenCV + Python
- Tesseract OCR
- Power Automate Desktop OCR actions
Best for:
- old apps, Citrix/remote desktops, custom-drawn interfaces
Cautions:
- more fragile than UI automation
- depends on screen layout and quality
4) File/database automation
Sometimes the app stores data in:
- flat files
- CSV/XML/JSON
- Excel
- Access/SQLite/DB files
- config files
You can automate by:
- writing files directly
- importing/exporting data
- watching folders
- updating data stores behind the app
Best for:
- batch processing
- data entry/import workflows
Cautions:
- verify app supports the file format
- don’t corrupt internal files by writing directly unless documented
5) Hook into OS-level accessibility or COM objects
Some legacy apps expose:
- Windows UI Automation
- COM automation interfaces
- accessibility trees
- scripting objects
This is more stable than pure mouse/keyboard automation if available.
Tools:
- Python
pywin32,comtypes - .NET UIAutomation
- AutoHotkey
- PowerShell for some COM apps
6) Reverse engineer only if necessary
If the app has no interfaces at all, people sometimes:
- inspect window messages
- analyze file formats
- monitor registry/file/network activity
- use process automation or DLL injection
This is advanced and may be risky or violate vendor terms.
Practical recommendation
Start in this order:
- Check for hidden automation support: COM, UI Automation, scripting, import/export.
- Use file/data automation if the app stores data in accessible files or databases.
- Use UI automation for structured screens.
- Use image/OCR automation if controls aren’t accessible.
- Use macros only for quick, simple, low-risk tasks.
Good workflow to design automation
- Identify the exact task and inputs/outputs
- Break it into steps
- Test each step manually
- Add error handling and timeouts
- Log actions and failures
- Make it resilient to:
- popup dialogs
- loading delays
- window focus changes
- unexpected values
Example tools by scenario
- Fast Windows scripting: AutoHotkey
- Python-based desktop automation: pywinauto
- Mixed UI + OCR: SikuliX or Python + OpenCV/Tesseract
- Business process automation: Power Automate Desktop
- Enterprise .NET/Windows apps: UI Automation, WinAppDriver
Important considerations
- Check licensing and vendor policy before automating
- Avoid automating actions that could cause data loss without validation
- Secure credentials carefully
- Make sure you can monitor and recover from failures
If you want, I can suggest the best tool and approach for your specific app if you tell me:
- Windows/macOS/Linux
- the app type
- what task you want to automate
- whether the app has export/import or database files