run on startup silently

This commit is contained in:
Hamed
2026-01-06 23:04:07 +03:30
parent 66c0482ae3
commit c23805320e
5 changed files with 19 additions and 2 deletions

4
run_silent.bat Normal file
View File

@@ -0,0 +1,4 @@
@echo off
cd /d "%~dp0"
call venv\Scripts\activate.bat
start "" pythonw src\main.pyw

4
run_silent.vbs Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -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():
"""