diff --git a/LunaTranslator/LunaTranslator/LunaTranslator.py b/LunaTranslator/LunaTranslator/LunaTranslator.py index 3222b3a8..dc7be4b4 100644 --- a/LunaTranslator/LunaTranslator/LunaTranslator.py +++ b/LunaTranslator/LunaTranslator/LunaTranslator.py @@ -28,7 +28,7 @@ from myutils.utils import ( ) from myutils.wrapper import threader from gui.showword import searchwordW -from myutils.hwnd import getpidexe, ListProcess, getExeIcon +from myutils.hwnd import getpidexe, ListProcess, getExeIcon, getcurrexe from textsource.copyboard import copyboard from textsource.texthook import texthook from textsource.ocrtext import ocrtext @@ -1131,7 +1131,7 @@ class MAINUI: trayMenu.addAction(quitAction) self.tray = QSystemTrayIcon() - icon = getExeIcon(sys.argv[0]) #'./LunaTranslator.exe')# QIcon() + icon = getExeIcon(getcurrexe()) #'./LunaTranslator.exe')# QIcon() self.tray.setIcon(icon) self.tray.activated.connect(self.translation_ui.leftclicktray) diff --git a/LunaTranslator/LunaTranslator/gobject.py b/LunaTranslator/LunaTranslator/gobject.py index 4832b919..d3b77568 100644 --- a/LunaTranslator/LunaTranslator/gobject.py +++ b/LunaTranslator/LunaTranslator/gobject.py @@ -64,9 +64,7 @@ def overridepathexists(): def testuseqwebengine(): - return os.path.exists( - "./LunaTranslator/runtime/PyQt5/Qt5/bin/Qt5WebEngineCore.dll" - ) or (len(sys.argv) and sys.argv[-1] == "test") + return os.path.exists("./LunaTranslator/runtime/PyQt5/Qt5/bin/Qt5WebEngineCore.dll") serverindex = 0 diff --git a/LunaTranslator/LunaTranslator/gui/setting_about.py b/LunaTranslator/LunaTranslator/gui/setting_about.py index 28b5f58d..32c20f0d 100644 --- a/LunaTranslator/LunaTranslator/gui/setting_about.py +++ b/LunaTranslator/LunaTranslator/gui/setting_about.py @@ -3,6 +3,7 @@ import platform, functools, sys import winsharedutils, queue from myutils.config import globalconfig, static_data, _TR from myutils.wrapper import threader, tryprint +from myutils.hwnd import getcurrexe from myutils.utils import makehtml, getlanguse, dynamiclink import requests import shutil, gobject @@ -158,7 +159,7 @@ def versioncheckthread(self): else: sversion = _version[0] self.versiontextsignal.emit(sversion) - version = winsharedutils.queryversion(sys.argv[0]) + version = winsharedutils.queryversion(getcurrexe()) need = ( version and _version @@ -288,7 +289,7 @@ def setTab_aboutlazy(self, basel): def setTab_update(self, basel): - version = winsharedutils.queryversion(sys.argv[0]) + version = winsharedutils.queryversion(getcurrexe()) if version is None: versionstring = "unknown" else: diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 6c128a71..cdd985e2 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -18,7 +18,7 @@ from myutils.utils import ( makehtml, loadpostsettingwindowmethod_maybe, ) -from myutils.hwnd import mouseselectwindow, grabwindow, getExeIcon, getpidexe +from myutils.hwnd import mouseselectwindow, grabwindow, getExeIcon, getpidexe, getcurrexe from gui.setting_about import doupdate from gui.dialog_memory import dialog_memory from gui.textbrowser import Textbrowser @@ -846,7 +846,7 @@ class QUnFrameWindow(resizableframeless): | Qt.WindowType.WindowMinimizeButtonHint, poslist=globalconfig["transuigeo"], ) # 设置为顶级窗口,无边框 - icon = getExeIcon(sys.argv[0]) #'./LunaTranslator.exe')# QIcon() + icon = getExeIcon(getcurrexe()) #'./LunaTranslator.exe')# QIcon() # icon.addPixmap(QPixmap('./files/luna.png'), QIcon.Normal, QIcon.On) self.setWindowIcon(icon) self.firstshow = True diff --git a/LunaTranslator/LunaTranslator/myutils/hwnd.py b/LunaTranslator/LunaTranslator/myutils/hwnd.py index d7c984ec..0c6ab734 100644 --- a/LunaTranslator/LunaTranslator/myutils/hwnd.py +++ b/LunaTranslator/LunaTranslator/myutils/hwnd.py @@ -103,6 +103,10 @@ def getpidexe(pid): return name_ +def getcurrexe(): + return os.environ.get("LUNA_EXE_NAME", "") + + def test_injectable_1(pid): return bool( windows.AutoHandle( diff --git a/LunaTranslator/run_test.bat b/LunaTranslator/run_test.bat deleted file mode 100644 index 5df81311..00000000 --- a/LunaTranslator/run_test.bat +++ /dev/null @@ -1,2 +0,0 @@ -python.exe -B LunaTranslator\LunaTranslator_main.py test -pause \ No newline at end of file diff --git a/plugins/exec/PyStand.cpp b/plugins/exec/PyStand.cpp index 12e6ed15..e0307adb 100644 --- a/plugins/exec/PyStand.cpp +++ b/plugins/exec/PyStand.cpp @@ -278,7 +278,7 @@ const auto init_script = L" sys.stderr = fp\n" L" attached = False\n" #endif - L"sys.argv = [os.environ['LUNA_EXE_NAME'] ,sys.argv[0], PYSTAND_SCRIPT] + sys.argv[1:]\n" + L"sys.argv = [PYSTAND_SCRIPT] + sys.argv[1:]\n" L"text = open(PYSTAND_SCRIPT, 'rb').read()\n" L"environ = {'__file__': PYSTAND_SCRIPT, '__name__': '__main__'}\n" L"environ['__package__'] = None\n"