From c23805320e1c05bbf1ba7215b439f2e452b26671 Mon Sep 17 00:00:00 2001 From: Hamed <36635653+Hamedrz004@users.noreply.github.com> Date: Tue, 6 Jan 2026 23:04:07 +0330 Subject: [PATCH] run on startup silently --- run_silent.bat | 4 ++++ run_silent.vbs | 4 ++++ src/__pycache__/startup.cpython-314.pyc | Bin 2846 -> 2854 bytes src/main.pyw | 7 ++++++- src/startup.py | 6 +++++- 5 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 run_silent.bat create mode 100644 run_silent.vbs 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 2ee39001772e315a891a620553fac682f58ee294..53680583b2288f4c9ab932a237608b875a400db7 100644 GIT binary patch delta 101 zcmbOywoHsyn~#@^0SFWmVl(?E@=oXHD=N*4FV4(K%`4F>ODf*D#)8Y*2&mu#Gb1D8 zZ3fQU47?Axr5ZSH@C){rcb50pch+B!*T2kf(7^MFg_}|TlN2wb@fSHhM$sZwpf&)^ C-5n?Z delta 50 zcmZ1`HcyOKn~#@^0SF#0o0-uuk#{-=dr@hgUQ%Mo#?2O7jE0lnaLKXGsJzUtIaz>P F3;=e}4?q9_ 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(): """