Windows Clipboard History ❲TRUSTED · BUNDLE❳

def monitor_clipboard(self): while self.running: try: current = pyperclip.paste() if current != self.last_text and current.strip() != "": self.last_text = current # Avoid duplicates of same consecutive text if not self.history or self.history[0]["text"] != current: self.history.insert(0, "text": current, "timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S") ) # Trim history while len(self.history) > MAX_HISTORY: removed = self.history.pop() self.pinned.discard((removed["text"], removed["timestamp"])) self.save_history() # Update GUI in main thread self.root.after(0, self.update_history_display) except Exception as e: print("Monitor error:", e) time.sleep(0.5)

self.history = [] self.pinned = set() self.load_history() self.last_text = pyperclip.paste() self.running = True # GUI self.create_widgets() self.update_history_display() # Start background monitor self.monitor_thread = threading.Thread(target=self.monitor_clipboard, daemon=True) self.monitor_thread.start() self.root.protocol("WM_DELETE_WINDOW", self.on_close) windows clipboard history

def save_history(self): try: with open(HISTORY_FILE, "w", encoding="utf-8") as f: json.dump( "history": self.history, "pinned": [list(p) for p in self.pinned] , f, ensure_ascii=False, indent=2) except: pass def monitor_clipboard(self): while self

def get_filtered_history(self): search_term = self.search_var.get().lower() filtered = [item for item in self.history if search_term in item["text"].lower()] # Sort: pinned first, then by timestamp desc filtered.sort(key=lambda x: (x["text"], x["timestamp"]) not in self.pinned) return filtered encoding="utf-8") as f: json.dump( "history": self.history

def clear_history(self): if messagebox.askyesno("Clear History", "Delete all clipboard history?"): self.history = [] self.pinned.clear() self.save_history() self.update_history_display() self.status_var.set("History cleared")

def show_context_menu(self, event): try: index = self.listbox.nearest(event.y) if index >= 0: self.listbox.selection_clear(0, tk.END) self.listbox.selection_set(index) menu = tk.Menu(self.root, tearoff=0) menu.add_command(label="Copy to clipboard", command=self.paste_selected) menu.add_command(label="Pin / Unpin", command=lambda: self.toggle_pin(index)) menu.add_command(label="Delete", command=lambda: self.delete_selected(index)) menu.post(event.x_root, event.y_root) except: pass