脚本:紫光拼音迷你智能版

优质
小牛编辑
130浏览
2023-12-01
为了减小体积,没有将资源文件一起提供,只提供了一个文件列表filelist.txt。你可以自己从已安装的输入法目录中获取并复制到提示的相应目录位置,然后进行编译即可。

引用 Hsunispim.nsi 的内容:

#############################
#    Engine @ Hesungstduio  #
#     紫光拼音迷你智能版    #
#############################

;;你可以借鉴它打包自己的输入法或是自己喜爱的输入法和朋友们内部分享。
;;时间仓促,注释不好,请见凉...


## 调用编译器现编译Hsunistools.nsh用来更新Hsunis.dll
!execute '"${NSISDIR}\makensis.exe" "Hsunistools.nsh"'

## 设置NSIS压缩器 ##
SetCompressor /SOLID lzma	;;请使用NSIS2.08以上版本

## 包含头文件 ##
!include 	"MUI.nsh"
!include	"PublicFuncS.nsh"
## 预定义 ##
!define		ICON_NAME	Hsunis_main
!define 	MUI_ICON 	"Icons\${ICON_NAME}.ico"

!define	 /date	DATEFULL	"%Y.%m.%d.%H"
!define	 /date	DATE	"%Y.%m.%d"
!define			VER	"Build ${DATE}"

## 基本属性设置 ##
Name			"紫光拼音"
Caption			"紫光拼音"
SilentInstall 	silent
CRCCheck		off
XPStyle 		on

## 安装程序文件输出 ##
OutFile		"Hsunispim.exe"

## 插入语言宏和其他 ##
!insertmacro MUI_LANGUAGE "simpchinese"
VIProductVersion "${DATEFULL}"
VIAddVersionKey /LANG=2052  "FileVersion" "版本:${VER}$\r$\n创建:Engine黑闪工作室"
VIAddVersionKey /LANG=2052  "ProductName" "紫光拼音 3.0 迷你版"
VIAddVersionKey /LANG=2052  "Comments" "紫光拼音输入法迷你版  $\r$\n基于紫光拼音3.0创建, $\r$\n具有除因特网搜索之外  $\r$\n紫光拼音原版全部功能,清华紫光软件版权所有。黑闪工作室成员Engine 编写迷你版策略和脚本。"
VIAddVersionKey /LANG=2052  "CompanyName" "Hesung Studio"
VIAddVersionKey /LANG=2052  "LegalCopyright" "北京清华紫光软件股份有限公司"
VIAddVersionKey /LANG=2052  "FileDescription" "Hesung Tools"
VIAddVersionKey /LANG=2052  "ProductVersion" "清华紫光拼音输入法$\r$\n引擎版本3.0.0.3045"
VIAddVersionKey /LANG=2052  "OriginalFilename" "Hsunispim.exe"


## 函数 .OnInit //主功能初始化函数 ##
Function .OnInit

	;;窗体互斥处理
	FindWindow $1 '#32770' '紫光拼音管理工具' 0 $1
	IntCmp $1 0 FindNextWindow
	SYSTEM::Call "user32::SetForegroundWindow(i r1) i."
	ShowWindow $1 1
	Abort
	FindNextWindow:
	FindWindow $1 'TApplication' '紫光拼音输入法-属性设置和管理中心' 0 $1
	IntCmp $1 0 NormalShow
	SYSTEM::Call "user32::SetForegroundWindow(i r1) i."
	ShowWindow $1 1
	Abort
	NormalShow:

	Call GetParameters 	;;获取命令行参数给$R0
	Pop $R0

	StrCmp $R0 "" 	Normal
	StrCmp $R0 "/h" Help
	StrCmp $R0 "-h" Help

	;;检测是否存在紫光拼音5的核心特征文件。
	IfFileExists "$SYSDIR\unispim5.ime" 0 +2
	IfFileExists "$SYSDIR\IME\Unispim\upimcfg5.exe" Unispim5_installed

	StrCmp $R0 "/c" Config
	StrCmp $R0 "-c" Config
	StrCmp $R0 "/u" Uninst
	StrCmp $R0 "-u" Uninst
	StrCmp $R0 "/n" OnlyFiles
	StrCmp $R0 "-n" OnlyFiles
	StrCmp $R0 "/f" ShowGUI
	StrCmp $R0 "-f" ShowGUI
	StrCmp $R0 "/r" Restore
	StrCmp $R0 "-r" Restore Normal

	Uninst:
	IfFileExists "$SYSDIR\unispim.ime" 0 SpecialDir
	IfFileExists "$SYSDIR\upengine.dll" 0 SpecialDir
	IfFileExists "$SYSDIR\IME\Unispim\Hsunis.dll" +3
	SetOutPath "$SYSDIR\IME\Unispim"
	File "Tools\Hsunis.dll"
	Exec `"$SYSDIR\IME\Unispim\Hsunis.dll" -u`
	Quit
	SpecialDir:
	IfFileExists "$TEMP\Hsunis.tmp" +2
	File "/oname=$TEMP\Hsunis.tmp" "Tools\Hsunis.dll"
	Exec `"$TEMP\Hsunis.tmp" -u`
	Abort

	ShowGUI:
	IfFileExists "$SYSDIR\unispim.ime" 0 NotInstalled
	IfFileExists "$SYSDIR\upengine.dll" 0 NotInstalled
	IfFileExists "$SYSDIR\IME\Unispim\Hsunis.dll" +3
	SetOutPath "$SYSDIR\IME\Unispim"
	File "Tools\Hsunis.dll"
	Exec "$SYSDIR\IME\Unispim\Hsunis.dll"
	Quit

	NotInstalled:
	;;窗体互斥
	SYSTEM::Call "kernel32::CreateMutexA(i 0, i 0, t '$(^Name)') i .r0 ?e"
	Pop $0
	StrCmp $0 0 ShowAsk
	StrLen $0 "$(^Name)"
	IntOp $0 $0 + 1
	loop1:
	FindWindow $1 '#32770' '' 0 $1
	IntCmp $1 0 +4
	SYSTEM::Call "user32::GetWindowText(i r1, t .r2, i r0) i."
	StrCmp $2 "$(^Name)" 0 loop1
	SYSTEM::Call "user32::SetForegroundWindow(i r1) i."
	ShowWindow $1 1
	Abort
	ShowAsk:
	MessageBox MB_YESNO|MB_ICONQUESTION  "当前系统中没有安装紫光拼音输入法 3.0,是否现在进行安装?  " IDYES Restore
	Quit

	Help:
	;;窗体互斥
	SYSTEM::Call "kernel32::CreateMutexA(i 0, i 0, t '$(^Name)') i .r0 ?e"
	Pop $0
	StrCmp $0 0 ShowHelp
	StrLen $0 "$(^Name)"
	IntOp $0 $0 + 1
	loop:
	FindWindow $1 '#32770' '' 0 $1
	IntCmp $1 0 +4
	SYSTEM::Call "user32::GetWindowText(i r1, t .r2, i r0) i."
	StrCmp $2 "$(^Name)" 0 loop
	SYSTEM::Call "user32::SetForegroundWindow(i r1) i."
	ShowWindow $1 1
	Abort
	ShowHelp:
	MessageBox MB_OK "$\n\
	H (帮助):弹出紫光拼音迷你版的参数说明。$\r$\n\
	F (界面):显示紫光拼音智能操作管理界面。$\r$\n\
	N (特别):安装时不添加控制面板卸载信息。$\r$\n\
	C (配置):载入紫光拼音输入法的优化配置。$\r$\n\
	R (修复):对紫光拼音输入法进行覆盖安装。$\r$\n\
	U (卸载):卸载已经安装的紫光拼音输入法。"
	Quit

	Config:
	IfFileExists "$SYSDIR\unispim.ime" 0 Restore
	IfFileExists "$SYSDIR\upengine.dll" 0 Restore
	IfFileExists "$SYSDIR\IME\Unispim\upimcfg.exe" RegCfg Restore
	OnlyFiles:
	StrCpy $R9 "NoUninstRegKey"

	Normal:
	;;检测是否存在紫光5的特征文件
	IfFileExists "$SYSDIR\unispim5.ime" 0 +2
	IfFileExists "$SYSDIR\IME\Unispim\upimcfg5.exe" Unispim5_installed

	;;检测核心文件
	IfFileExists "$SYSDIR\unispim.ime" 0 Restore
	IfFileExists "$SYSDIR\upengine.dll" 0 Restore

	;;检测文件Dat类型
	IfFileExists "$SYSDIR\IME\Unispim\syswl.dat" 0 Restore
	IfFileExists "$SYSDIR\IME\Unispim\bcoc.dat" 0 Restore
	IfFileExists "$SYSDIR\IME\Unispim\hzfreq.dat" 0 Restore

	;;检测文件Exe类型
	IfFileExists "$SYSDIR\IME\Unispim\upcfgwiz.exe" 0 Restore
	IfFileExists "$SYSDIR\IME\Unispim\upimcfg.exe" 0 Restore
	IfFileExists "$SYSDIR\IME\Unispim\wlmerge.exe" 0 Restore
	IfFileExists "$SYSDIR\IME\Unispim\wlbackup.exe" 0 Restore

	;;检测重要manifest类型
	IfFileExists "$SYSDIR\IME\Unispim\upimcfg.exe.manifest" 0 Restore

	;;检测Chm & dll类型
	IfFileExists "$SYSDIR\IME\Unispim\unispim.chm" 0 Restore
	IfFileExists "$SYSDIR\IME\Unispim\upimset.dll" 0 Restore

	;;检测概要INI类型
	IfFileExists "$SYSDIR\IME\Unispim\spewords.ini" 0 Restore
	IfFileExists "$SYSDIR\IME\Unispim\chnsym.ini" 0 Restore
	IfFileExists "$SYSDIR\IME\Unispim\unispimsp.ini" 0 Restore

	;;检测当前用户是否存在配置
	ClearErrors
	ReadRegDWORD $R0 HKCU "Software\Thunisoft\Unispim\3.0" "输入栏字体大小"
	IfErrors 0 ExeC
	Services::IsProcessUserAdministrator
	Pop $0
	StrCmp $0 "NO" ExeC ImmInst

	Restore:
	Services::IsProcessUserAdministrator
	Pop $0
	StrCmp $0 "NO" 0 Pass

	Call GetWindowsVer
	Pop $R0
	StrCmp $R0 "XP" Notify
	StrCmp $R0 "2003" Notify
	StrCmp $R0 "Other" Notify

	MessageBox MB_OK|MB_ICONINFORMATION "当前用户组没有权限安装输入法,请以管理员身份登录。  "
	Quit

	Notify:
	NotifyIcon::Icon /NOUNLOAD "iy" 103
	NotifyIcon::Icon /NOUNLOAD "b" "紫光输入法安装提示" "当前用户组没有权限安装输入法,请以管理员身份登录。"
	Sleep 8000
	NotifyIcon::Icon "r"
	Sleep 1000
	Quit

	Pass:
	RMDir /r "$APPDATA\Unispim"

	DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C21C537D-6438-4574-825C-FBB1CB7BB54C}" 
	DeleteRegKey HKCU "Software\Microsoft\Installer\Products\D735C12C8346475428C5BF1BBCB75BC4"
	DeleteRegKey HKCU "S-1-5-21-2052111302-1958367476-839522115-1003\Software\Microsoft\Installer\Products\D735C12C8346475428C5BF1BBCB75BC4"

	StrCmp $R9 "NoUninstRegKey" DoneRegUninstall
	MoreInfo::GetOSUserinterfaceLanguage ;;MoreInfo插件这里获取操作系统shell语言
	Pop $LANGUAGE
	StrCmp $LANGUAGE "2052" SimpChineseString
	WriteRegStr  HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C21C537D-6438-4574-825C-FBB1CB7BB54C}" "DisplayName" "Thunisoft Unispim IME 3.0"
	WriteRegStr  HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C21C537D-6438-4574-825C-FBB1CB7BB54C}" "DisplayIcon" "$SYSDIR\IME\Unispim\upimcfg.exe"
	WriteRegStr  HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C21C537D-6438-4574-825C-FBB1CB7BB54C}" "Publisher" "Beijing Thunisoft Corporation"
	WriteRegStr  HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C21C537D-6438-4574-825C-FBB1CB7BB54C}" "UninstallString" `"$SYSDIR\IME\Unispim\Hsunis.dll" -Uninstall`
	WriteRegStr  HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C21C537D-6438-4574-825C-FBB1CB7BB54C}" "ModifyPath" `"$SYSDIR\IME\Unispim\Hsunis.dll" -Restore`
	WriteRegStr  HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C21C537D-6438-4574-825C-FBB1CB7BB54C}" "Specical Description" "This Smart Installer is Created by SupEngine at Hesung Studio."
	Goto DoneRegUninstall
	SimpChineseString:
	WriteRegStr  HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C21C537D-6438-4574-825C-FBB1CB7BB54C}" "DisplayName" "紫光拼音输入法 3.0"
	WriteRegStr  HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C21C537D-6438-4574-825C-FBB1CB7BB54C}" "DisplayIcon" "$SYSDIR\IME\Unispim\upimcfg.exe"
	WriteRegStr  HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C21C537D-6438-4574-825C-FBB1CB7BB54C}" "Publisher" "北京清华紫光软件股份有限公司"
	WriteRegStr  HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C21C537D-6438-4574-825C-FBB1CB7BB54C}" "UninstallString" `"$SYSDIR\IME\Unispim\Hsunis.dll" -Uninstall`
	WriteRegStr  HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C21C537D-6438-4574-825C-FBB1CB7BB54C}" "ModifyPath" `"$SYSDIR\IME\Unispim\Hsunis.dll" -Restore`
	WriteRegStr  HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C21C537D-6438-4574-825C-FBB1CB7BB54C}" "Specical Description" "黑闪工作室迷你智能安装策略版本"
	DoneRegUninstall:
	ClearErrors

	SetOutPath "$SYSDIR"
	File "Imekernel\unispim.ime"
	File "Imekernel\upengine.dll"
	SetOutPath "$SYSDIR\IME"
	File /r "Unispim"
	SetOutPath "$SYSDIR\IME\Unispim"
	File "Tools\Hsunis.dll"

	ImmInst:
	System::Call 'imm32::ImmInstallIME(t "$SYSDIR\unispim.ime" ,t "紫光拼音输入法 3.0")'

	RegCfg:
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "输入风格"			0x00000001
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "用字母键选择候选字词"	0x00000000
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "使用双拼输入"		0x00000000
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "双拼输入时显示提示信息"	0x00000001
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "光标跟随"			0x00000001
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "动态调整词频"		0x00000001
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "自动隐藏低频词"		0x00000000
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "动态调整字频"		0x00000001
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "最近输入字优先"		0x00000001
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "每页最多候选个数"		0x00000005
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "中英文输入切换键"		0x00000000
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "回车键定义"		0x00000001
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "多个候选翻页键"		0x00000001
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "输入第二第三候选字词键" 	0x00000001
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "以词定字选字键"		0x00000002
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "软键盘开关键"		0x00000011
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "输入栏字体大小"		0x0000000e
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "输入栏显示样式"		0x00000000
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "状态条显示"		0x00000001
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "状态条位置"		10000
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "支持GBK大字符集"		0x00000001
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "输入简体汉字"		0x00000001
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "智能组词"			0x00000001
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "智能组词自动记忆"		0x00000000
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "按前次输入动态调整字序"	0x00000000
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "数字后跟随英文符号"	0x00000000
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "打开时默认为英文输入状态"	0x00000000
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "v状态可输入空格"		0x00000000
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "声母模糊音设置"		0x00ffffff
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "属性设置保存提示"		0x00000000
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "一次输入汉字最多个数"	0x0000000c
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "中文符号"			0x00000400
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "软键盘索引"		0x00000008
	WriteRegDWORD HKCU "Software\Thunisoft\Unispim\3.0" "记忆并可输入最近输入过的字词"	 1
	WriteRegBin   HKCU "Software\Thunisoft\Unispim\3.0" "韵母模糊音设置"	  ffffffff0f000000
	WriteRegStr   HKCU "Software\Thunisoft\Unispim\3.0" "输入栏中文字体"		"宋体"
	WriteRegStr   HKCU "Software\Thunisoft\Unispim\3.0" "输入栏英文字体"		"Tahoma"

	DeleteRegKey  HKCR "紫光拼音输入法词库备份文件"
	WriteRegStr   HKCR ".uwl" "" "UnispimWlbackup.file"
	WriteRegStr   HKCR "UnispimWlbackup.file" "" "紫光拼音词库备份文件"
	WriteRegStr   HKCR "UnispimWlbackup.file\DefaultIcon" "" "$SYSDIR\IME\unispim\wlbackup.exe,0"
	WriteRegStr   HKCR "UnispimWlbackup.file\shell" "" "open"
	WriteRegStr   HKCR "UnispimWlbackup.file\shell\open\command" "" `"$SYSDIR\IME\unispim\wlbackup.exe$\" $\"%1$\"`
	WriteRegStr   HKCR "UnispimWlbackup.file\shell\open" "" "导入词库(&A)"

	;;运行紫光拼音3配置中心程序 并自动退出
	ExeC:
	Exec "$SYSDIR\IME\Unispim\upimcfg.exe"
	ClearErrors
	Quit
	
	## 给出已安装紫光拼音5的提示,并清理可能的残留项目
	Unispim5_installed:
	;;窗体互斥
	SYSTEM::Call "kernel32::CreateMutexA(i 0, i 0, t '$(^Name)') i .r0 ?e"
	Pop $0
	StrCmp $0 0 ShowVer5
	StrLen $0 "$(^Name)"
	IntOp $0 $0 + 1
	loop3:
	FindWindow $1 '#32770' '' 0 $1
	IntCmp $1 0 +4
	SYSTEM::Call "user32::GetWindowText(i r1, t .r2, i r0) i."
	StrCmp $2 "$(^Name)" 0 loop3
	SYSTEM::Call "user32::SetForegroundWindow(i r1) i."
	ShowWindow $1 1
	Abort
	ShowVer5:
	MessageBox MB_OK|MB_ICONINFORMATION  "当前系统中已存在紫光拼音 5.0,请将其卸载后再执行该程序。  "
	DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C21C537D-6438-4574-825C-FBB1CB7BB54C}" 
	DeleteRegKey HKCR "UnispimWlbackup.file"
	DeleteRegKey HKCU "Software\Classes\UnispimWlbackup.file"
	DeleteRegKey HKCU  "Software\Microsoft\Installer\Products\D735C12C8346475428C5BF1BBCB75BC4"
	DeleteRegKey HKCU "Software\Thunisoft\Unispim\3.0"
	DeleteRegKey HKCU "Software\Thunisoft\紫光拼音输入法3.0"
	SetOutPath "$SYSDIR"
	File "Tools\DeleteIME.Dll"
	ExecWait '"$SYSDIR\DeleteIME.Dll" /c unispim.ime'
	Delete /REBOOTOK "$SYSDIR\DeleteIME.Dll"
	ClearErrors
	Delete /REBOOTOK "$TEMP\Hsunis.tmp"
	Quit

FunctionEnd ;;.onInit


Section "NoFuntion" ;;形式
SectionEnd

点击另存附件