Skip to content

Automating Desktop Applications

Strategy

  1. open app
  2. focus window
  3. navigate with hotkeys
  4. use image locate for buttons
  5. add safe delays

Skeleton script (safe)

desktop_automation_skeleton.py
import time
import pyautogui
 
 
def main():
    pyautogui.alert("Move mouse to top-left anytime to STOP", title="Safety")
 
    # TODO: open your app manually first
    time.sleep(2)
 
    # Example actions:
    # pyautogui.hotkey("ctrl", "l")
    # pyautogui.write("hello")
    # pyautogui.press("enter")
 
 
if __name__ == "__main__":
    main()
desktop_automation_skeleton.py
import time
import pyautogui
 
 
def main():
    pyautogui.alert("Move mouse to top-left anytime to STOP", title="Safety")
 
    # TODO: open your app manually first
    time.sleep(2)
 
    # Example actions:
    # pyautogui.hotkey("ctrl", "l")
    # pyautogui.write("hello")
    # pyautogui.press("enter")
 
 
if __name__ == "__main__":
    main()

Tip

If an app provides an API or CLI, use that instead.

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did