halp/install_right_click.py
bake a5eb09f40f Initial commit: Python-based local AI assistant
- Add main GUI application (local_agent_ui.py) with customtkinter interface
- Add Windows right-click context menu installer (install_right_click.py)
- Add project documentation (CLAUDE.md) with setup and usage instructions
- Add .gitignore for Python project files

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-23 10:50:34 -05:00

53 lines
2.0 KiB
Python

pimport sys
import os
import winreg as reg
# --- Configuration ---
# The text that will appear in the right-click menu
MENU_ITEM_NAME = "Open AI Assistant Here"
# --- Main Logic ---
def install():
try:
# Get the absolute path to the python executable and the main script
python_exe = sys.executable
script_path = os.path.abspath("local_agent_ui.py")
# The command that will be executed when the menu item is clicked
# %V is a placeholder that Windows replaces with the directory you right-clicked in
command = f'"{python_exe}" "{script_path}" "%V"'
# Registry path for the context menu on the background of a folder
key_path = r'Directory\\Background\\shell'
# Create the main key for our menu item
with reg.CreateKey(reg.HKEY_CLASSES_ROOT, f'{key_path}\\{MENU_ITEM_NAME}') as key:
# Create the 'command' subkey and set its value to our command
with reg.CreateKey(key, 'command') as command_key:
reg.SetValue(command_key, None, reg.REG_SZ, command)
print(f"Successfully installed '{MENU_ITEM_NAME}' context menu item.")
print("You can now right-click inside any folder to launch the assistant with that folder as context.")
except Exception as e:
print(f"Error: {e}")
print("Please try running this script as an administrator.")
def uninstall():
try:
key_path = r'Directory\\Background\\shell'
reg.DeleteKey(reg.HKEY_CLASSES_ROOT, f'{key_path}\\{MENU_ITEM_NAME}\\command')
reg.DeleteKey(reg.HKEY_CLASSES_ROOT, f'{key_path}\\{MENU_ITEM_NAME}')
print(f"Successfully uninstalled '{MENU_ITEM_NAME}'.")
except FileNotFoundError:
print("Menu item not found. Nothing to uninstall.")
except Exception as e:
print(f"Error: {e}")
print("Please try running this script as an administrator.")
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == 'uninstall':
uninstall()
else:
install()