import pyautogui
import tkinter as tk
import tkinter.messagebox
import win32gui, win32con, win32api
import time
import pyperclip
import webbrowser
def open_web(mode):
if mode==1:
url = "https://survey.tn.edu.tw/" # 注意:"http://"不可省略
if mode==2:
url = "https://www.google.com/" # 注意:"http://"不可省略
webbrowser.open(url)
mouse_move(mode)
def mouse_move(mode):
if mode==1:
pyautogui.moveTo(100, 200, 1)
if mode==2:
pyautogui.moveTo(600, 200, 1)
def move(mode):
notepad = win32gui.FindWindow("Notepad", None)
if (notepad != 0):
win32gui.SetForegroundWindow(notepad)
else:
win32api.ShellExecute(0,"open","notepad.exe","","",1)
time.sleep(1)
if mode == 1:
pyperclip.copy('擬辦:\r\n一、知悉\r\n二、陳核後文存查\r\n')
pyautogui.hotkey('ctrl', 'v')
if mode == 2:
pyperclip.copy('擬辦:\r\n一、本校無移撥意願\r\n二、陳核後文存查\r\n')
pyautogui.hotkey('ctrl', 'v')
if mode == 3:
pyperclip.copy('擬辦:\r\n一、依函示規定辦理\r\n二、陳核後文存查\r\n')
pyautogui.hotkey('ctrl', 'v')
window = tk.Tk()
window.title('新版按鍵精靈')
window.geometry("300x150+250+150")
# 按鈕
button = tk.Button(window, text = "知悉", command = lambda:move(1))
button.pack()
button2 = tk.Button(window, text = "本校無移撥意願", command = lambda:move(2))
button2.pack()
button3 = tk.Button(window, text = "線上填報", command = lambda:open_web(1))
button3.pack()
button4 = tk.Button(window, text = "google", command = lambda:open_web(2))
button4.pack()
window.bind("<F1>",lambda event:move(3))
window.mainloop()
沒有留言:
張貼留言