Use Python with PyAutoGUI to Duplicate a File and Rename it Automatically |
Use Python with PyAutoGUI to Duplicate a File and Rename it Automatically
In this Python program, I use PyAutoGUI to duplicate a file and rename it automatically.
import pyautogui
import time
import pyperclip
pyautogui.PAUSE = 0.5
pyautogui.FAILSAFE = True
# Duplicate file
def duplicate_file():
pyautogui.rightClick()
time.sleep(1)
pyautogui.press('c')
pyautogui.moveRel(100, 0)
pyautogui.rightClick()
pyautogui.press('p')
time.sleep(1)
# Ramane file to file name - Analysis
def rename_file():
pyautogui.click()
time.sleep(1)
pyautogui.moveRel(0, 60)
pyautogui.click()
time.sleep(1)
pyautogui.press('end')
for i in range(0, 4):
pyautogui.press('left')
for i in range(0, 2):
pyautogui.press('backspace')
pyautogui.typewrite('Analysis')
pyautogui.press('enter')
# Open file with Painter
def open_file():
pyautogui.doubleClick()
time.sleep(2)
pyautogui.moveTo(445, 65)
pyautogui.click() # select Rectangle tool
# Duplicate file, ramane it and open it with Painter
def analyze_file(file_number):
x = 160
y = 70 + (file_number - 1) * 155
print('(x, y) = ('+ str(x) + ', ' + str(y) +')')
pyautogui.moveTo(x, y)
duplicate_file()
rename_file()
open_file()
analyze_file(1)
台灣地震預測研究所 所長
林湧森(Dyson Lin)
2017-04-20 14:16 UTC+8
沒有留言:
張貼留言