import win32api
import win32gui
import win32con
import time
import tkinter as tk## pyinstaller --onefile t4.py 將python 代碼打包為windows可執行文件 .exe
## airtext 大漠 def clickGoogle():hw = win32gui.FindWindow("Chrome_WidgetWin_1", "新標簽頁 - Google Chrome")a = win32gui.GetClassName(hw)title = win32gui.GetWindowText(hw)print(title)# 獲取窗口坐標left, top, right, bottom = win32gui.GetWindowRect(hw)print("窗口位置:({}, {})".format(left, top))print("窗口大小:{} x {}".format(right - left, bottom - top))x = 0y = 0width = 1920height = 1080repaint = Truewin32gui.MoveWindow(hw, x, y, width, height, repaint)print('--------------')win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 250, 60, 0, 0)win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 250, 60, 0, 0)win32api.MessageBox(0, "https://cn.bing.com/?mkt=zh-CN", 'text', win32con.MB_OK | win32con.MB_ICONWARNING)if __name__ == '__main__':# 創建Tkinter窗口root = tk.Tk()root.title("簡單的Tkinter應用程序")root.geometry('700x400+800+300')# 創建標簽和文本框#label = tk.Label(root, text="請輸入您的姓名:")#label.pack()#name_entry = tk.Entry(root)#name_entry.pack()# 創建按鈕hello_button1 = tk.Button(root, text="啟動", command=clickGoogle)hello_button1.pack()hello_button2 = tk.Button(root, text="停止", command=clickGoogle)hello_button2.pack()# 啟動Tkinter主事件循環root.mainloop()