import pyautogui import time # 创建GUI界面来选择账号 print("请选择账号:") print("1.马家益") print("2.王中豪") print("3.陈诗源") print("4.陈亮") print("5.张少芬") print("6.海玲") print("7.张科") print("8.邱进东") print("9.黎福妮") print("10.任国军") print("11.叶穗君") choice = int(input("请输入选项:")) # 根据选择进行操作 if choice == 1: username = "马家益" password = "tb021 A*123456" elif choice == 2: username = "王中豪" password = "tb121 W123456*" elif choice == 3: username = "陈诗源" password = "tb058 A*123456" elif choice == 4: username = "陈亮" password = "tb057 12345678" elif choice == 5: username = "张少芬" password = "tb017 A*123456" elif choice == 6: username = "海玲" password = "tb020 A*123456" elif choice == 7: username = "张科" password = "tb090 Tbyy123456@" elif choice == 8: username = "邱进东" password = "tb110 A*123456" elif choice == 9: username = "黎福妮" password = "tb095 HD@123456" elif choice == 10: username = "任国军" password = "tb051 HD@123456" elif choice == 11: username = "叶穗君" password = "tb032 A*123456" else: print("无效的选项") exit() # 单击左键并输入账号 pyautogui.click(843, 440) pyautogui.typewrite(username) # 单击左键并输入密码,然后按回车键 time.sleep(1) # 等待界面加载 pyautogui.click(952, 495) pyautogui.typewrite(password) pyautogui.press('enter'),帮我修改一下,创建一个gui界面
时间: 2023-07-06 21:12:14 浏览: 94
好的,我可以帮你修改代码,添加一个 GUI 界面来选择账号。你可以使用 Python 的 tkinter 模块来创建界面。以下是修改后的代码示例:
```
import pyautogui
import time
import tkinter as tk
# 创建 GUI 界面
root = tk.Tk()
root.title("选择账号")
# 创建标签和选项
tk.Label(root, text="请选择账号:").grid(row=0, column=0, sticky=tk.W, padx=10, pady=10)
options = [
("马家益", "tb021 A*123456"),
("王中豪", "tb121 W123456*"),
("陈诗源", "tb058 A*123456"),
("陈亮", "tb057 12345678"),
("张少芬", "tb017 A*123456"),
("海玲", "tb020 A*123456"),
("张科", "tb090 Tbyy123456@"),
("邱进东", "tb110 A*123456"),
("黎福妮", "tb095 HD@123456"),
("任国军", "tb051 HD@123456"),
("叶穗君", "tb032 A*123456")
]
var = tk.StringVar()
var.set("") # 设置默认值为空
for i, option in enumerate(options):
tk.Radiobutton(root, text=option[0], variable=var, value=option[1]).grid(row=i+1, column=0, sticky=tk.W, padx=10, pady=5)
# 创建按钮
def login():
# 获取选择的账号和密码
choice = var.get()
if not choice:
tk.messagebox.showwarning("警告", "请选择一个账号!")
return
username, password = choice.split()
# 单击左键并输入账号
pyautogui.click(843, 440)
pyautogui.typewrite(username)
# 单击左键并输入密码,然后按回车键
time.sleep(1) # 等待界面加载
pyautogui.click(952, 495)
pyautogui.typewrite(password)
pyautogui.press('enter')
tk.Button(root, text="登录", command=login).grid(row=len(options)+1, column=0, pady=10)
root.mainloop()
```
运行这段代码,将会弹出一个窗口,你可以选择一个账号,然后点击 “登录” 按钮,程序将会自动输入账号和密码并进行登录。
阅读全文