magpie config

Update fullscreen.py
This commit is contained in:
恍兮惚兮 2024-04-04 00:41:44 +08:00
parent 2cb3ae5f34
commit b7bf392e7b
5 changed files with 88 additions and 4 deletions

View File

@ -1,5 +1,5 @@
import os, json
import windows
import windows, winsharedutils
from myutils.config import globalconfig, magpie10_config
from myutils.hwnd import letfullscreen, recoverwindow, ListProcess, injectdll
from traceback import print_exc
@ -123,12 +123,30 @@ class fullscreen:
def _external_magpie10(self, hwnd, full):
configpath = os.path.join(globalconfig["magpie10path"], "config/config.json")
if os.path.exists(configpath) == False:
configpath = os.path.join(
os.environ["LOCALAPPDATA"], "Magpie/config/config.json"
version = winsharedutils.queryversion(
os.path.join(globalconfig["magpie10path"], "Magpie.exe")
)
checks = [
os.path.join(
os.environ["LOCALAPPDATA"], "Magpie/config/v2/config.json"
),
os.path.join(os.environ["LOCALAPPDATA"], "Magpie/config/config.json"),
]
if version:
if version[:3] >= (0, 10, 100): # v0.11.0-preview1
checks = [checks[0]]
else:
checks = [checks[1]]
for ck in checks:
if os.path.exists(ck):
configpath = ck
break
if os.path.exists(configpath) == False:
return
with open(configpath, "r", encoding="utf8") as ff:
config = json.load(ff)
autoRestore = config["autoRestore"]

View File

@ -18,6 +18,7 @@ from ctypes import (
windll,
c_char,
)
from ctypes.wintypes import WORD
import gobject
utilsdll = CDLL(gobject.GetDllpath(("winsharedutils32.dll", "winsharedutils64.dll")))
@ -286,3 +287,25 @@ class lockedqueue:
def empty(self):
return lockedqueueempty(self.ptr)
_queryversion = utilsdll.queryversion
_queryversion.restype = c_bool
_queryversion.argtypes = (
c_wchar_p,
POINTER(WORD),
POINTER(WORD),
POINTER(WORD),
POINTER(WORD),
)
def queryversion(exe):
_1 = WORD()
_2 = WORD()
_3 = WORD()
_4 = WORD()
succ = _queryversion(exe, pointer(_1), pointer(_2), pointer(_3), pointer(_4))
if succ:
return _1.value, _2.value, _3.value, _4.value
return None

View File

@ -2,7 +2,7 @@
project(winsharedutils)
add_library(winsharedutils MODULE otsu.cpp cinterface.cpp clipboard.cpp lnk.cpp dllmain.cpp levenshtein.cpp muteprocess.cpp sapi_dll.cpp simplemecab.cpp SimpleBrowser.cpp MWebBrowser.cpp icon.cpp)
add_library(winsharedutils MODULE version.cpp otsu.cpp cinterface.cpp clipboard.cpp lnk.cpp dllmain.cpp levenshtein.cpp muteprocess.cpp sapi_dll.cpp simplemecab.cpp SimpleBrowser.cpp MWebBrowser.cpp icon.cpp)
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set_target_properties(winsharedutils PROPERTIES OUTPUT_NAME "winsharedutils64")

View File

@ -2,6 +2,7 @@
#include <Windows.h>
extern "C"
{
__declspec(dllexport) bool queryversion(const wchar_t *exe, WORD *_1, WORD *_2, WORD *_3, WORD *_4);
__declspec(dllexport) bool SAPI_Speak(const wchar_t *Content, int version, int voiceid, int rate, int volume, const wchar_t *Filename);
__declspec(dllexport) wchar_t **SAPI_List(int version, size_t *);

View File

@ -0,0 +1,42 @@
#include <windows.h>
#include <vector>
#include "define.h"
#pragma comment(lib, "Version.lib")
bool queryversion(const wchar_t *exe, WORD *_1, WORD *_2, WORD *_3, WORD *_4)
{
DWORD dwHandle;
DWORD dwSize = GetFileVersionInfoSizeW(exe, &dwHandle);
if (dwSize == 0)
{
return false;
}
std::vector<char> versionInfoBuffer(dwSize);
if (!GetFileVersionInfoW(exe, dwHandle, dwSize, versionInfoBuffer.data()))
{
return false;
}
VS_FIXEDFILEINFO *pFileInfo;
UINT fileInfoSize;
if (!VerQueryValueW(versionInfoBuffer.data(), L"\\", reinterpret_cast<LPVOID *>(&pFileInfo), &fileInfoSize))
{
return false;
}
DWORD ms = pFileInfo->dwFileVersionMS;
DWORD ls = pFileInfo->dwFileVersionLS;
WORD majorVersion = HIWORD(ms);
WORD minorVersion = LOWORD(ms);
WORD buildNumber = HIWORD(ls);
WORD revisionNumber = LOWORD(ls);
*_1 = majorVersion;
*_2 = minorVersion;
*_3 = buildNumber;
*_4 = revisionNumber;
return true;
}