import tkinter as tk from tkinter import ttk import os from pynput import keyboard import threading # Define color palette COLOR_PRIMARY = "#4285F4" COLOR_PRIMARY_LIGHT = "#6AA9FF" COLOR_BACKGROUND = "#FFFFFF" COLOR_TEXT = "#000000" def launch_application(application_path): os.startfile(application_path) def search_applications(): search_text = search_entry.get().lower() search_results.delete(*search_results.get_children()) if not search_text: return search_text = search_text.strip() for lowercase_name, application_name in index.items(): if lowercase_name.startswith(search_text): search_results.insert("", tk.END, text=application_name, values=[application_name]) def launch_selected_application(event=None): selected_item = search_results.focus() if selected_item: selected_application = search_results.item(selected_item)["text"] application_path = applications.get(selected_application) threading.Thread(target=launch_application, args=(application_path,)).start() def on_activate(event=None): if window.attributes("-alpha") == 1.0: window.attributes("-alpha", 0.0) search_entry.focus() else: window.attributes("-alpha", 1.0) window.deiconify() window.focus_set() # Dictionary of applications (application_name: application_path) applications = { "Calculator": "C:\\Windows\\System32\\calc.exe", "Notepad": "C:\\Windows\\System32\\notepad.exe", "Paint": "C:\\Windows\\System32\\mspaint.exe" } index = {app_name.lower(): app_name for app_name in applications} window = tk.Tk() window.title("Application Launcher") window.geometry("400x200") window.attributes("-alpha", 0.0) window.bind("", on_activate) # Configure the style to match Google Material Design style = ttk.Style(window) style.configure("TMenubutton", background=COLOR_PRIMARY, foreground=COLOR_TEXT) style.configure("TEntry", fieldbackground=COLOR_BACKGROUND, foreground=COLOR_TEXT) style.configure("Treeview", fieldbackground=COLOR_BACKGROUND, foreground=COLOR_TEXT) # Create the search entry field search_entry = ttk.Entry(window) search_entry.pack(pady=10) # Create the search results treeview search_results = ttk.Treeview(window, columns=("name"), show="headings") search_results.column("name", width=200, anchor="w") search_results.heading("name", text="Application Name") search_results.pack(fill=tk.BOTH, expand=True) # Bind events to functions search_entry.bind("", lambda event: threading.Thread(target=search_applications).start()) search_results.bind("", lambda event: threading.Thread(target=launch_selected_application).start()) hotkey_combination = {keyboard.Key.space, keyboard.Key.ctrl} current_keys = set() def on_press(key): if key in hotkey_combination: current_keys.add(key) if all(k in current_keys for k in hotkey_combination): on_activate() def on_release(key): if key in hotkey_combination: current_keys.remove(key) listener = keyboard.Listener(on_press=on_press, on_release=on_release) listener.start() window.mainloop()