@echo off
cd /d "%~dp0"
setlocal enabledelayedexpansion

taskkill /f /im wps* /t 2>nul
taskkill /f /im wpp.exe /t 2>nul
taskkill /f /im et.exe /t 2>nul

call "%~dp0mdbx\获取皮肤列表v3pro.cmd"

echo ::估计版本号低于10000的使用一代皮肤
echo ::11000~11.1.0.15319二代皮肤
echo ::12.1.0.15374 AI 三代皮肤
cls	


cd /d "%~dp0"
set /a sn=0
set cn=
set hs=

echo.
echo      选择皮肤：
echo ----------------------------
for /f "tokens=*" %%a in ('dir /b /a-d mdbx\*.reg ^|findstr /i /v "中灰"') do (
	set /a sn+=1
	if !sn! lss 10 (
		set cn=!cn!!sn!
		echo      [!sn!]  %%~na
	)
	if !sn! == 10 (
		set cn=!cn!a
		echo      [a]  %%~na
	)
	if !sn! == 11 (
		set cn=!cn!b
		echo      [b]  %%~na
	)
	if !sn! == 12 (
		set cn=!cn!c
		echo      [c]  %%~na
	)
	if !sn! == 13 (
		set cn=!cn!d
		echo      [d]  %%~na
	)
	if !sn! == 14 (
		set cn=!cn!e
		echo      [e]  %%~na
	)
	if !sn! == 15 (
		set cn=!cn!f
		echo      [f]  %%~na
	)
	if !sn! == 16 (
		set cn=!cn!g
		echo      [g]  %%~na
	)
	if !sn! == 17 (
		set cn=!cn!h
		echo      [h]  %%~na
	)
	if !sn! == 18 (
		set cn=!cn!i
		echo      [i]  %%~na
	)
	if !sn! == 19 (
		set cn=!cn!j
		echo      [j]  %%~na
	)
	if !sn! == 20 (
		set cn=!cn!k
		echo      [k]  %%~na
	)
	if "!hs!" equ "" set hs=%%a
	if "!hs!" neq "" set hs=!hs!, %%a
)
echo ----------------------------
choice /C:%cn% /N /M "　　请选择: [退出直接关闭本窗口]"
set el=%errorlevel%


set ls=
set /a sn=0
for /f "tokens=*" %%a in ('dir /b /a-d mdbx\*.reg ^|findstr /i /v "中灰"') do (
	set /a sn+=1
	if "%el%" equ "!sn!" (
		set "ls=%%a"
		set ss=mdbx-%%~na.dat
		set skp=%%~na
	)
)
echo.
echo %skp%
echo.


title 更改皮肤颜色
reg import "%~dp0mdbx\%ls%"
reg delete "HKCU\Software\Kingsoft\Office\6.0\plugins\kskincenter" /f /v "skinlistmd5" 2>nul
reg add "HKCU\SOFTWARE\Kingsoft\Office\6.0\plugins\kskincenter\users\default\wpsoffice" /f /v "lastSkin" /t REG_SZ /d "2019dark"
::不自动切换皮肤
reg add "HKCU\SOFTWARE\Kingsoft\Office\6.0\Common" /f /v "autoSwitchSkin" /t REG_SZ /d "false"

del /s /q "%~dp0office6\skins\2019dark" >nul
del /s /q "%appdata%\Kingsoft\office6\cache" >nul

xcopy /s /y "%~dp0office6\skins\%skp%" "%~dp0office6\skins\2019dark\" >nul

set "tpn=%appdata%\Kingsoft\wps\addons\data\win-i386\kconfigcenter\kccsdkdb\kccsdkpriortydb\mdbx.dat"
if not exist "%appdata%\Kingsoft\wps\addons\data\win-i386\kconfigcenter\kccsdkdb\kccsdkpriortydb" md "%appdata%\Kingsoft\wps\addons\data\win-i386\kconfigcenter\kccsdkdb\kccsdkpriortydb"
if "%ss:默认=%" equ "%ss%" copy /y "%~dp0mdbx\mdbx-中灰.dat" "%tpn%"
if "%ss:默认=%" neq "%ss%" copy /y "%~dp0mdbx\%ss%" "%tpn%"

ping 127.1>nul