diff --git a/core/app_launcher.py b/core/app_launcher.py index 1bc1db1..94553e2 100644 --- a/core/app_launcher.py +++ b/core/app_launcher.py @@ -110,12 +110,18 @@ def parse_lnk_file(file_path: Path) -> Optional[App]: shortcut = shell.CreateShortCut(str(file_path)) target = shortcut.TargetPath - if not target: + arguments = shortcut.Arguments + + if not target or not os.path.exists(target): return None + full_exec = f'"{target}"' + if arguments: + full_exec += f' {arguments}' + return App( name=file_path.stem, - exec=target, + exec=full_exec, comment=shortcut.Description, icon=shortcut.IconLocation.split(',')[0] if shortcut.IconLocation else "" ) @@ -173,13 +179,18 @@ def reload_app_cache() -> list[App]: def launch(app: App): if platform.system() == "Windows": try: - os.startfile(app.exec) + command_args = shlex.split(app.exec, posix=False) + + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + + subprocess.Popen( + command_args, + creationflags=subprocess.DETACHED_PROCESS, + startupinfo=startupinfo + ) except Exception as e: - print(f"Failed to launch '{app.name}' with os.startfile: {e}. Trying subprocess.") - try: - subprocess.Popen([app.exec]) - except Exception as e2: - print(f"Failed to launch '{app.name}' with subprocess: {e2}") + print(f"Failed to launch '{app.name}': {e}") else: cleaned_exec = app.exec.split(' %')[0] try: diff --git a/windows/main_window.py b/windows/main_window.py index 515658f..acdf45a 100644 --- a/windows/main_window.py +++ b/windows/main_window.py @@ -216,7 +216,7 @@ class MainWindow(QtWidgets.QMainWindow): super().closeEvent(event) def ensure_on_top(self): - if self.isVisible(): + if self.isVisible() and not self.left_menu.isVisible() and not self.tray.contextMenu().isVisible(): self.raise_() def showEvent(self, event):