import win32con
import win32api
import pyautogui
import time
import tkinter as tk
pyautogui.FAILSAFE = False
strings = [‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’]
def a():
# 向右移动 500 像素
pyautogui.move(500, 0)
time.sleep(0.3)
# 向下移动 300 像素
pyautogui.move(0, 300)
time.sleep(0.3)
# 左键点击
pyautogui.click(button='left')
time.sleep(0.3)
win32api.keybd_event(16, 0, 0, 0) # 键盘按下
time.sleep(1)
win32api.keybd_event(16, 0, win32con.KEYEVENTF_KEYUP, 0) # 键盘松开 # 打开 shift
for s in strings:
pyautogui.typewrite(s)
time.sleep(0.1)
root = tk.Tk()
root.title(“操作程序”)
root.geometry(“600x300”)
button = tk.Button(root, text=“执行操作”, command=a)
button.place(x=200, y=100, width=100, height=50)
root.mainloop()