Untitled
unknown
plain_text
a month ago
2.1 kB
8
Indexable
Never
import tkinter as tk from tkinter import * import psutil import os import ctypes from tkinter import filedialog import tkinter.messagebox as messagebox def choose_file(): root = tk.Tk() root.withdraw() file_path = filedialog.askopenfilename(filetypes=[("Tekstfiler", "*.txt")]) if file_path: file_label.config(text=file_path) return file_path else: return None def inject_script(filename, text_to_inject): try: with open(filename, 'a') as file: file.write(text_to_inject + '\n') messagebox.showinfo("Succes", "Teksten er blevet skrevet til filen.") except IOError as e: messagebox.showerror("Fejl", f"Kunne ikke skrive til filen: {e}") def handle_inject_button(): filename = choose_file() if filename: text_to_inject = script_entry.get("1.0", tk.END").strip() if text_to_inject: inject_script(filename, text_to_inject) else: messagebox.showwarning("Advarsel", "Indtast venligst noget tekst.") else: messagebox.showwarning("Advarsel", "Ingen fil valgt.") def center_window(window): """Centererer et vindue på skærmen. Args: window: Det vindue, der skal centreres. """ window.update_idletasks() width = window.winfo_width() height = window.winfo_height() x = (window.winfo_screenwidth() // 2) - (width // 2) y = (window.winfo_screenheight() // 2) - (height // 2) window.geometry('{}x{}+{}+{}'.format(width, height, x, y)) root = tk.Tk() root.title("Script Injektor") file_label = tk.Label(root, text="Ingen fil valgt") file_label.pack() script_label = tk.Label(root, text="Indtast text:") script_label.pack() script_entry = tk.Text(root, height=10) script_entry.pack() choose_process_button = tk.Button(root, text="Vælg .txt fil", command=choose_file) choose_process_button.pack() inject_button = tk.Button(root, text="Indsæt text i dokumentet", command=inject_script) inject_button.pack() center_window(root) root.mainloop()
Leave a Comment