python完整无错游戏多开窗口绑定脚本 import tkinter as tk from tkinter import ttk, messagebox import win32gui import win32con class ExclusiveWindowBinder: def __init__(self): self.root = tk.Tk() self.root.title("游戏多窗口绑定器") self.root.geometry("420x380") self.bound_windows = {} # 存储槽位与窗口句柄的映射 self.status_vars = {} # 存储状态变量 self.setup_ui() self.root.after(1000, self.check_window_status) def setup_ui(self): for i in range(4): frame = ttk.LabelFrame(self.root, text=f"绑定窗口 {i+1}") frame.grid(row=0, column=i, padx=5, pady=5, sticky="nsew") self.setup_slot_ui(frame, i+1) self.root.columnconfigure(i, weight=1) def setup_slot_ui(self, parent, slot_id): status_var = tk.StringVar(value="等待绑定") self.status_vars[slot_id] = status_var label = ttk.Label(parent, textvariable=status_var) label.pack(pady=5)
def bind_action(): hwnd = self.find_available_window() if hwnd: self.bound_windows[slot_id] = hwnd title = win32gui.GetWindowText(hwnd)[:20] status_var.set(f"已绑定: {title}...") label.config(foreground='black') else: messagebox.showwarning("绑定失败", "无可用窗口或已被其他槽位绑定") ttk.Button(parent, text="点击绑定", command=bind_action).pack() def check_window_status(self): for slot_id, hwnd in list(self.bound_windows.items()): if not win32gui.IsWindow(hwnd): self.status_vars[slot_id].set("窗口已断开") for widget in self.root.winfo_children(): if isinstance(widget, ttk.LabelFrame): for child in widget.winfo_children(): if isinstance(child, ttk.Label) and child.cget("textvariable") == self.status_vars[slot_id]._name: child.config(foreground='red') del self.bound_windows[slot_id] self.root.after(1000, self.check_window_status) def find_available_window(self): def callback(hwnd, extra): if (win32gui.IsWindowVisible(hwnd) and "QQ" in win32gui.GetWindowText(hwnd) and hwnd not in self.bound_windows.values()): extra.append(hwnd) return True
candidates = [] win32gui.EnumWindows(callback, candidates) return candidates[0] if candidates else None if __name__ == "__main__": app = ExclusiveWindowBinder() app.root.mainloop() |