diff --git a/run_silent.bat b/run_silent.bat new file mode 100644 index 0000000..a3067b5 --- /dev/null +++ b/run_silent.bat @@ -0,0 +1,4 @@ +@echo off +cd /d "%~dp0" +call venv\Scripts\activate.bat +start "" pythonw src\main.pyw diff --git a/run_silent.vbs b/run_silent.vbs new file mode 100644 index 0000000..5b11679 --- /dev/null +++ b/run_silent.vbs @@ -0,0 +1,4 @@ +Set WshShell = CreateObject("WScript.Shell") +strPath = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName) +WshShell.Run chr(34) & strPath & "\run_silent.bat" & Chr(34), 0 +Set WshShell = Nothing diff --git a/src/__pycache__/startup.cpython-314.pyc b/src/__pycache__/startup.cpython-314.pyc index 2ee3900..5368058 100644 Binary files a/src/__pycache__/startup.cpython-314.pyc and b/src/__pycache__/startup.cpython-314.pyc differ diff --git a/src/main.pyw b/src/main.pyw index 01a5a7b..84eaa0e 100644 --- a/src/main.pyw +++ b/src/main.pyw @@ -232,7 +232,12 @@ def main(): ensure_single_instance() config = load_config() # Sync startup state just in case it was changed externally - config["run_on_startup"] = is_in_startup() + if is_in_startup(): + config["run_on_startup"] = True + # Update the registry key to point to the current location (in case the app was moved) + add_to_startup() + else: + config["run_on_startup"] = False save_config(config) # Start the tray icon in a separate thread diff --git a/src/startup.py b/src/startup.py index c77f124..c86d61c 100644 --- a/src/startup.py +++ b/src/startup.py @@ -2,7 +2,11 @@ import os import winreg APP_NAME = "OopsWrongLang" -RUN_BAT_PATH = os.path.abspath("run.bat") +# Get the directory of the current script (src) +current_dir = os.path.dirname(os.path.abspath(__file__)) +# The project root is one level up +project_root = os.path.dirname(current_dir) +RUN_BAT_PATH = os.path.join(project_root, "run_silent.vbs") def add_to_startup(): """