权威会员
- UID
- 519859
- 积分
- 12999
- 可用积分
- 点
- 威望
- 个
- 水滴
- 滴
- 存在感
- 点
- NB
- 点
- 豆币
- 点
- 帖子
- 主题
- 好友
- 精华
- APP积分
- 点
|
楼主 |
2023-10-11 14:51 发表于 江苏
|
显示全部楼层
自己顶一下自己,这几天觉得这个sizer4.0不好用,刚好有人介绍用了chatgpt,就下载了python,结果chat是真牛直接就给了可以用的:
需要成品的私信我
以下是源代码,下载一个python自己编译一下:
import tkinter as tk
from tkinter import messagebox
import win32con
import win32gui
import keyboard
class WindowModifier:
def __init__(self):
self.target_window = None
self.original_width = None
self.original_height = None
def get_target_window(self):
# Use the win32gui module to get the handle of the target window
target_title = "地下城与勇士:创新世纪"
self.target_window = win32gui.FindWindow(None, target_title)
if self.target_window != 0:
# Get the original size of the target window
rect = win32gui.GetWindowRect(self.target_window)
self.original_width = rect[2] - rect[0]
self.original_height = rect[3] - rect[1]
messagebox.showinfo("提示", "地下城窗口获取成功!")
else:
# Handle error if the target window is not found
print("Target window not found!")
def resize_window(self, new_width, new_height):
if self.target_window is not None:
# Resize the target window
win32gui.SetWindowPos(self.target_window, None, 0, 0, new_width, new_height, win32con.SWP_NOMOVE | win32con.SWP_NOZORDER)
print("Window resized to:", new_width, "x", new_height)
else:
print("Window not yet obtained")
def restore_window_size(self):
if self.target_window is not None and self.original_width is not None and self.original_height is not None:
# Restore the original size of the target window
win32gui.SetWindowPos(self.target_window, None, 0, 0, self.original_width, self.original_height, win32con.SWP_NOMOVE | win32con.SWP_NOZORDER)
print("Window size restored to original.")
else:
print("Window size not yet modified")
# Create the main window
window = tk.Tk()
window.title("DNF窗口修改器")
window.geometry("240x200")
modifier = WindowModifier()
# Add a button to get the target window
get_button = tk.Button(window, text="获取DNF窗口", command=modifier.get_target_window)
get_button.pack()
# Add an entry for entering the window size
width_label = tk.Label(window, text="宽度:")
width_label.pack()
width_entry = tk.Entry(window)
width_entry.pack()
height_label = tk.Label(window, text="高度:")
height_label.pack()
height_entry = tk.Entry(window)
height_entry.pack()
# Add a button to resize the window
resize_button = tk.Button(window, text="修改窗口", command=lambda: modifier.resize_window(int(width_entry.get()), int(height_entry.get())))
resize_button.pack()
# Add a button to restore the window size
restore_button = tk.Button(window, text="还原窗口", command=modifier.restore_window_size)
restore_button.pack()
# Run the main event loop
window.mainloop()
|
|