Skip to content

Instantly share code, notes, and snippets.

@heyimalex
Last active January 30, 2020 17:41
Embed
What would you like to do?
Nexhealth toy project
import subprocess as sp
import pyautogui
import time
child = sp.Popen(["write.exe"])
time.sleep(1)
pyautogui.typewrite('Dae Choi is the best.\nGive me a job!', interval=0.1)
# Save
pyautogui.hotkey('ctrl', 's')
# Name the file
pyautogui.typewrite('alex-guerra-plea.rtf', interval=0.1)
# Bump the directory to desktop
pyautogui.hotkey('alt', 'up')
pyautogui.hotkey('alt', 'up')
pyautogui.hotkey('alt', 'up')
pyautogui.hotkey('alt', 'up')
pyautogui.hotkey('alt', 'up')
# Finalize the save
pyautogui.hotkey('enter')
# Select yes in the file overwriting dialogue.
pyautogui.hotkey('tab')
pyautogui.hotkey('enter')
# This worked but was slow, so I just did the tab/enter regardless since it doesn't
# change anything in the non-overwriting case.
#
# Check for already exists dialogue popup.
#time.sleep(.500)
#try:
# pyautogui.locateOnScreen('exists.png'
# pyautogui.hotkey('tab')
# pyautogui.hotkey('enter')
#except pyautogui.ImageNotFoundException
# pass
# Exit
time.sleep(.500)
pyautogui.hotkey('alt', 'f')
pyautogui.hotkey('x')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment