mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 00:24:13 +08:00
fix
This commit is contained in:
parent
620e99aa5d
commit
ef82fb3d04
@ -1,5 +1,5 @@
|
|||||||
import time, uuid
|
import time, uuid
|
||||||
import os, threading, sys, re, codecs
|
import os, threading, re, codecs, winreg
|
||||||
from qtsymbols import *
|
from qtsymbols import *
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from myutils.config import (
|
from myutils.config import (
|
||||||
@ -10,10 +10,10 @@ from myutils.config import (
|
|||||||
findgameuidofpath,
|
findgameuidofpath,
|
||||||
savehook_new_data,
|
savehook_new_data,
|
||||||
static_data,
|
static_data,
|
||||||
tryreadconfig,
|
|
||||||
getlanguse,
|
getlanguse,
|
||||||
set_font_default,
|
set_font_default,
|
||||||
)
|
)
|
||||||
|
from ctypes import c_int, CFUNCTYPE, c_void_p
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from myutils.utils import (
|
from myutils.utils import (
|
||||||
minmaxmoveobservefunc,
|
minmaxmoveobservefunc,
|
||||||
@ -26,7 +26,7 @@ from myutils.utils import (
|
|||||||
targetmod,
|
targetmod,
|
||||||
translate_exits,
|
translate_exits,
|
||||||
)
|
)
|
||||||
from myutils.wrapper import threader
|
from myutils.wrapper import threader, tryprint
|
||||||
from gui.showword import searchwordW
|
from gui.showword import searchwordW
|
||||||
from myutils.hwnd import getpidexe, ListProcess, getExeIcon, getcurrexe
|
from myutils.hwnd import getpidexe, ListProcess, getExeIcon, getcurrexe
|
||||||
from textsource.copyboard import copyboard
|
from textsource.copyboard import copyboard
|
||||||
@ -1106,40 +1106,34 @@ class MAINUI:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def inittray(self):
|
def inittray(self):
|
||||||
|
self.tray = QSystemTrayIcon()
|
||||||
|
self.tray.setIcon(getExeIcon(getcurrexe()))
|
||||||
trayMenu = LMenu(self.commonstylebase)
|
trayMenu = LMenu(self.commonstylebase)
|
||||||
showAction = LAction(
|
showAction = LAction("&显示", trayMenu)
|
||||||
("&显示"),
|
showAction.triggered.connect(self.translation_ui.show_)
|
||||||
trayMenu,
|
settingAction = LAction(qtawesome.icon("fa.gear"), "&设置", trayMenu)
|
||||||
triggered=self.translation_ui.show_,
|
settingAction.triggered.connect(self.settin_ui.showsignal)
|
||||||
)
|
quitAction = LAction(qtawesome.icon("fa.times"), "&退出", trayMenu)
|
||||||
settingAction = LAction(
|
quitAction.triggered.connect(self.translation_ui.close)
|
||||||
qtawesome.icon("fa.gear"),
|
trayMenu.addAction(showAction)
|
||||||
("&设置"),
|
trayMenu.addAction(settingAction)
|
||||||
trayMenu,
|
trayMenu.addSeparator()
|
||||||
triggered=lambda: self.settin_ui.showsignal.emit(),
|
trayMenu.addAction(quitAction)
|
||||||
)
|
|
||||||
quitAction = LAction(
|
|
||||||
qtawesome.icon("fa.times"),
|
|
||||||
("&退出"),
|
|
||||||
trayMenu,
|
|
||||||
triggered=self.translation_ui.close,
|
|
||||||
)
|
|
||||||
trayMenu.addAction(showAction)
|
trayMenu.addAction(showAction)
|
||||||
trayMenu.addAction(settingAction)
|
trayMenu.addAction(settingAction)
|
||||||
trayMenu.addSeparator()
|
trayMenu.addSeparator()
|
||||||
trayMenu.addAction(quitAction)
|
trayMenu.addAction(quitAction)
|
||||||
self.tray = QSystemTrayIcon()
|
|
||||||
|
|
||||||
icon = getExeIcon(getcurrexe()) #'./LunaTranslator.exe')# QIcon()
|
|
||||||
self.tray.setIcon(icon)
|
|
||||||
|
|
||||||
self.tray.activated.connect(self.translation_ui.leftclicktray)
|
|
||||||
self.tray.show()
|
|
||||||
self.tray.setContextMenu(trayMenu)
|
self.tray.setContextMenu(trayMenu)
|
||||||
|
self.tray.activated.connect(self.leftclicktray)
|
||||||
|
self.tray.messageClicked.connect(winsharedutils.dispatchcloseevent)
|
||||||
|
self.tray.show()
|
||||||
|
|
||||||
|
def leftclicktray(self, reason):
|
||||||
|
if reason == QSystemTrayIcon.ActivationReason.Trigger:
|
||||||
|
self.translation_ui.showhideui()
|
||||||
|
|
||||||
def showtraymessage(self, title, message):
|
def showtraymessage(self, title, message):
|
||||||
self.tray.showMessage(_TR(title), _TR(message), QSystemTrayIcon.MessageIcon())
|
self.tray.showMessage(_TR(title), _TR(message), getExeIcon(getcurrexe()))
|
||||||
|
|
||||||
def destroytray(self):
|
def destroytray(self):
|
||||||
self.tray.hide()
|
self.tray.hide()
|
||||||
@ -1234,7 +1228,8 @@ class MAINUI:
|
|||||||
target=minmaxmoveobservefunc, args=(self.translation_ui,)
|
target=minmaxmoveobservefunc, args=(self.translation_ui,)
|
||||||
).start()
|
).start()
|
||||||
threading.Thread(target=self.checkgameplayingthread).start()
|
threading.Thread(target=self.checkgameplayingthread).start()
|
||||||
threading.Thread(target=self.darklistener).start()
|
self.messagecallback__ = CFUNCTYPE(None, c_int, c_void_p)(self.messagecallback)
|
||||||
|
winsharedutils.globalmessagelistener(self.messagecallback__)
|
||||||
self.inittray()
|
self.inittray()
|
||||||
self.createsavegamedb()
|
self.createsavegamedb()
|
||||||
|
|
||||||
@ -1244,14 +1239,15 @@ class MAINUI:
|
|||||||
return
|
return
|
||||||
return os.startfile(file)
|
return os.startfile(file)
|
||||||
|
|
||||||
def darklistener(self):
|
def messagecallback(self, msg, param):
|
||||||
sema = winsharedutils.startdarklistener()
|
if msg == 0:
|
||||||
while True:
|
|
||||||
# 会触发两次
|
|
||||||
windows.WaitForSingleObject(sema, windows.INFINITE)
|
|
||||||
if globalconfig["darklight2"] == 0:
|
if globalconfig["darklight2"] == 0:
|
||||||
self.commonstylebase.setstylesheetsignal.emit()
|
self.commonstylebase.setstylesheetsignal.emit()
|
||||||
windows.WaitForSingleObject(sema, windows.INFINITE)
|
elif msg == 1:
|
||||||
|
if bool(param):
|
||||||
|
windows.BringWindowToTop(int(self.translation_ui.winid))
|
||||||
|
elif msg == 2:
|
||||||
|
self.translation_ui.closesignal.emit()
|
||||||
|
|
||||||
def installeventfillter(self):
|
def installeventfillter(self):
|
||||||
class WindowEventFilter(QObject):
|
class WindowEventFilter(QObject):
|
||||||
@ -1284,3 +1280,18 @@ class MAINUI:
|
|||||||
targetmod[k] = importlib.import_module(f"metadata.{k}").searcher(k)
|
targetmod[k] = importlib.import_module(f"metadata.{k}").searcher(k)
|
||||||
except:
|
except:
|
||||||
print_exc()
|
print_exc()
|
||||||
|
|
||||||
|
@tryprint
|
||||||
|
def urlprotocol(self):
|
||||||
|
|
||||||
|
key = winreg.CreateKey(
|
||||||
|
winreg.HKEY_CURRENT_USER, r"Software\Classes\lunatranslator"
|
||||||
|
)
|
||||||
|
winreg.SetValue(key, None, winreg.REG_SZ, "URL:lunatranslator")
|
||||||
|
winreg.SetValueEx(key, r"URL Protocol", 0, winreg.REG_SZ, "")
|
||||||
|
keysub = winreg.CreateKey(
|
||||||
|
winreg.HKEY_CURRENT_USER,
|
||||||
|
r"Software\Classes\lunatranslator\shell\open\command",
|
||||||
|
)
|
||||||
|
command = f'"{getcurrexe()}" --URLProtocol "%1"'
|
||||||
|
winreg.SetValue(keysub, r"", winreg.REG_SZ, command)
|
||||||
|
@ -45,6 +45,7 @@ def loadmainui():
|
|||||||
|
|
||||||
gobject.baseobject = MAINUI()
|
gobject.baseobject = MAINUI()
|
||||||
gobject.baseobject.loadui()
|
gobject.baseobject.loadui()
|
||||||
|
# gobject.baseobject.urlprotocol()
|
||||||
|
|
||||||
|
|
||||||
def checklang():
|
def checklang():
|
||||||
@ -211,6 +212,27 @@ def savelogs():
|
|||||||
sys.stdout = debugoutput(sys.stdout)
|
sys.stdout = debugoutput(sys.stdout)
|
||||||
|
|
||||||
|
|
||||||
|
def urlprotocol():
|
||||||
|
import argparse
|
||||||
|
from urllib.parse import urlsplit
|
||||||
|
from traceback import print_exc
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--URLProtocol", required=False)
|
||||||
|
args = parser.parse_args()
|
||||||
|
URLProtocol: str = args.URLProtocol
|
||||||
|
try:
|
||||||
|
if URLProtocol:
|
||||||
|
print(URLProtocol)
|
||||||
|
result = urlsplit(URLProtocol)
|
||||||
|
netloc = result.netloc.lower()
|
||||||
|
if netloc == "oauthtoken":
|
||||||
|
token = result.path[1:]
|
||||||
|
|
||||||
|
except:
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
switchdir()
|
switchdir()
|
||||||
prepareqtenv()
|
prepareqtenv()
|
||||||
@ -222,5 +244,6 @@ if __name__ == "__main__":
|
|||||||
checkintegrity()
|
checkintegrity()
|
||||||
checkpermission()
|
checkpermission()
|
||||||
savelogs()
|
savelogs()
|
||||||
|
# urlprotocol()
|
||||||
loadmainui()
|
loadmainui()
|
||||||
app.exit(app.exec())
|
app.exit(app.exec())
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from qtsymbols import *
|
from qtsymbols import *
|
||||||
import platform, functools, sys
|
import platform, functools
|
||||||
import winsharedutils, queue
|
import winsharedutils, queue
|
||||||
from myutils.config import globalconfig, static_data, _TR
|
from myutils.config import globalconfig, static_data, _TR
|
||||||
from myutils.wrapper import threader, tryprint
|
from myutils.wrapper import threader, tryprint
|
||||||
@ -8,7 +8,6 @@ from myutils.utils import makehtml, getlanguse, dynamiclink
|
|||||||
import requests
|
import requests
|
||||||
import shutil, gobject
|
import shutil, gobject
|
||||||
from myutils.proxy import getproxy
|
from myutils.proxy import getproxy
|
||||||
from traceback import print_exc
|
|
||||||
import zipfile, os
|
import zipfile, os
|
||||||
import subprocess
|
import subprocess
|
||||||
from gui.usefulwidget import D_getsimpleswitch, makescrollgrid, makesubtab_lazy
|
from gui.usefulwidget import D_getsimpleswitch, makescrollgrid, makesubtab_lazy
|
||||||
@ -148,7 +147,7 @@ def versioncheckthread(self):
|
|||||||
while True:
|
while True:
|
||||||
x = versionchecktask.get()
|
x = versionchecktask.get()
|
||||||
gobject.baseobject.update_avalable = False
|
gobject.baseobject.update_avalable = False
|
||||||
self.progresssignal.emit("……", 0)
|
self.progresssignal.emit("", 0)
|
||||||
if not x:
|
if not x:
|
||||||
continue
|
continue
|
||||||
self.versiontextsignal.emit("获取中") # ,'',url,url))
|
self.versiontextsignal.emit("获取中") # ,'',url,url))
|
||||||
@ -167,6 +166,7 @@ def versioncheckthread(self):
|
|||||||
)
|
)
|
||||||
if not (need and globalconfig["autoupdate"]):
|
if not (need and globalconfig["autoupdate"]):
|
||||||
continue
|
continue
|
||||||
|
self.progresssignal.emit("……", 0)
|
||||||
savep = updatemethod(_version[1], self)
|
savep = updatemethod(_version[1], self)
|
||||||
if not savep:
|
if not savep:
|
||||||
self.progresssignal.emit(_TR("自动更新失败,请手动更新"), 0)
|
self.progresssignal.emit(_TR("自动更新失败,请手动更新"), 0)
|
||||||
@ -175,7 +175,9 @@ def versioncheckthread(self):
|
|||||||
uncompress(self, savep)
|
uncompress(self, savep)
|
||||||
gobject.baseobject.update_avalable = True
|
gobject.baseobject.update_avalable = True
|
||||||
self.progresssignal.emit(_TR("准备完毕,等待更新"), 10000)
|
self.progresssignal.emit(_TR("准备完毕,等待更新"), 10000)
|
||||||
gobject.baseobject.showtraymessage(sversion, "准备完毕,等待更新")
|
gobject.baseobject.showtraymessage(
|
||||||
|
sversion, "准备完毕,等待更新_\n_点击消息后退出并开始更新"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def updateprogress(self, text, val):
|
def updateprogress(self, text, val):
|
||||||
|
@ -167,8 +167,7 @@ def doinstallqweb(self, dd, base):
|
|||||||
zipf.extractall(target)
|
zipf.extractall(target)
|
||||||
bit = ["x86", "x64"][platform.architecture()[0] == "64bit"]
|
bit = ["x86", "x64"][platform.architecture()[0] == "64bit"]
|
||||||
copytree(f"{target}/{bit}/PyQt5", "LunaTranslator/runtime/PyQt5")
|
copytree(f"{target}/{bit}/PyQt5", "LunaTranslator/runtime/PyQt5")
|
||||||
|
getQMessageBox(self, "成功", "安装成功")
|
||||||
gobject.baseobject.showtraymessage("", "安装成功")
|
|
||||||
|
|
||||||
|
|
||||||
def installqwebdialog(self, link):
|
def installqwebdialog(self, link):
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from qtsymbols import *
|
from qtsymbols import *
|
||||||
import time, functools, threading, os, sys, importlib, shutil, uuid
|
import time, functools, threading, os, importlib, shutil, uuid
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
import windows, qtawesome, gobject, winsharedutils
|
import windows, qtawesome, gobject, winsharedutils
|
||||||
from myutils.wrapper import threader, trypass
|
from myutils.wrapper import threader, trypass
|
||||||
@ -18,7 +18,13 @@ from myutils.utils import (
|
|||||||
makehtml,
|
makehtml,
|
||||||
loadpostsettingwindowmethod_maybe,
|
loadpostsettingwindowmethod_maybe,
|
||||||
)
|
)
|
||||||
from myutils.hwnd import mouseselectwindow, grabwindow, getExeIcon, getpidexe, getcurrexe
|
from myutils.hwnd import (
|
||||||
|
mouseselectwindow,
|
||||||
|
grabwindow,
|
||||||
|
getExeIcon,
|
||||||
|
getpidexe,
|
||||||
|
getcurrexe,
|
||||||
|
)
|
||||||
from gui.setting_about import doupdate
|
from gui.setting_about import doupdate
|
||||||
from gui.dialog_memory import dialog_memory
|
from gui.dialog_memory import dialog_memory
|
||||||
from gui.textbrowser import Textbrowser
|
from gui.textbrowser import Textbrowser
|
||||||
@ -236,6 +242,7 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
ocr_once_signal = pyqtSignal()
|
ocr_once_signal = pyqtSignal()
|
||||||
resizesignal = pyqtSignal(QSize)
|
resizesignal = pyqtSignal(QSize)
|
||||||
move_signal = pyqtSignal(QPoint)
|
move_signal = pyqtSignal(QPoint)
|
||||||
|
closesignal = pyqtSignal()
|
||||||
|
|
||||||
@threader
|
@threader
|
||||||
def tracewindowposthread(self):
|
def tracewindowposthread(self):
|
||||||
@ -436,11 +443,6 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
else:
|
else:
|
||||||
self.hide_()
|
self.hide_()
|
||||||
|
|
||||||
def leftclicktray(self, reason):
|
|
||||||
# 鼠标左键点击
|
|
||||||
if reason == QSystemTrayIcon.Trigger:
|
|
||||||
self.showhideui()
|
|
||||||
|
|
||||||
def refreshtoolicon(self):
|
def refreshtoolicon(self):
|
||||||
self.titlebar.setFixedHeight(int(globalconfig["buttonsize"] * 1.5))
|
self.titlebar.setFixedHeight(int(globalconfig["buttonsize"] * 1.5))
|
||||||
self.titlebar.adjustminwidth()
|
self.titlebar.adjustminwidth()
|
||||||
@ -837,6 +839,7 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
self.toolbarhidedelaysignal.connect(self.toolbarhidedelay)
|
self.toolbarhidedelaysignal.connect(self.toolbarhidedelay)
|
||||||
self.resizesignal.connect(self.resize)
|
self.resizesignal.connect(self.resize)
|
||||||
self.move_signal.connect(self.move)
|
self.move_signal.connect(self.move)
|
||||||
|
self.closesignal.connect(self.close)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
@ -1226,19 +1229,28 @@ class QUnFrameWindow(resizableframeless):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def closeEvent(self, a0) -> None:
|
def closeEvent(self, a0) -> None:
|
||||||
if self.fullscreenmanager:
|
try:
|
||||||
self.fullscreenmanager.endX()
|
if self.fullscreenmanager:
|
||||||
gobject.baseobject.isrunning = False
|
self.fullscreenmanager.endX()
|
||||||
self.hide()
|
gobject.baseobject.isrunning = False
|
||||||
|
self.hide()
|
||||||
|
|
||||||
if gobject.baseobject.textsource:
|
if gobject.baseobject.textsource:
|
||||||
|
|
||||||
gobject.baseobject.textsource = None
|
gobject.baseobject.textsource = None
|
||||||
|
endsubprocs()
|
||||||
|
try:
|
||||||
|
saveallconfig()
|
||||||
|
self.tryremoveuseless()
|
||||||
|
except:
|
||||||
|
print_exc()
|
||||||
|
gobject.baseobject.destroytray()
|
||||||
|
handle = windows.CreateMutex(False, "LUNASAVECONFIG")
|
||||||
|
if windows.GetLastError() != windows.ERROR_ALREADY_EXISTS:
|
||||||
|
doupdate()
|
||||||
|
else:
|
||||||
|
windows.CloseHandle(handle)
|
||||||
|
os._exit(0)
|
||||||
|
|
||||||
saveallconfig()
|
except:
|
||||||
|
print_exc()
|
||||||
endsubprocs()
|
|
||||||
self.tryremoveuseless()
|
|
||||||
gobject.baseobject.destroytray()
|
|
||||||
doupdate()
|
|
||||||
os._exit(0)
|
|
||||||
|
@ -17,7 +17,7 @@ import os
|
|||||||
import gobject, functools
|
import gobject, functools
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from qtsymbols import *
|
from qtsymbols import *
|
||||||
from gui.usefulwidget import LFocusCombo, getboxlayout
|
from gui.usefulwidget import LFocusCombo, getboxlayout, getQMessageBox
|
||||||
from gui.dynalang import LPushButton, LFormLayout, LLabel
|
from gui.dynalang import LPushButton, LFormLayout, LLabel
|
||||||
|
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ def dodownload(combo: QComboBox, allsupports: list):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def doinstall(combo: QComboBox, allsupports: list, parent, callback):
|
def doinstall(self, combo: QComboBox, allsupports: list, parent, callback):
|
||||||
lang = allsupports[combo.currentIndex()]
|
lang = allsupports[combo.currentIndex()]
|
||||||
f = QFileDialog.getOpenFileName(parent, filter=lang + ".zip")
|
f = QFileDialog.getOpenFileName(parent, filter=lang + ".zip")
|
||||||
fn = f[0]
|
fn = f[0]
|
||||||
@ -149,8 +149,7 @@ def doinstall(combo: QComboBox, allsupports: list, parent, callback):
|
|||||||
try:
|
try:
|
||||||
with zipfile.ZipFile(fn) as zipf:
|
with zipfile.ZipFile(fn) as zipf:
|
||||||
zipf.extractall("files/ocr")
|
zipf.extractall("files/ocr")
|
||||||
|
getQMessageBox(self, "成功", "安装成功")
|
||||||
gobject.baseobject.showtraymessage("", "安装成功")
|
|
||||||
callback()
|
callback()
|
||||||
except:
|
except:
|
||||||
print_exc()
|
print_exc()
|
||||||
@ -181,7 +180,7 @@ def question(dialog: QDialog):
|
|||||||
btndownload.clicked.connect(functools.partial(dodownload, combo, allsupports))
|
btndownload.clicked.connect(functools.partial(dodownload, combo, allsupports))
|
||||||
btninstall = LPushButton("添加")
|
btninstall = LPushButton("添加")
|
||||||
btninstall.clicked.connect(
|
btninstall.clicked.connect(
|
||||||
functools.partial(doinstall, combo, allsupports, dialog, callback)
|
functools.partial(doinstall, dialog, combo, allsupports, dialog, callback)
|
||||||
)
|
)
|
||||||
formLayout.addRow(
|
formLayout.addRow(
|
||||||
"添加语言包",
|
"添加语言包",
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
from scalemethod.base import scalebase
|
from scalemethod.base import scalebase
|
||||||
import os, json
|
import json
|
||||||
import windows, gobject
|
import windows, gobject
|
||||||
from myutils.config import globalconfig, magpie_config
|
from myutils.config import globalconfig, magpie_config
|
||||||
from myutils.subproc import subproc_w
|
from myutils.subproc import subproc_w
|
||||||
from myutils.wrapper import threader
|
from ctypes import c_int, CFUNCTYPE, c_void_p
|
||||||
from winsharedutils import startmaglistener, endmaglistener
|
import winsharedutils
|
||||||
|
|
||||||
|
|
||||||
class Method(scalebase):
|
class Method(scalebase):
|
||||||
def saveconfig(self):
|
def saveconfig(self):
|
||||||
@ -14,17 +13,14 @@ class Method(scalebase):
|
|||||||
json.dumps(magpie_config, ensure_ascii=False, sort_keys=False, indent=4)
|
json.dumps(magpie_config, ensure_ascii=False, sort_keys=False, indent=4)
|
||||||
)
|
)
|
||||||
|
|
||||||
@threader
|
|
||||||
def statuslistener(self):
|
def messagecallback(self ,msg, status):
|
||||||
listener = windows.AutoHandle(startmaglistener())
|
if msg==1:
|
||||||
while not self.hasend:
|
self.setuistatus(int(bool(status)))
|
||||||
status = windows.c_int.from_buffer_copy(windows.ReadFile(listener, 4)).value
|
|
||||||
self.setuistatus(status)
|
|
||||||
|
|
||||||
endmaglistener(listener)
|
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
self.statuslistener()
|
self.messagecallback__ = CFUNCTYPE(None, c_int, c_void_p)(self.messagecallback)
|
||||||
|
winsharedutils.globalmessagelistener(self.messagecallback__)
|
||||||
self.jspath = gobject.gettempdir("magpie.config.json")
|
self.jspath = gobject.gettempdir("magpie.config.json")
|
||||||
self.engine = subproc_w(
|
self.engine = subproc_w(
|
||||||
'./files/plugins/Magpie/Magpie.Core.exe "{}"'.format(self.jspath),
|
'./files/plugins/Magpie/Magpie.Core.exe "{}"'.format(self.jspath),
|
||||||
|
@ -116,6 +116,8 @@ class TS(basetrans):
|
|||||||
elif json_data["type"] == "content_block_start":
|
elif json_data["type"] == "content_block_start":
|
||||||
msg = json_data["content_block"]["text"]
|
msg = json_data["content_block"]["text"]
|
||||||
message += msg
|
message += msg
|
||||||
|
else:
|
||||||
|
continue
|
||||||
except:
|
except:
|
||||||
print_exc()
|
print_exc()
|
||||||
raise Exception(response_data)
|
raise Exception(response_data)
|
||||||
|
@ -205,7 +205,8 @@ _GetWindowLong.argtypes = c_int, c_int
|
|||||||
|
|
||||||
_SetWindowLongW = _user32.SetWindowLongW
|
_SetWindowLongW = _user32.SetWindowLongW
|
||||||
_SetWindowLongW.argtypes = c_int, c_int, c_int
|
_SetWindowLongW.argtypes = c_int, c_int, c_int
|
||||||
|
BringWindowToTop = _user32.BringWindowToTop
|
||||||
|
BringWindowToTop.argtypes = (HWND,)
|
||||||
_GetDC = _user32.GetDC
|
_GetDC = _user32.GetDC
|
||||||
_GetDC.restype = c_void_p
|
_GetDC.restype = c_void_p
|
||||||
_ReleaseDC = _user32.ReleaseDC
|
_ReleaseDC = _user32.ReleaseDC
|
||||||
@ -423,7 +424,6 @@ def GetClientRect(hwnd):
|
|||||||
return (_rect.left, _rect.top, _rect.right, _rect.bottom)
|
return (_rect.left, _rect.top, _rect.right, _rect.bottom)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def ShowWindow(hwnd, nCmdShow):
|
def ShowWindow(hwnd, nCmdShow):
|
||||||
return _ShowWindow(hwnd, nCmdShow)
|
return _ShowWindow(hwnd, nCmdShow)
|
||||||
|
|
||||||
|
@ -239,8 +239,10 @@ def queryversion(exe):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
startdarklistener = utilsdll.startdarklistener
|
globalmessagelistener = utilsdll.globalmessagelistener
|
||||||
startdarklistener.restype = HANDLE
|
globalmessagelistener.argtypes = (c_void_p,)
|
||||||
|
dispatchcloseevent = utilsdll.dispatchcloseevent
|
||||||
|
|
||||||
|
|
||||||
_SetTheme = utilsdll._SetTheme
|
_SetTheme = utilsdll._SetTheme
|
||||||
_SetTheme.argtypes = HWND, c_bool, c_int
|
_SetTheme.argtypes = HWND, c_bool, c_int
|
||||||
@ -302,11 +304,6 @@ Is64bit.restype = c_bool
|
|||||||
isDark = utilsdll.isDark
|
isDark = utilsdll.isDark
|
||||||
isDark.restype = c_bool
|
isDark.restype = c_bool
|
||||||
|
|
||||||
startmaglistener = utilsdll.startmaglistener
|
|
||||||
startmaglistener.restype = HANDLE
|
|
||||||
endmaglistener = utilsdll.endmaglistener
|
|
||||||
endmaglistener.argtypes = (HANDLE,)
|
|
||||||
|
|
||||||
PlayAudioInMem = utilsdll.PlayAudioInMem
|
PlayAudioInMem = utilsdll.PlayAudioInMem
|
||||||
PlayAudioInMem.argtypes = (
|
PlayAudioInMem.argtypes = (
|
||||||
c_void_p,
|
c_void_p,
|
||||||
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "سلسلة استبدال",
|
"字符串替换": "سلسلة استبدال",
|
||||||
"转义": "هروب",
|
"转义": "هروب",
|
||||||
"不推荐使用": "لا ينصح باستخدام",
|
"不推荐使用": "لا ينصح باستخدام",
|
||||||
"游戏已存在,是否重复添加?": "اللعبة موجودة بالفعل ، هل تريد تكرار ذلك ؟"
|
"游戏已存在,是否重复添加?": "اللعبة موجودة بالفعل ، هل تريد تكرار ذلك ؟",
|
||||||
|
"点击消息后重新启动以生效": "اضغط على الرسالة إلى إعادة تشغيل نافذة المفعول",
|
||||||
|
"点击消息后退出并开始更新": "انقر على رسالة الخروج والبدء في تحديث"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "字串取代",
|
"字符串替换": "字串取代",
|
||||||
"转义": "跳脫",
|
"转义": "跳脫",
|
||||||
"不推荐使用": "不推薦使用",
|
"不推荐使用": "不推薦使用",
|
||||||
"游戏已存在,是否重复添加?": "遊戲已存在,是否重複新增?"
|
"游戏已存在,是否重复添加?": "遊戲已存在,是否重複新增?",
|
||||||
|
"点击消息后重新启动以生效": "點擊消息後重新啟動以生效",
|
||||||
|
"点击消息后退出并开始更新": "點擊消息後退出並開始更新"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "Náhrada řetězce",
|
"字符串替换": "Náhrada řetězce",
|
||||||
"转义": "Útěk",
|
"转义": "Útěk",
|
||||||
"不推荐使用": "Nedoporučuje se k použití",
|
"不推荐使用": "Nedoporučuje se k použití",
|
||||||
"游戏已存在,是否重复添加?": "Hra již existuje, chtěli byste ji znovu přidat?"
|
"游戏已存在,是否重复添加?": "Hra již existuje, chtěli byste ji znovu přidat?",
|
||||||
|
"点击消息后重新启动以生效": "Klikněte na zprávu a restartujte ji.",
|
||||||
|
"点击消息后退出并开始更新": "Klikněte na zprávu pro ukončení a spuštění aktualizace"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "Zeichenfolgenersatz",
|
"字符串替换": "Zeichenfolgenersatz",
|
||||||
"转义": "Flucht",
|
"转义": "Flucht",
|
||||||
"不推荐使用": "Nicht empfohlen für die Anwendung",
|
"不推荐使用": "Nicht empfohlen für die Anwendung",
|
||||||
"游戏已存在,是否重复添加?": "Das Spiel existiert bereits, möchtest du es noch einmal hinzufügen?"
|
"游戏已存在,是否重复添加?": "Das Spiel existiert bereits, möchtest du es noch einmal hinzufügen?",
|
||||||
|
"点击消息后重新启动以生效": "Klicken Sie auf die Nachricht und starten Sie neu, um wirksam zu werden",
|
||||||
|
"点击消息后退出并开始更新": "Klicken Sie auf die Nachricht, um zu beenden und mit der Aktualisierung zu beginnen"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "String replacement",
|
"字符串替换": "String replacement",
|
||||||
"转义": "Escaping",
|
"转义": "Escaping",
|
||||||
"不推荐使用": "Not recommended for use",
|
"不推荐使用": "Not recommended for use",
|
||||||
"游戏已存在,是否重复添加?": "The game already exists, would you like to add it again?"
|
"游戏已存在,是否重复添加?": "The game already exists, would you like to add it again?",
|
||||||
|
"点击消息后重新启动以生效": "Click on the message and restart to take effect",
|
||||||
|
"点击消息后退出并开始更新": "Click on the message to exit and start updating"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "Reemplazo de cadenas",
|
"字符串替换": "Reemplazo de cadenas",
|
||||||
"转义": "Transliteración",
|
"转义": "Transliteración",
|
||||||
"不推荐使用": "No se recomienda usar",
|
"不推荐使用": "No se recomienda usar",
|
||||||
"游戏已存在,是否重复添加?": "¿El juego ya existe, ¿ se repite la adición?"
|
"游戏已存在,是否重复添加?": "¿El juego ya existe, ¿ se repite la adición?",
|
||||||
|
"点击消息后重新启动以生效": "Reiniciar para entrar en vigor después de hacer clic en el mensaje",
|
||||||
|
"点击消息后退出并开始更新": "Haga clic en el mensaje para salir y comenzar la actualización"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "Remplacement de chaîne",
|
"字符串替换": "Remplacement de chaîne",
|
||||||
"转义": "échappement",
|
"转义": "échappement",
|
||||||
"不推荐使用": "Utilisation non recommandée",
|
"不推荐使用": "Utilisation non recommandée",
|
||||||
"游戏已存在,是否重复添加?": "Le jeu existe déjà, y a - t - il des ajouts répétés?"
|
"游戏已存在,是否重复添加?": "Le jeu existe déjà, y a - t - il des ajouts répétés?",
|
||||||
|
"点击消息后重新启动以生效": "Redémarrer après avoir cliqué sur le message pour prendre effet",
|
||||||
|
"点击消息后退出并开始更新": "Quitter et commencer la mise à jour après avoir cliqué sur le message"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "Sostituzione stringa",
|
"字符串替换": "Sostituzione stringa",
|
||||||
"转义": "Scappare",
|
"转义": "Scappare",
|
||||||
"不推荐使用": "Non raccomandato per l'uso",
|
"不推荐使用": "Non raccomandato per l'uso",
|
||||||
"游戏已存在,是否重复添加?": "Il gioco esiste già, vuoi aggiungerlo di nuovo?"
|
"游戏已存在,是否重复添加?": "Il gioco esiste già, vuoi aggiungerlo di nuovo?",
|
||||||
|
"点击消息后重新启动以生效": "Fare clic sul messaggio e riavviare per avere effetto",
|
||||||
|
"点击消息后退出并开始更新": "Clicca sul messaggio per uscire e iniziare l'aggiornamento"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "文字列置換",
|
"字符串替换": "文字列置換",
|
||||||
"转义": "エスケープ",
|
"转义": "エスケープ",
|
||||||
"不推荐使用": "使用を推奨しない",
|
"不推荐使用": "使用を推奨しない",
|
||||||
"游戏已存在,是否重复添加?": "ゲームは既に存在します。追加を繰り返しますか?"
|
"游戏已存在,是否重复添加?": "ゲームは既に存在します。追加を繰り返しますか?",
|
||||||
|
"点击消息后重新启动以生效": "メッセージをクリックして再起動して有効にする",
|
||||||
|
"点击消息后退出并开始更新": "メッセージをクリックして終了し、更新を開始"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "문자열 대체",
|
"字符串替换": "문자열 대체",
|
||||||
"转义": "전의",
|
"转义": "전의",
|
||||||
"不推荐使用": "권장하지 않음",
|
"不推荐使用": "권장하지 않음",
|
||||||
"游戏已存在,是否重复添加?": "게임이 이미 존재합니다. 다시 추가하시겠습니까?"
|
"游戏已存在,是否重复添加?": "게임이 이미 존재합니다. 다시 추가하시겠습니까?",
|
||||||
|
"点击消息后重新启动以生效": "메시지를 클릭한 후 다시 시작하여 적용",
|
||||||
|
"点击消息后退出并开始更新": "메시지 클릭 후 종료 및 업데이트 시작"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "Vervanging van tekenreeks",
|
"字符串替换": "Vervanging van tekenreeks",
|
||||||
"转义": "Ontsnappen",
|
"转义": "Ontsnappen",
|
||||||
"不推荐使用": "Niet aanbevolen voor gebruik",
|
"不推荐使用": "Niet aanbevolen voor gebruik",
|
||||||
"游戏已存在,是否重复添加?": "Het spel bestaat al, wil je het opnieuw toevoegen?"
|
"游戏已存在,是否重复添加?": "Het spel bestaat al, wil je het opnieuw toevoegen?",
|
||||||
|
"点击消息后重新启动以生效": "Klik op het bericht en start opnieuw op om van kracht te worden",
|
||||||
|
"点击消息后退出并开始更新": "Klik op het bericht om te sluiten en te beginnen met updaten"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "Zastąpienie ciągu",
|
"字符串替换": "Zastąpienie ciągu",
|
||||||
"转义": "Ucieczka",
|
"转义": "Ucieczka",
|
||||||
"不推荐使用": "Nie zaleca się stosowania",
|
"不推荐使用": "Nie zaleca się stosowania",
|
||||||
"游戏已存在,是否重复添加?": "Gra już istnieje, chcesz dodać ją ponownie?"
|
"游戏已存在,是否重复添加?": "Gra już istnieje, chcesz dodać ją ponownie?",
|
||||||
|
"点击消息后重新启动以生效": "Kliknij na wiadomość i uruchom ponownie, aby wejść w życie",
|
||||||
|
"点击消息后退出并开始更新": "Kliknij na wiadomość, aby wyjść i rozpocząć aktualizację"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "Substituição de strings",
|
"字符串替换": "Substituição de strings",
|
||||||
"转义": "Escapar",
|
"转义": "Escapar",
|
||||||
"不推荐使用": "Não recomendado para utilização",
|
"不推荐使用": "Não recomendado para utilização",
|
||||||
"游戏已存在,是否重复添加?": "O jogo já existe, você gostaria de adicioná-lo novamente?"
|
"游戏已存在,是否重复添加?": "O jogo já existe, você gostaria de adicioná-lo novamente?",
|
||||||
|
"点击消息后重新启动以生效": "Clique na mensagem e reinicie para entrar em vigor",
|
||||||
|
"点击消息后退出并开始更新": "Clique na mensagem para sair e iniciar a atualização"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "Замена строки",
|
"字符串替换": "Замена строки",
|
||||||
"转义": "Транслитерация",
|
"转义": "Транслитерация",
|
||||||
"不推荐使用": "Не рекомендуется использовать",
|
"不推荐使用": "Не рекомендуется использовать",
|
||||||
"游戏已存在,是否重复添加?": "Игра уже существует, добавляется ли повторно?"
|
"游戏已存在,是否重复添加?": "Игра уже существует, добавляется ли повторно?",
|
||||||
|
"点击消息后重新启动以生效": "После нажатия на сообщение перезапустить для вступления в силу",
|
||||||
|
"点击消息后退出并开始更新": "Выйти после нажатия на сообщение и начать обновление"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "Strängersättning",
|
"字符串替换": "Strängersättning",
|
||||||
"转义": "Flykt",
|
"转义": "Flykt",
|
||||||
"不推荐使用": "Rekommenderas inte för användning",
|
"不推荐使用": "Rekommenderas inte för användning",
|
||||||
"游戏已存在,是否重复添加?": "Spelet finns redan, vill du lägga till det igen?"
|
"游戏已存在,是否重复添加?": "Spelet finns redan, vill du lägga till det igen?",
|
||||||
|
"点击消息后重新启动以生效": "Klicka på meddelandet och starta om för att träda i kraft",
|
||||||
|
"点击消息后退出并开始更新": "Klicka på meddelandet för att avsluta och börja uppdatera"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "การแทนที่สตริง",
|
"字符串替换": "การแทนที่สตริง",
|
||||||
"转义": "แปลความหมาย",
|
"转义": "แปลความหมาย",
|
||||||
"不推荐使用": "ไม่แนะนำให้ใช้",
|
"不推荐使用": "ไม่แนะนำให้ใช้",
|
||||||
"游戏已存在,是否重复添加?": "มีเกมอยู่แล้วคุณต้องการเพิ่มซ้ำหรือไม่?"
|
"游戏已存在,是否重复添加?": "มีเกมอยู่แล้วคุณต้องการเพิ่มซ้ำหรือไม่?",
|
||||||
|
"点击消息后重新启动以生效": "เริ่มใหม่หลังจากแตะข้อความเพื่อให้มีผล",
|
||||||
|
"点击消息后退出并开始更新": "ออกจากข้อความและเริ่มต้นการปรับปรุง"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "String Replacement",
|
"字符串替换": "String Replacement",
|
||||||
"转义": "Kaçmak",
|
"转义": "Kaçmak",
|
||||||
"不推荐使用": "Kullanmak için önerilmez",
|
"不推荐使用": "Kullanmak için önerilmez",
|
||||||
"游戏已存在,是否重复添加?": "Oyun zaten var, tekrar eklemek ister misiniz?"
|
"游戏已存在,是否重复添加?": "Oyun zaten var, tekrar eklemek ister misiniz?",
|
||||||
|
"点击消息后重新启动以生效": "Mesaj üzerine tıklayın ve etkisi yaratmak için yeniden başlatın",
|
||||||
|
"点击消息后退出并开始更新": "Çıkmak ve güncellenmeye başlamak için mesajı tıklayın"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "Заміна рядків",
|
"字符串替换": "Заміна рядків",
|
||||||
"转义": "Бег",
|
"转义": "Бег",
|
||||||
"不推荐使用": "Не рекомендується використовувати",
|
"不推荐使用": "Не рекомендується використовувати",
|
||||||
"游戏已存在,是否重复添加?": "Гра вже існує, бажаєте додати її знову?"
|
"游戏已存在,是否重复添加?": "Гра вже існує, бажаєте додати її знову?",
|
||||||
|
"点击消息后重新启动以生效": "Натисніть лівою кнопкою миші на повідомлення і перезапускайте, щоб діяти",
|
||||||
|
"点击消息后退出并开始更新": "Натисніть повідомлення для виходу і запуску оновлення"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "Thay thế chuỗi",
|
"字符串替换": "Thay thế chuỗi",
|
||||||
"转义": "Thoát",
|
"转义": "Thoát",
|
||||||
"不推荐使用": "Không khuyến khích sử dụng",
|
"不推荐使用": "Không khuyến khích sử dụng",
|
||||||
"游戏已存在,是否重复添加?": "Trò chơi đã tồn tại, có được thêm nhiều lần không?"
|
"游戏已存在,是否重复添加?": "Trò chơi đã tồn tại, có được thêm nhiều lần không?",
|
||||||
|
"点击消息后重新启动以生效": "Khởi động lại sau khi nhấp vào tin nhắn để có hiệu lực",
|
||||||
|
"点击消息后退出并开始更新": "Thoát sau khi nhấp vào tin nhắn và bắt đầu cập nhật"
|
||||||
}
|
}
|
@ -853,5 +853,7 @@
|
|||||||
"字符串替换": "",
|
"字符串替换": "",
|
||||||
"转义": "",
|
"转义": "",
|
||||||
"不推荐使用": "",
|
"不推荐使用": "",
|
||||||
"游戏已存在,是否重复添加?": ""
|
"游戏已存在,是否重复添加?": "",
|
||||||
|
"点击消息后重新启动以生效": "",
|
||||||
|
"点击消息后退出并开始更新": ""
|
||||||
}
|
}
|
@ -29,7 +29,7 @@ include(generate_product_version)
|
|||||||
|
|
||||||
set(VERSION_MAJOR 5)
|
set(VERSION_MAJOR 5)
|
||||||
set(VERSION_MINOR 23)
|
set(VERSION_MINOR 23)
|
||||||
set(VERSION_PATCH 3)
|
set(VERSION_PATCH 4)
|
||||||
|
|
||||||
add_library(pch pch.cpp)
|
add_library(pch pch.cpp)
|
||||||
target_precompile_headers(pch PUBLIC pch.h)
|
target_precompile_headers(pch PUBLIC pch.h)
|
||||||
|
@ -11,7 +11,7 @@ generate_product_version(
|
|||||||
VERSION_PATCH ${VERSION_PATCH}
|
VERSION_PATCH ${VERSION_PATCH}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(winsharedutils MODULE webview2_extra.cpp AreoAcrylic.cpp screenshot.cpp audio.cpp ../implsapi.cpp hwnd.cpp darklistener.cpp theme.cpp version.cpp otsu.cpp clipboard.cpp lnk.cpp dllmain.cpp levenshtein.cpp muteprocess.cpp sapi_dll.cpp simplemecab.cpp SimpleBrowser.cpp MWebBrowser.cpp icon.cpp maglistener.cpp ${versioninfo})
|
add_library(winsharedutils MODULE webview2_extra.cpp AreoAcrylic.cpp screenshot.cpp audio.cpp ../implsapi.cpp hwnd.cpp globalmessagelistener.cpp theme.cpp version.cpp otsu.cpp clipboard.cpp lnk.cpp dllmain.cpp levenshtein.cpp muteprocess.cpp sapi_dll.cpp simplemecab.cpp SimpleBrowser.cpp MWebBrowser.cpp icon.cpp ${versioninfo})
|
||||||
target_precompile_headers(winsharedutils REUSE_FROM pch)
|
target_precompile_headers(winsharedutils REUSE_FROM pch)
|
||||||
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
||||||
set_target_properties(winsharedutils PROPERTIES OUTPUT_NAME "winsharedutils64")
|
set_target_properties(winsharedutils PROPERTIES OUTPUT_NAME "winsharedutils64")
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
|
|
||||||
#include "define.h"
|
|
||||||
HANDLE hsema;
|
|
||||||
void IsColorSchemeChangeMessage(LPARAM lParam)
|
|
||||||
{
|
|
||||||
if (lParam && CompareStringOrdinal(reinterpret_cast<LPCWCH>(lParam), -1, L"ImmersiveColorSet", -1, TRUE) == CSTR_EQUAL)
|
|
||||||
{
|
|
||||||
ReleaseSemaphore(hsema, 1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void startdarklistener_1()
|
|
||||||
{
|
|
||||||
const wchar_t CLASS_NAME[] = L"LunaDarkListener";
|
|
||||||
|
|
||||||
WNDCLASS wc = {};
|
|
||||||
wc.lpfnWndProc = [](HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
if (WM_SETTINGCHANGE == message)
|
|
||||||
IsColorSchemeChangeMessage(lParam);
|
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
||||||
};
|
|
||||||
wc.hInstance = GetModuleHandle(0);
|
|
||||||
wc.lpszClassName = CLASS_NAME;
|
|
||||||
|
|
||||||
static auto _ = RegisterClass(&wc);
|
|
||||||
HWND hWnd = CreateWindowEx(
|
|
||||||
WS_EX_CLIENTEDGE, CLASS_NAME, CLASS_NAME, WS_OVERLAPPEDWINDOW,
|
|
||||||
0, 0, 0, 0,
|
|
||||||
NULL, NULL, GetModuleHandle(0), 0);
|
|
||||||
MSG msg = {};
|
|
||||||
while (GetMessage(&msg, NULL, 0, 0))
|
|
||||||
{
|
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessage(&msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HANDLE startdarklistener()
|
|
||||||
{
|
|
||||||
hsema = CreateSemaphoreW(0, 0, 10, 0);
|
|
||||||
std::thread(startdarklistener_1).detach();
|
|
||||||
return hsema;
|
|
||||||
}
|
|
@ -3,7 +3,6 @@
|
|||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
|
||||||
__declspec(dllexport) HANDLE startdarklistener();
|
|
||||||
__declspec(dllexport) bool queryversion(const wchar_t *exe, WORD *_1, WORD *_2, WORD *_3, WORD *_4);
|
__declspec(dllexport) bool queryversion(const wchar_t *exe, WORD *_1, WORD *_2, WORD *_3, WORD *_4);
|
||||||
|
|
||||||
__declspec(dllexport) void SAPI_List(int version, void (*cb)(const wchar_t *));
|
__declspec(dllexport) void SAPI_List(int version, void (*cb)(const wchar_t *));
|
||||||
|
63
plugins/winsharedutils/globalmessagelistener.cpp
Normal file
63
plugins/winsharedutils/globalmessagelistener.cpp
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
|
||||||
|
#include "define.h"
|
||||||
|
static auto LUNA_UPDATE_PREPARED_OK = RegisterWindowMessage(L"LUNA_UPDATE_PREPARED_OK");
|
||||||
|
static auto WM_MAGPIE_SCALINGCHANGED = RegisterWindowMessage(L"MagpieScalingChanged");
|
||||||
|
bool IsColorSchemeChangeMessage(LPARAM lParam)
|
||||||
|
{
|
||||||
|
return lParam && CompareStringOrdinal(reinterpret_cast<LPCWCH>(lParam), -1, L"ImmersiveColorSet", -1, TRUE) == CSTR_EQUAL;
|
||||||
|
}
|
||||||
|
void globalmessagelistener_1(void *callback)
|
||||||
|
{
|
||||||
|
|
||||||
|
const wchar_t CLASS_NAME[] = L"globalmessagelistener";
|
||||||
|
|
||||||
|
WNDCLASS wc = {};
|
||||||
|
wc.lpfnWndProc = [](HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
void (*callback)(int, void *);
|
||||||
|
callback = (decltype(callback))GetWindowLongPtrW(hWnd, GWLP_USERDATA);
|
||||||
|
if (callback)
|
||||||
|
{
|
||||||
|
if (WM_SETTINGCHANGE == message)
|
||||||
|
{
|
||||||
|
if (IsColorSchemeChangeMessage(lParam))
|
||||||
|
callback(0, 0);
|
||||||
|
}
|
||||||
|
else if (message == WM_MAGPIE_SCALINGCHANGED)
|
||||||
|
{
|
||||||
|
callback(1, (void *)wParam);
|
||||||
|
}
|
||||||
|
else if (message == LUNA_UPDATE_PREPARED_OK)
|
||||||
|
{
|
||||||
|
callback(2, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
|
};
|
||||||
|
wc.hInstance = GetModuleHandle(0);
|
||||||
|
wc.lpszClassName = CLASS_NAME;
|
||||||
|
|
||||||
|
static auto _ = RegisterClass(&wc);
|
||||||
|
HWND hWnd = CreateWindowEx(
|
||||||
|
WS_EX_CLIENTEDGE, CLASS_NAME, CLASS_NAME, WS_OVERLAPPEDWINDOW,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
NULL, NULL, GetModuleHandle(0), 0);
|
||||||
|
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)callback);
|
||||||
|
ChangeWindowMessageFilterEx(hWnd, LUNA_UPDATE_PREPARED_OK, MSGFLT_ALLOW, nullptr);
|
||||||
|
ChangeWindowMessageFilterEx(hWnd, WM_MAGPIE_SCALINGCHANGED, MSGFLT_ALLOW, nullptr);
|
||||||
|
MSG msg = {};
|
||||||
|
while (GetMessage(&msg, NULL, 0, 0))
|
||||||
|
{
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DECLARE void globalmessagelistener(void *callback)
|
||||||
|
{
|
||||||
|
std::thread(std::bind(globalmessagelistener_1, callback)).detach();
|
||||||
|
}
|
||||||
|
|
||||||
|
DECLARE void dispatchcloseevent()
|
||||||
|
{
|
||||||
|
PostMessage(HWND_BROADCAST, LUNA_UPDATE_PREPARED_OK, 0, 0);
|
||||||
|
}
|
@ -1,61 +0,0 @@
|
|||||||
#include "define.h"
|
|
||||||
|
|
||||||
static UINT WM_MAGPIE_SCALINGCHANGED = RegisterWindowMessage(L"MagpieScalingChanged");
|
|
||||||
static HWND listener = 0;
|
|
||||||
static HANDLE hwrite = 0;
|
|
||||||
|
|
||||||
DECLARE HANDLE startmaglistener()
|
|
||||||
{
|
|
||||||
ChangeWindowMessageFilter(WM_MAGPIE_SCALINGCHANGED, MSGFLT_ADD);
|
|
||||||
auto CLASS_NAME = L"MagpieWatcher";
|
|
||||||
WNDCLASS wc = {};
|
|
||||||
wc.lpfnWndProc = [](HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
if (message == WM_MAGPIE_SCALINGCHANGED && hwrite)
|
|
||||||
{
|
|
||||||
int send = wParam;
|
|
||||||
DWORD _;
|
|
||||||
WriteFile(hwrite, &send, 4, &_, 0);
|
|
||||||
}
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
|
|
||||||
case WM_DESTROY:
|
|
||||||
{
|
|
||||||
CloseHandle(hwrite);
|
|
||||||
PostQuitMessage(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
||||||
};
|
|
||||||
wc.hInstance = GetModuleHandle(0);
|
|
||||||
wc.lpszClassName = CLASS_NAME;
|
|
||||||
static auto _ = RegisterClass(&wc);
|
|
||||||
HANDLE hread;
|
|
||||||
CreatePipe(&hread, &hwrite, 0, 0);
|
|
||||||
|
|
||||||
std::thread([=]()
|
|
||||||
{
|
|
||||||
listener = CreateWindowEx(
|
|
||||||
WS_EX_CLIENTEDGE, CLASS_NAME, CLASS_NAME, WS_OVERLAPPEDWINDOW,
|
|
||||||
0, 0, 0, 0,
|
|
||||||
NULL, NULL, GetModuleHandle(0), hwrite);;
|
|
||||||
MSG msg = {};
|
|
||||||
while (GetMessage(&msg, NULL, 0, 0))
|
|
||||||
{
|
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessage(&msg);
|
|
||||||
} })
|
|
||||||
.detach();
|
|
||||||
|
|
||||||
return hread;
|
|
||||||
}
|
|
||||||
DECLARE void endmaglistener(HANDLE hread)
|
|
||||||
{
|
|
||||||
if (listener)
|
|
||||||
{
|
|
||||||
DestroyWindow(listener);
|
|
||||||
listener = 0;
|
|
||||||
hwrite = 0;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user