This commit is contained in:
恍兮惚兮 2024-08-08 16:42:20 +08:00
parent 31d2aef8ad
commit 37a577c69b
7 changed files with 13 additions and 12 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,2 +0,0 @@
python.exe -B LunaTranslator\LunaTranslator_main.py test
pause

View File

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