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 = 0
y = 0
width = 1920
height = 1080
repaint = True
win32gui.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()
python windows 开发.exe程序笔记
最新推荐文章于 2024-07-08 18:25:59 发布