;桌面logo
Schema_logo:
	Gui, 3:Default
	Gui, 3: -Caption +AlwaysOnTop -DPIScale ToolWindow +Owner +hwndWubi_Gui
	Gui, 3:Add, Picture,x0 y0 w120 h-1 BackgroundTrans gMoveGui vPics, config/wubi98.icl
	GetKeyState, CL_State, CapsLock, T
	if CL_State ~="i)D"
		GuiControl,3:, Pics,*Icon17 config\wubi98.icl
	else
	{
		if IMEmode~="i)off"
			GuiControl,3:, Pics,*Icon19 config\wubi98.icl
		else
			GuiControl,3:, Pics,*Icon1 config\wubi98.icl
	}
	Gui, 3:Color, 015BA3
	Gui, 3:Margin, 2,2
	if Logo_Switch ~="i)off"
		Gui, 3:Destroy
	else
		Gui, 3:Show, NA x%Logo_X% y%Logo_Y%,sign_wb
	WinSet, TransColor, 015BA3 240,sign_wb   ;方案Logo的透明度 数字越大透明度越低最大255，0为完全透明
Return

Get_IME:
	global tip_pos:={x:GetCaretPos().x,y:GetCaretPos().y+30}
	If (srf_mode&&A_Cursor ~= "i)IBeam" ){
		if (A_OSVersion in WIN_7,WIN_8,WIN_8.1,10.,6.1,6.2,6.3)
		{
			Gosub Ime_Tips
			Sleep,400
			Gui, tips: Destroy
		}else{
			ToolTip,中,% GetCaretPos().x ,% GetCaretPos().y+30
			Sleep,400
			ToolTip
		}
	}else If (!srf_mode&&A_Cursor ~= "i)IBeam" ){
		if (A_OSVersion in WIN_7,WIN_8,WIN_8.1,10.,6.1,6.2,6.3)
		{
			Gosub Ime_Tips
			Sleep,400
			Gui, tips: Destroy
		}else{
			ToolTip, 英,% GetCaretPos().x ,% GetCaretPos().y+30
			Sleep,400
			ToolTip
		}
	}
Return

; 中英文切换模式
SetHotkey:
	srf_mode := !srf_mode
	if  srf_mode
	{
		if Logo_Switch ~="on"{
			Logo_X :=WubiIni.Settings["Logo_X"]
			Logo_Y :=WubiIni.Settings["Logo_Y"]
			Gui, 3:Show, NA x%Logo_X% y%Logo_Y%,sign_wb
			GuiControl,3:, Pics,*Icon1 config\wubi98.icl
		}
		Menu, Tray, Icon, config\wubi98.icl,9,1
		SetCapsLockState , off
		Gosub srf_value_off
		srf_for_select_Array :=select_arr:=srf_input:=[],Select_result:="",count_ci:=1, select_sym:=0
		WubiIni.Settings["IMEmode"]:="on"
		WubiIni.save()
	}
	else
	{
		Gosub Write_Pos
		GuiControl,3:, Pics,*Icon19 config\wubi98.icl
		;Gui, 3:Show, NA x%Logo_X% y%Logo_Y%,sign_wb
		Menu, Tray, Icon, config\wubi98.icl,12,1
		sendinput % RegExReplace(srf_all_input,"^z\'","")
		SetCapsLockState , off
		Gosub srf_value_off
		srf_for_select_Array :=select_arr:=[],Select_result:="",count_ci:=1, select_sym:=0
		WubiIni.Settings["IMEmode"]:="off"
		WubiIni.save()
	}
	Gosub Get_IME
Return

;logo开关
Logo_Switch:
	Logo_Switch :=(Logo_Switch~="i)off"?"on":"off")
	if Logo_Switch ~="i)off"{
		Gui, 3:Destroy
		Menu, Tray, Rename, 显隐图标,显隐图标	×
	}else{
		Gosub Schema_logo
		Menu, Tray, Rename, 显隐图标	×,显隐图标
	}
	WubiIni.Settings["Logo_Switch"] :=Logo_Switch, WubiIni.save()
	Menu, Tray, Enable, 导入词库
	Menu, Tray, Enable, 导出词库
Return

Del_EnKeyboard:    ;彻底删除系统美式英文键盘，因为是增删注册表的原因不能实时失效，需重启生效!调用的话直接 Gosub+空格+Del_EnKeyboard即可
	DelRegKey("HKEY_CURRENT_USER", "Keyboard Layout\Preload")
	DelRegKey("HKEY_USERS", ".DEFAULT\Keyboard Layout\Preload")
	RegDelete, HKEY_CURRENT_USER\Software\Microsoft\CTF\SortOrder\AssemblyItem\0x00000409
Return

;logo移动写入坐标
Write_Pos:
	WinGetPos, X_, Y_, , , sign_wb
	if (X_=""||Y_="")
	{
		Logo_X :=WubiIni.Settings["Logo_X"]:=200
		Logo_Y :=WubiIni.Settings["Logo_Y"]:=y2
		WubiIni.save()
	}
	else
	{
		Logo_X :=WubiIni.Settings["Logo_X"]:=X_
		Logo_Y :=WubiIni.Settings["Logo_Y"]:=Y_
		WubiIni.save()
	}
Return

;logo双击操作设定
MoveGui:
	PostMessage, 0xA1, 2, , , Ahk_Id %Wubi_Gui%
	Gosub Write_Pos
	if (A_GuiEvent = "Normal")
	{
		if IMEmode~="i)on" {
			GuiControl,3:, Pics,*Icon19 config\wubi98.icl
			Menu, Tray, Icon, config\wubi98.icl,12,1
			SetCapsLockState , off
			IMEmode :=WubiIni.Settings["IMEmode"]:="off",srf_mode:=0,WubiIni.save()
		}else{
			GuiControl,3:, Pics,*Icon1 config\wubi98.icl
			Menu, Tray, Icon, config\wubi98.icl,9,1
			SetCapsLockState , off
			IMEmode :=WubiIni.Settings["IMEmode"]:="on",srf_mode:=1,WubiIni.save()
		}
	}
Return

;托盘菜单
TRAY_Menu:
	global Wubi_Schema
	Menu, TRAY, NoStandard
	Menu, TRAY, DeleteAll
	program:="『柚子98五笔』"
	Menu, Tray, Add, 使用帮助,OnHelp
	Menu, TRAY, Icon, 使用帮助, config\wubi98.icl, 3
	Menu, Tray, Add
	if (Initial_Mode ~="i)on"){
		Menu, setting, Add, 剪切板通道	√, Initial_Mode
		Menu, setting, Icon, 剪切板通道	√, config\wubi98.icl, 15
	}else{
		Menu, setting, Add, 剪切板通道	×,Initial_Mode
		Menu, setting, Icon, 剪切板通道	×, config\wubi98.icl, 15
	}
	Menu, setting, Add
	if (Startup ~="i)on"){
		Menu, setting, Add, 开机自启	√, Startup
		Menu, setting, Icon, 开机自启	√, config\wubi98.icl, 15
	}else{
		Menu, setting, Add, 开机自启	×,Startup
		Menu, setting, Icon, 开机自启	×, config\wubi98.icl, 15
	}
/*
	Menu, setting, Add
	if (lookup_status ~="i)on"){
		Menu, setting, Add, 转换查询	√, lookup_status
		Menu, setting, Icon, 转换查询	√, config\wubi98.icl, 15
	}else{
		Menu, setting, Add, 转换查询	×,lookup_status
		Menu, setting, Icon, 转换查询	×, config\wubi98.icl, 15
	}
*/
	Menu, setting, Add
	if (Cut_Mode ~="i)on"){
		Menu, setting, Add, 拆分显示	√, Cut_Mode
		Menu, setting, Icon, 拆分显示	√, config\wubi98.icl, 15
	}else{
		Menu, setting, Add, 拆分显示	×,Cut_Mode
		Menu, setting, Icon, 拆分显示	×, config\wubi98.icl, 15
	}
	Menu, setting, Add
	if (Prompt_Word ~="i)on"){
		Menu, setting, Add, 空码提示	√, Prompt_Word
		Menu, setting, Icon, 空码提示	√, config\wubi98.icl, 15
	}else{
		Menu, setting, Add, 空码提示	×,Prompt_Word
		Menu, setting, Icon, 空码提示	×, config\wubi98.icl, 15
	}
	Menu, setting, Add
	if (Trad_Mode ~="i)on"){
		Menu, setting, Add, 中文繁体, Trad_Mode
		Menu, setting, Icon, 中文繁体, config\wubi98.icl, 6
	}else{
		Menu, setting, Add, 中文简体,Trad_Mode
		Menu, setting, Icon, 中文简体, config\wubi98.icl, 15
	}
	Menu, setting, Add
	if (Textdirection ~="i)horizontal"){
		Menu, setting, Add, 候选横排, Textdirection
		Menu, setting, Icon, 候选横排, config\wubi98.icl, 15
	}else{
		Menu, setting, Add, 候选竖排,Textdirection
		Menu, setting, Icon, 候选竖排, config\wubi98.icl, 15
	}
	Menu, setting, Add
	if (limit_code ~="i)on"){
		Menu, setting, Add, 四码上屏	√, limit_code
		Menu, setting, Icon, 四码上屏	√, config\wubi98.icl, 15
	}else{
		Menu, setting, Add, 四码上屏	×,limit_code
		Menu, setting, Icon, 四码上屏	×, config\wubi98.icl, 15
	}
	Menu, setting, Add
/*
	if (symb_send ~="i)on"){
		Menu, setting, Add, 符号顶屏	√, symb_send
		Menu, setting, Icon, 符号顶屏	√, config\wubi98.icl, 15
	}else{
		Menu, setting, Add, 符号顶屏	×,symb_send
		Menu, setting, Icon, 符号顶屏	×, config\wubi98.icl, 15
	}
	Menu, setting, Add
*/
	if (Select_Enter ~="i)send"){
		Menu, setting, Add, 回车上屏, Select_Enter
		Menu, setting, Icon, 回车上屏, config\wubi98.icl, 15
	}else if (Select_Enter ~="i)clean"){
		Menu, setting, Add, 回车清屏,Select_Enter
		Menu, setting, Icon, 回车清屏, config\wubi98.icl, 15
	}
	Menu, Tray, Add, 更多设置,:setting
	Menu, TRAY, Icon, 更多设置, config\wubi98.icl, 14
	Menu, Tray, Add
	if ToolTipStyle ~="i)on"{
		Menu, Tip_Style, Add, ToolTip样式	√,Tip_Style
		Menu, Tip_Style, Icon, ToolTip样式	√, config\wubi98.icl, 15
	}else{
		Menu, Tip_Style, Add, ToolTip样式,Tip_Style
		Menu, Tip_Style, Icon, ToolTip样式, config\wubi98.icl, 15
	}
	Menu, Tip_Style, Add
	if ToolTipStyle ~="i)off"{
		Menu, Tip_Style, Add, Gui候选样式	√,Tip_Style
		Menu, Tip_Style, Icon, Gui候选样式	√, config\wubi98.icl, 15
	}else{
		Menu, Tip_Style, Add, Gui候选样式,Tip_Style
		Menu, Tip_Style, Icon, Gui候选样式, config\wubi98.icl, 15
	}
	Menu, Tip_Style, Add
	if ToolTipStyle ~="i)Gdip"{
		Menu, Tip_Style, Add, Gdip候选样式	√,Tip_Style
		Menu, Tip_Style, Icon, Gdip候选样式	√, config\wubi98.icl, 15
	}else{
		Menu, Tip_Style, Add, Gdip候选样式,Tip_Style
		Menu, Tip_Style, Icon, Gdip候选样式, config\wubi98.icl, 15
	}
	Menu, Tray, Add, 候选样式, :Tip_Style
	Menu, TRAY, Icon, 候选样式, config\wubi98.icl, 20
	Menu, Tray, Add
	;Menu, Tray, Default, 高级设置
	Menu, Tray, Add, 导入词库,OnWrite
	if Wubi_Schema~="i)zi"
		Menu, Tray, Disable, 导入词库
	Menu, TRAY, Icon, 导入词库, config\wubi98.icl, 10
	Menu, Tray, Add
	Menu, Tray, Add, 导出词库,OnBackup
	if Wubi_Schema~="i)zi"
		Menu, Tray, Disable, 导出词库
	Menu, TRAY, Icon, 导出词库, config\wubi98.icl, 11
	Menu, Tray, Add
	Menu, Tray, Add, 标签设置, OnLabel
	Menu, TRAY, Icon, 标签设置, config\wubi98.icl, 8
	Menu, Tray, Add
	Menu, Tray, Add, 高级设置, Onconfig
	Menu, TRAY, Icon, 高级设置, config\wubi98.icl, 6
	Menu, Tray, Add
	Menu, Tray, Add, 快捷造词,Add_Code
	if Wubi_Schema~="i)zi|chaoji"
		Menu, Tray, Disable, 快捷造词
	Menu, TRAY, Icon, 快捷造词, config\wubi98.icl, 13
	Menu, Tray, Add
	Menu, Tray, Add, 显隐图标,Logo_Switch
	Menu, TRAY, Icon, 显隐图标, config\wubi98.icl, 2
	Menu, Tray, Add
	Menu, Tray, Add, 启用状态	√,OnSuspend
	Menu, TRAY, Icon, 启用状态	√, config\wubi98.icl, 18
	Menu, Tray, Add
	Menu, Tray, Add, 重载脚本,OnReload
	Menu, TRAY, Icon, 重载脚本, config\wubi98.icl, 5
	Menu, Tray, Add
	Menu, Tray, Add, 退出程序,OnExit
	Menu, TRAY, Icon, 退出程序, config\wubi98.icl, 7
	Menu, Tray, Default,高级设置
	;Menu, Tray, Click, 1
	Menu,Tray,Tip,%program%
return

Disable_Tray:
	Menu, Tray, Disable, 导入词库
	Menu, Tray, Disable, 导出词库
return

Enable_Tray:
	Menu, Tray, Enable, 导入词库
	Menu, Tray, Enable, 导出词库
return

;托盘菜单候选样式选择
Tip_Style:
	if A_ThisMenuItem ~="i)ToolTip"&&ToolTipStyle<>"on"{
		Menu, Tip_Style, Rename, ToolTip样式,ToolTip样式	√
		if ToolTipStyle ~="i)gdip"
			Menu, Tip_Style, Rename, Gdip候选样式	√,Gdip候选样式
		else if ToolTipStyle ~="i)off"
			Menu, Tip_Style, Rename, Gui候选样式	√,Gui候选样式
		global ToolTipStyle :=WubiIni.TipStyle["ToolTipStyle"] :="on"
		global FontSize :=WubiIni.TipStyle["FontSize"] :="14"
	}
	else if A_ThisMenuItem ~="i)Gui"&&ToolTipStyle<>"off"{
		Menu, Tip_Style, Rename, Gui候选样式,Gui候选样式	√
		if ToolTipStyle ~="i)gdip"
			Menu, Tip_Style, Rename, Gdip候选样式	√,Gdip候选样式
		else if ToolTipStyle ~="i)on"
			Menu, Tip_Style, Rename, ToolTip样式	√,ToolTip样式
		global ToolTipStyle :=WubiIni.TipStyle["ToolTipStyle"] :="off"
		global FontSize :=WubiIni.TipStyle["FontSize"] :="16"
	}
	else if A_ThisMenuItem ~="i)Gdip"&&ToolTipStyle<>"gdip"{
		Menu, Tip_Style, Rename, Gdip候选样式,Gdip候选样式	√
		if ToolTipStyle ~="i)off"
			Menu, Tip_Style, Rename, Gui候选样式	√,Gui候选样式
		else if ToolTipStyle ~="i)on"
			Menu, Tip_Style, Rename, ToolTip样式	√,ToolTip样式
		global ToolTipStyle :=WubiIni.TipStyle["ToolTipStyle"] :="gdip"
		global FontSize :=WubiIni.TipStyle["FontSize"] :="20"
	}
	WubiIni.save()
	Gui, houxuankuang:Destroy
	Gosub houxuankuangguicreate
Return

;挂起操作
OnSuspend:
	Suspend
	if (A_IsSuspended =1){
		Menu, TRAY, Rename, 启用状态	√ , 挂起状态	×
		Menu, TRAY, Icon, 挂起状态	×, config\wubi98.icl, 4
		Traytip,  提示:,已切换至挂起状态！
	}
	else if A_IsSuspended =0
	{
		Menu, TRAY, Rename, 挂起状态	× , 启用状态	√
		Menu, TRAY, Icon, 启用状态	√, config\wubi98.icl, 18
		Traytip,  提示:,已切换至启用状态！
	}
return

;重载操作
OnReload:
	if Logo_Switch ~="i)on"
		Gosub Write_Pos
	reload
return

;写入词库
OnWrite:
	Gosub Write_DB
Return

;导出词库
OnBackup:
	Gosub Backup_DB
Return

;帮助
OnHelp:
	Run  config\ReadMe.png
return

;设置面板
Onconfig:
if WinExist("样式面板"){
	Traytip,  警告提示:,不能重复打开「样式面板」窗口！,,2
	Return
}
else
	Gosub Show_Setting
return

;标签设置页
OnLabel:
if WinExist("标签设置"){
	Traytip,  警告提示:,不能重复打开「标签设置」窗口！,,2
	Return
}
else
	Gosub Label_show
Return

;退出设定
OnExit:
	DB.closedb()
	;Gosub Del_EnKeyboard          ;退出后从系统删除美式键盘，启用的话去掉注释符
	if Logo_Switch ~="i)on"
		Gosub Write_Pos
	if A_OSVersion contains 10.0
	{
		SwitchToChsIME()
		Traytip,  退出提示:,已切换至中文键盘！
	}
	ExitApp
return

;gui候选框
houxuankuangguicreate:
	Gui, houxuankuang:Destroy
	Gui, houxuankuang:+ToolWindow -Caption -DPIScale +AlwaysOnTop +hWndguihouxuankuang +Border
	Gui, houxuankuang:Font,s%FontSize% , %FontType%
	Gui, houxuankuang:Color, %BgColor%
	Gui, houxuankuang:Add, Text, x5 y3 vmyedit1 BackgroundTrans c%FontColor_Code%
	if Gdip_Line ~="i)on"
		Gui, houxuankuang:Add, Text, x0 yp+15 w%A_ScreenWidth% h1 0x10 vfengefu
	Gui, houxuankuang:Add, Text, x5 vmyedit2 BackgroundTrans c%FontColor%
	Gui, houxuankuang:Show, % "Hide x" A_ScreenWidth//2-A_ScreenWidth//8 " y" A_ScreenHeight-200
	Tip1hWnd:=ToolTip(1, "", "Q1 B" BgColor " T" FontColor_Code " S" FontSize*A_ScreenDPI/96 " F" FontType)
	ToolTip(2, "", "Q1 B" BgColor " T" FontColor " S" FontSize*A_ScreenDPI/96 " F" FontType)
	Height:=60
Return

;提词结果处理
srf_tooltip:
	if srf_all_Input ~="^[\,\#0-9]+"
	{
		srf_all_Input :=RegExReplace(srf_all_Input,"^\,","#")
		num_switch :=numTohz(srf_all_Input)
		StringSplit, num_for_select_arrays, num_switch, `n, `n
		if !num_switch
			tooltip(1)
		else
		{
			srf_for_select_for_tooltip :=num_for_select_arrays1 . "`n" . num_for_select_arrays2 . "`n" . num_for_select_arrays3 . "`n" . num_for_select_arrays4 . "`n" . num_for_select_arrays5
		}
	}

	If limit_code ~="i)on"
	{
		if (StrLen(srf_all_input)=4&&srf_all_input ~="^[a-yA-Y]")
		{
			if srf_for_select_Array.Length()=0{    ;如果无候选，则自动清空历史
				srf_for_select_for_tooltip:=
			}
			else if srf_for_select_Array.Length()=1 ;如果候选唯一，则自动上屏
			{
				srf_select(1)
				gosub srf_value_off
				srf_for_select_Array :=[]
			}
		}
		else if (StrLen(srf_all_input)>4&&srf_all_input ~="^[a-yA-Y]") ;五码顶字上屏，排除编码含z的拼音反查
		{
			if Textdirection ~="i)vertical"
			{
				loop,parse,srf_for_select_for_tooltip ,`n
				{
					sendinput % RegExReplace(A_LoopField,"^\d\.|〔.+|#\〔.+|>\d+\、|\d+\、|\s+","")
					break
				}
			}
			else
			{
				loop,parse,srf_for_select_for_tooltip ,%A_Space%
				{
					sendinput % RegExReplace(A_LoopField,"^\d\.|〔.+|#\〔.+|>\d+\.|\d+\.","")
					break
				}
			}
			srf_all_input :=RegExReplace(srf_all_input, "^[a-zA-Z]{4}", "")
			Gosub srf_tooltip_fanye
		}
		else if StrLen(srf_all_input)<4&&srf_for_select_Array.Length()=0&&srf_all_input ~="^[a-yA-Y]"
		{
			srf_for_select_for_tooltip :=
		}
	}
	else
	{
		if strlen(srf_all_input)>0&&srf_for_select_Array.Length()<1
			srf_for_select_for_tooltip :=
	}

	if srf_all_input ~="^z.+|^z|^``|^/|^~"
	{
		if (srf_for_select_Array.Length()<1)
			srf_for_select_for_tooltip :=
	}	
	global Caret:=GetCaretPos()
	Gosub showhouxuankuang
	strlen(srf_all_input)>4&&srf_for_select_Array.Length()<1?"":(srf_for_select_for_tooltip :=)
Return

;候选下一页
MoreWait:
	If (waitnum*ListNum+ListNum<srf_for_select_Array.Length()){
		waitnum+=1
		Gosub srf_tooltip_fanye
	}
Return

;候选上一页
lessWait:
	If (waitnum>0){
		waitnum-=1
		Gosub srf_tooltip_fanye
	}
Return

;候选词条分页处理
srf_tooltip_fanye:
	if srf_all_Input ~="^``"{
		if srf_all_Input~="^``[a-z]+"{
			srf_input:= StrSplit(RegExReplace(srf_all_Input,"^``"), "``")
			srf_for_select_Array:=format_word(srf_input[count_ci])
			if (count_ci>1){
				srf_for_select_Array.InsertAt(1,select_arr )
				srf_for_select_Array[1,2]:="☯",srf_for_select_Array[1,3]:="☯"
			}
			Gosub srf_tooltip_cut
		}else if RegExReplace(srf_all_Input,"^``")~="\``[a-z]+"{
			srf_for_select_Array:=prompt_enword(RegExReplace(srf_all_Input,"^````",""))
			Gosub srf_tooltip_cut
		}else if (srf_all_Input~="^[``]{1,2}$"){
			Sym_Array[1,1]:="``", srf_for_select_Array:=Sym_Array, count_ci:=1,select_arr:=srf_input:=[],Select_result:=""
			Gosub srf_tooltip_cut
		}else if (srf_all_Input~="^[``]{3,}$"){
			Gosub srf_value_off
			count_ci:=1, select_arr:=srf_input:=[],Select_result:=""
		}
	}else if srf_all_Input ~="^/"{
		if srf_all_Input~="^/[a-z]+|^/[0-9]+"
		{
			srf_for_select_Array:=prompt_symbols(srf_all_Input)
		}else{
			Sym_Array_1[1,1]:=srf_all_input, srf_for_select_Array:=Sym_Array_1
		}
		Gosub srf_tooltip_cut
	}else if srf_all_Input ~="^z"{
		if srf_all_Input~="^z[a-z]+|^z\'[a-z]+"
			srf_all_input:=RegExReplace(srf_all_input,"^z|^z\'",srf_all_input~="'"?"z":"z'"), srf_for_select_Array:=get_word(srf_all_input, Wubi_Schema)
		else
		{
			if recent[1]{
				loop % objLength(recent)
					srf_for_select_Array[A_Index,1]:=recent[A_Index]
			}else{
				recent[1]:=srf_all_input
				loop % objLength(recent)
					srf_for_select_Array[A_Index,1]:=recent[A_Index]
			}
		}
		Gosub srf_tooltip_cut
	}else if srf_all_Input ~="^~"{
		if srf_all_Input ~="^~[a-z]+"
			srf_for_select_Array:=prompt_pinyin(srf_all_Input)
		else if srf_all_Input ~="^~$"
			Sym_Array:=[],Sym_Array[1,1]:=srf_all_Input, Sym_Array[2,1]:="～",srf_for_select_Array:=Sym_Array
		Gosub srf_tooltip_cut
	}else{
		srf_for_select_Array:=get_word(srf_all_Input, Wubi_Schema)
		Gosub srf_tooltip_cut
	}

Return

srf_tooltip_cut:
	srf_for_select_string:=""
	, loopindex:=srf_for_select_Array.Length()-ListNum*waitnum
	, loopindex:=(loopindex>ListNum?ListNum:loopindex)
	If (Textdirection="horizontal")
	{
		Loop %loopindex%
			srf_for_select_string.=(srf_all_Input~="/\d+"?A_Space A_Space SubStr(Select_Code, A_Index , 1):(Cut_Mode~="on"?A_Space:A_Space A_Space) A_Index) "." srf_for_select_Array[ListNum*waitnum+A_Index,1] (Cut_Mode="on"&&a_FontList ~="98WB-V|98WB-P0|五笔拆字字根字体|98WB-1|98WB-3|98WB-ZG|98WB-0"&&FontType ~="98WB-V|98WB-P0|五笔拆字字根字体|98WB-1|98WB-3|98WB-ZG|98WB-0"&&srf_for_select_Array[ListNum*waitnum+A_Index, valueindex]<>""?"〔" . srf_for_select_Array[ListNum*waitnum+A_Index, valueindex] . "〕":A_Space . srf_for_select_Array[ListNum*waitnum+A_Index, 3])
	}
	Else
	{
		Loop %loopindex%
			srf_for_select_string.="`n" (srf_all_Input~="/\d+"?SubStr(Select_Code, A_Index , 1):A_Index) "." srf_for_select_Array[ListNum*waitnum+A_Index, 1] (Cut_Mode="on"&&a_FontList ~="98WB-V|98WB-P0|五笔拆字字根字体|98WB-1|98WB-3|98WB-ZG|98WB-0"&&FontType ~="98WB-V|98WB-P0|五笔拆字字根字体|98WB-1|98WB-3|98WB-ZG|98WB-0"&&srf_for_select_Array[ListNum*waitnum+A_Index, valueindex]<>""?"〔" . srf_for_select_Array[ListNum*waitnum+A_Index, valueindex] . "〕":A_Space . srf_for_select_Array[ListNum*waitnum+A_Index, 3])
	}

	if srf_for_select_string
		srf_for_select_for_tooltip:=Trim(srf_for_select_string,". `n") (Textdirection="vertical"?"`n":(Textdirection="horizontal"&&Ceil(srf_for_select_Array.Length()/ListNum)>1?A_Space:"")) (Ceil(srf_for_select_Array.Length()/ListNum)>1?(Cut_Mode="on"?("[ 第" waitnum+1 "页/共" Ceil(srf_for_select_Array.Length()/ListNum) "页 ]"):("[ " waitnum+1 "/" Ceil(srf_for_select_Array.Length()/ListNum) " ]")):"")
	Gosub srf_tooltip
Return

;候选框样式判断
showhouxuankuang:
	If (srf_all_Input=""){
		srf_for_select_for_tooltip:=""
		If (ToolTipStyle ~="i)off")
			ToolTip(1,""), ToolTip(2,"")
		Else
			Gui, houxuankuang:Hide
		Return
	}
	srf_code:=srf_all_input~="^z\'[a-z]"?RegExReplace(srf_all_input,"^z\'",""):(srf_all_input~="^``$"?RegExReplace(srf_all_input,"^``","〔精准造词〕"):srf_all_input~="^~$"?RegExReplace(srf_all_input,"^~","〔以形查音〕"):srf_all_input~="^````$"?RegExReplace(srf_all_input,"^````","〔临时英文〕"):srf_all_input)
	srf_code:=RegExReplace(srf_code,"^``|^~")
	if Fix_Switch~="i)on"{
		Caret:={x:Fix_X,y:Fix_Y,h:30}
	}else{
		Caret:=GetCaretPos()
	}
	If (ToolTipStyle ~="i)on"){
		ToolTip(1, srf_code, "x" Caret.x " y" Caret.y+Caret.h)
		WinGetPos, x, y, , Height, % "ahk_id" Tip1hWnd  ;   ;双行请启用
		ToolTip(2, srf_for_select_for_tooltip, "x" x " y" y+Height+5+Set_Range)
	} Else If (ToolTipStyle ~="i)off"){
		Gui, measure:Destroy
		Gui, measure:+ToolWindow -Caption -DPIScale +AlwaysOnTop
		Gui, measure:Font,s%FontSize% , %FontType%
		Try {
			Gui, measure:Add, Text, vmeasureedit1, %srf_all_Input%
			GuiControlGet, measure_P1, measure:Pos, measureedit1
			Gui, measure:Add, Text, x0 yp+20 vmeasureedit2, % srf_for_select_for_tooltip
			GuiControlGet, measure_P2, measure:Pos, measureedit2
		}
		guihouxuankuang_width:=Max(measure_P1w, measure_P2w)+15
		if (srf_for_select_Array.Length()>0)
		{
			guihouxuankuang_height:=((srf_for_select_Array.Length()>ListNum or Textdirection ~="i)horizontal")?(measure_P1h+measure_P2h+25):(measure_P1h+measure_P2h))
			guihouxuankuang_x:=Max(Min(A_ScreenWidth-guihouxuankuang_width, Caret.X+15), 0)
			, guihouxuankuang_y:=Max(Min(A_ScreenHeight-guihouxuankuang_height, Caret.Y+30), 0)
			Gui, houxuankuang:Show, % "NA w" guihouxuankuang_width " h" guihouxuankuang_height " x" guihouxuankuang_x " y" guihouxuankuang_y
			;WinSet, Region, % "0-0 w" guihouxuankuang_width+3 " h" guihouxuankuang_height+3 " R15-15", ahk_id%guihouxuankuang%
			GuiControl, houxuankuang:Move, myedit1, % "w" measure_P1w " h" measure_P1h
			if Gdip_Line ~="i)on"{
				GuiControl, houxuankuang:Show, fengefu
				GuiControl, houxuankuang:Move, fengefu, % "y" measure_P1h+7
			}
			GuiControl, houxuankuang:Move, myedit2, % "w" measure_P2w " h" measure_P2h " y" measure_P1h+20
			GuiControl, houxuankuang:Text, myedit1, %srf_code%
			GuiControl, houxuankuang:Show, myedit2
			GuiControl, houxuankuang:Text, myedit2, %srf_for_select_for_tooltip%
		}
		else
		{
			guihouxuankuang_height:=measure_P1h+measure_P2h/2
			guihouxuankuang_x:=Max(Min(A_ScreenWidth-guihouxuankuang_width, Caret.X+15), 0)
			, guihouxuankuang_y:=Max(Min(A_ScreenHeight-guihouxuankuang_height, Caret.Y+30), 0)
			Gui, houxuankuang:Show, % "NA w" guihouxuankuang_width " h" guihouxuankuang_height " x" guihouxuankuang_x " y" guihouxuankuang_y
			GuiControl, houxuankuang:Move, myedit1, % "w" measure_P1w " h" measure_P1h
			GuiControl, houxuankuang:Hide, fengefu
			GuiControl, houxuankuang:Text, myedit1, %srf_code%
			GuiControl, houxuankuang:Hide, myedit2
		}
	} Else {
		GdipText(srf_code, srf_for_select_for_tooltip, Caret.X , Caret.Y+30 , FontType)
	}
Return

;清除操作
srf_value_off:
	Critical, On
	If (ToolTipStyle ~="i)on")
		ToolTip(1), ToolTip(2)
	Else If (ToolTipStyle ~="i)off")
		Gui, houxuankuang:Hide
	Else
		GdipText("")
	num_for_select_arrays0=
	srf_for_select_for_tooltip:=""
	srf_all_Input:=output_words:="", hasCaretPos:=waitnum:=0
	jichu_for_select_Array:=[]
Return

;样式面板
More_Setting:
	Menu, StyleMenu, Add, Tooltip样式, Export
	Menu, StyleMenu, Add, Gui候选框样式, Export
	Menu, StyleMenu, Add, Gdip候选框样式, Export
	HMENU := Menu_GetMenuByName("StyleMenu")
	Gui, 98: +hwndhwndgui98 +AlwaysOnTop +ToolWindow
	Gui,98:Font, s10 Bold, %font_%
	Gui 98:Add, Tab3, x+0 y+10 w420 h720, 基础配置|其它设置|关于
	Gui, 98:Tab, 1
	Gui 98:Add, GroupBox, y+5 w365 h160, 候选框选色
	Gui,98:Font
	Gui,98:Font, s9, %font_%
	Gui, 98:Add, Text,
	Gui, 98:Add, Text, xm+25 yp-130 left, 编码选色：
	Gui, 98:Add, Button, x+0 w80 h25 hwndhwndfontcolor_code gsetcolor vFontColor_Code
	Gui, 98:Add, Text,
	Gui, 98:Add, Text, xm+180 ym+70 left, 候选词选色：
	Gui, 98:Add, Button, x+0 w80 h25 hwndhwndfontcolor gsetcolor vFontColor
	Gui, 98:Add, Text,
	Gui, 98:Add, Text, xm+25 ym+110 left, 背景选色：
	Gui, 98:Add, Button, x+0 w80 h25 hwndhwndbgcolor gsetcolor vBgColor
	Gui, 98:Add, Text, xm+180 yp+0 left, 分隔线选色：
	Gui, 98:Add, Button, x+0 w80 h25 hwndhwndlinecolor gsetcolor vLineColor
	Gui, 98:Add, Text, xm+25 ym+150 left, 边框选色：
	Gui, 98:Add, Button, x+0 w80 h25 hwndhwndbordercolor gsetcolor vBorderColor
	CreateImageButton(hwndfontcolor_code,[{BC: fontcolor_code, 3D: 0}],5)
	CreateImageButton(hwndfontcolor,[{BC: fontcolor, 3D: 0}],5)
	CreateImageButton(hwndbgcolor,[{BC: bgcolor, 3D: 0}],5)
	CreateImageButton(hwndlinecolor,[{BC: linecolor, 3D: 0}],5)
	CreateImageButton(hwndbordercolor,[{BC: bordercolor, 3D: 0}],5)
	;Menu_BarRightJustify(hwndgui98, 2)
	Gui,98:Font, s10 Bold, %font_%
	Gui 98:Add, GroupBox,xm+15 y+30 w365 h310, 功能项设置
	Gui,98:Font
	Gui,98:Font, s9, %font_%
	Gui, 98:Add, Text, xm+25 yp+30  left, 选框风格：
	Gui, 98:Add, Button,x+20 w135 hwndHExportBtn gStyleMenu vStyleMenu, % ToolTipStyle~="i)on"?"Tooltip样式":ToolTipStyle~="i)off"?"Gui候选框样式":"Gdip候选框样式"
	Gui, 98:Add, CheckBox,xm+250 yp+0 vSBA5 gSBA5, 固定`n位置
	Gui, 98:Add, Button,xm+305 yp+5 vSBA0 gSBA0, 坐标设置
	Gui, 98:Add, CheckBox,xm+25 yp+35 vSBA9 gSBA9, Gdip框圆角
	Gui, 98:Add, CheckBox,xm+140 yp+0 vSBA10 gSBA10, Gdip分割线
	Gui, 98:Add, CheckBox,xm+280 yp+0 vSBA12 gSBA12, 粗体
	Gui, 98:Add, Text, xm+25 yp+40  left, 上屏方式：
	Gui, 98:Add, DDL,x+22 w135  vsChoice1 gsChoice1, 常规上屏|剪切板上屏
	Gui, 98:Add, Text, xm+25 yp+40  left, 回车键功能：
	Gui, 98:Add, DDL,x+10 w135 vsChoice2 gsChoice2, 编码上屏|回车清空
	Gui, 98:Add, Text, xm+25 yp+40  left, 候选模式：
	Gui, 98:Add, DDL,x+22 w135 vsChoice3 gsChoice3, 候选横排|候选竖排
	Gui, 98:Add, Text, xm+25 yp+40  left, 中英切换：
	Gui, 98:Add, DDL, vsethotkey_1 gsethotkey_1 x+22 yp-1 w60, Ctrl|Shift|Alt|LWin
	Gui 98:Add, Text, yp x+10 h25 w65 Center Border cblue vsethotkey_2 gsethotkey_2, % RegExReplace(Srf_Hotkey,"i)Shift|Ctrl|Alt|LWin|&","")
	Gui, 98:Add, Button, yp+0 x+10 vhk_1 ghk_1, 设置
	Gui, 98:Add, text, yp+5 x+10 w80 cred vtip_text, %A_Space%
	Gui, 98:Add, CheckBox, xm+25 yp+40 gEnableUIAccess vUIAccess , UIA（便携版勿选）
	Gui, 98:Add, CheckBox,xm+185 yp vSBA14 gSBA14, 中文模式使用英文标点
	Gui,98:Font, s10 Bold, %font_%
	Gui 98:Add, GroupBox,xm+15 y+40 w365 h170, 词库设置
	Gui,98:Font
	Gui,98:Font, s9, %font_%
	Gui, 98:Add, Text, xm+25 yp+40  left, 码表选择：
	Gui, 98:Add, DDL,x+30 w80 vsChoice4 gsChoice4, 含词码表|单字码表|超集码表
	Gui, 98:Add, Button, x+10 yp-1 vciku1 gciku1,导入
	Gui, 98:Add, Button, x+5 yp-1 vciku2 gciku2,导出
	Gui, 98:Add, Text, xm+25 yp+40  left, 英文词库：
	Gui, 98:Add, Button, x+30 yp-1 vciku3 gciku3,导入
	Gui, 98:Add, Button, x+5 yp-1 vciku4 gciku4,导出
	Gui, 98:Add, Text, xm+25 yp+40  left, 特殊符号：
	Gui, 98:Add, Button, x+30 yp-1 vciku5 gciku5,导入
	Gui, 98:Add, Button, x+5 yp-1 vciku6 gciku6,导出
	Gui, 98:Tab, 2
	Gui,98:Font, s10 Bold, %font_%
	Gui 98:Add, GroupBox, y+5 w370 h240, 字体设置
	Gui,98:Font,
	Gui,98:Font, s9, %font_%
	Gui, 98:Add, Text, xm+35 ym+70 w80 left, 字体选择：
	Gui, 98:Add, ComboBox,x+0 w120 gfonts_type vFontType, % a_FontList
	GuiControl, 98:ChooseString, FontType, %FontType%
	Gui, 98:Add, Text, xm+35 y+20 w80 left, 字号选择：
	Gui, 98:Add, Edit, x+0 w120 Limit2 Number vfont_value gfont_value
	Gui, 98:Add, UpDown, x+0 w120 vMyUpDown Range9-40 gfont_size vfont_size, %FontSize%
	Gui, 98:Add, Text, xm+35 y+20 w80 left, 候选数选择：
	Gui, 98:Add, Edit, x+0 w120 Limit2 Number vselect_value gselect_value
	Gui, 98:Add, UpDown, x+0 w120 vMyUpDown Range4-10 gset_select_value vset_select_value, %ListNum%
	Gui, 98:Add, Text, xm+35 y+20 w80 left, ToolTip框`n偏移值：
	Gui, 98:Add, Edit, x+0 w120 Limit2 Number vset_regulate_Hx gset_regulate_Hx
	Gui, 98:Add, UpDown, x+0 w120 vMyUpDown Range3-25 gset_regulate vset_regulate, %Set_Range%
	Gui,98:Font, s10 Bold, %font_%
	Gui 98:Add, GroupBox,xm+15 y+60 w370 h380, 扩展项设置
	Gui,98:Font
	Gui,98:Font, s9, %font_%
	Gui, 98:Add, CheckBox,xm+25 yp+45 vSBA1 gSBA1, 繁体模式
	Gui, 98:Add, CheckBox,xm+135 yp+0 vSBA2 gSBA2, 拆分显示
	Gui, 98:Add, CheckBox,xm+235 yp+0 vSBA3 gSBA3, 空码提示
	Gui, 98:Add, CheckBox,xm+25 yp+45 vSBA4 gSBA4, 开机自启
	Gui, 98:Add, CheckBox,xm+135 yp+0 vSBA6 gSBA6, 符号顶屏
	Gui, 98:Add, CheckBox,xm+235 yp+0 vSBA7 gSBA7, 四码上屏
	Gui, 98:Add, CheckBox,xm+25 yp+45 vSBA13 gSBA13, Logo显隐
	Gui, 98:Tab, 3
	Gui,98:Font
	Gui,98:Font,cRed s12 Bold, %font_%
	Gui 98:Add, Picture
	Gui,98:Add, Text,Center w100 y+25, 详细帮助
	Gui 98:Add, Text, y+5 w370 h2 0x10
	Gui,98:Add, Text,
	Gui,98:Font
	Gui,98:Font, s10, %font_%
	Gui,98:Add, Text, y+5, 了解更多信息
	Gui,98:Add, Link, y+5, 关于：<a href="https://wubi98.gitee.io/">https://wubi98.gitee.io/</a>`n资源库：<a href="http://98wb.ys168.com">http://98wb.ys168.com</a>
	Gui,98:Add, Text, y+5, 版本日期：%Versions%
	Gui 98:Font, cRed
	Gui 98:Add, GroupBox, y+5 w370 h255, 使用说明
	Gui,98:Font
	Gui,98:Font, s9, %font_%
	FileRead, readme_, config\ReadMe.txt
	Gui, 98:Add, Edit, xm+25 yp+30 w345 h210 Uppercase gAbout vAbout, %readme_%
	Gui,98:Margin, 15, 15
	Global SG1 := New ScrollGUI(hwndgui98, 540, 540, "+AlwaysOnTop +ToolWindow -DPIScale", 3, 4)
	Gosub ControlGui
Return


;样式面板关闭销毁保存操作
98GuiClose:
	98GuiEscape:
	Gui, 98:Destroy
	WubiIni.Save()
Return

;快捷键选择键盘界面
Key_:
	KeyName:={ "":"Space", Caps:"CapsLock", App:"AppsKey", Psc:"PrintScreen", Slk:"ScrollLock", "↑":"Up", "↓":"Down", "←":"Left", "→":"Right" ,"清空":""}
	w1:=35, h1:=20, w2:=50, w3:=w1*14+2*13

	s1:=[ ["Esc"],["F1",,w3-w1*13-15*2-2*9],["F2"],["F3"],["F4"],["F5",,15],["F6"],["F7"],["F8"],["F9",,15],["F10"],["F11"],["F12"],["Psc",w2,10],["Slk",w2],["Pause",w2] ]

	s2:=[ ["``"],["1"],["2"],["3"],["4"],["5"],["6"],["7"],["8"],["9"],["0"],["-"],["="],["BS"],["Ins",w2,10],["Home",w2],["PgUp",w2] ]

	s3:=[ ["Tab"],["q"],["w"],["e"],["r"],["t"],["y"],["u"],["i"],["o"],["p"],["["],["]"],["\"],["Del",w2,10],["End",w2],["PgDn",w2] ]

	s4:=[ ["Caps",w2],["a"],["s"],["d"],["f"],["g"],["h"],["j"],["k"],["l"],["`;"],["'"],["Enter",w3-w1*11-w2-2*12] ,["清空",w2,10]]

	s5:=[ ["Shift",w1*2],["z"],["x"],["c"],["v"],["b"],["n"],["m"],[","],["."],["/"],["Shift",w3-w1*12-2*11],["↑",w2,10+w2+2] ]

	s6:=[ ["Ctrl",w2],["Win",w2],["Alt",w2],["",w3-w2*7-2*7],["Alt",w2],["Win",w2],["App",w2],["Ctrl",w2],["←",w2,10],["↓",w2],["→",w2] ]

	Gui, Key: Destroy
	Gui, Key: +AlwaysOnTop +Owner +ToolWindow +E0x08000000
	Gui, Key: Font, s9, Verdana
	Gui, Key: Margin, 10, 10
	Gui, Key: Color, ffffff
	Loop, 6 {
		if (A_Index<=2)
		j=
		For i,v in s%A_Index%
		{
			w:=v.2 ? v.2 : w1, d:=v.3 ? v.3 : 2
			j:=j="" ? "xm" : i=1 ? "xm y+2" : "x+" d
			Gui, Key: Add, Button, %j% w%w% h%h1% -Wrap gRunKey, % v.1
		}
	}
	Gui, Key: Add, StatusBar,vsbt,[ 请选取按键 。。。]
	Gui, Key: Show, NA, 小键盘
return

KeyGuiClose:
	Gui, Key: Destroy
	SG1.Show("高级设置", "ycenter xcenter")
	Gui, 98:show,NA
return

RunKey:
	k:=A_GuiControl
	GuiControl, 98:Text, tip_text,% ""
	if k not in Shift,Ctrl,Win,Alt
	{
		if not GetKeyState(k)~="\d" {
			Srf_Hotkey2:=KeyName[k]
		}else{
			Srf_Hotkey2:=k
		}
		GuiControl, 98:Text, sethotkey_2, % Srf_Hotkey2
		Srf_Hotkey:=WubiIni.Settings["Srf_Hotkey"]:=(Srf_Hotkey1?Srf_Hotkey1:RegExReplace(Srf_Hotkey,"&.+","")) . (Srf_Hotkey2?"&":"") Srf_Hotkey2,WubiIni.save()
		Gosub KeyGuiClose
		SG1.Show("高级设置", "ycenter xcenter")
		Gui, 98:show,NA
	}else{
		Gui, Key:Font, s8 cRed Bold 
		GuiControl, Key:Font, sbt
		GuiControl,Key:, sbt , 该键名不支持，请重新选择！
	}
	if Srf_Hotkey2{
		GuiControl, 98:Text, tip_text , 已选择！
		Sleep 1500
		GuiControl, 98:Text, tip_text , 
	}
return

hk_1:
	if !sethotkey_2&&sethotkey_1
		Srf_Hotkey:=WubiIni.Settings["Srf_Hotkey"]:=SSrf_Hotkey~="\&"?(Srf_Hotkey1 . "&" . RegExReplace(Srf_Hotkey,".+\&","")):Srf_Hotkey1,WubiIni.save()
	else if !sethotkey_2&& !sethotkey_1
		Srf_Hotkey:=Srf_Hotkey
	Hotkey, %Srf_Hotkey_%, SetHotkey,off
	Srf_Hotkeys :=hk_conv(Srf_Hotkey)
	Hotkey, %Srf_Hotkeys%, SetHotkey,on
	if ErrorLevel{
		Gui, 98:Font, s8 cRed Bold 
		GuiControl, 98:Font, tip_text
		GuiControl, 98:Text, tip_text , 设置失败，请重试!
		Sleep 2500
		GuiControl, 98:Text, tip_text , 
	}else{
		Gui, 98:Font, s8 cRed Bold 
		GuiControl, 98:Font, tip_text
		GuiControl, 98:Text, tip_text , 设置成功！
		Sleep 2500
		GuiControl, 98:Text, tip_text , 
	}
Return

sethotkey_1:
	GuiControlGet, sethotkey_1,, sethotkey_1, text
	global Srf_Hotkey1:=sethotkey_1
Return

sethotkey_2:
	SG1.hide("高级设置")
	Gosub Key_
Return

ControlGui:
	if (ToolTipStyle~="i)on")
		Menu_CheckRadioItem(HMENU, 1)
	else if (ToolTipStyle~="i)off")
		Menu_CheckRadioItem(HMENU, 2)
	else if (ToolTipStyle~="i)Gdip")
		Menu_CheckRadioItem(HMENU, 3)
	if ToolTipStyle ~="i)off|on"{
		GuiControl, 98:Disable, SBA9
		GuiControl, 98:Disable, SBA12
		GuiControl, 98:Disable, SBA10
	}
	if Radius~="i)on" {
		GuiControl,98:, SBA9 , 1
	}
	if FontStyle~="i)on" {
		GuiControl,98:, SBA12 , 1
	}
	if Logo_Switch~="i)on|off" {
		GuiControl,98:, SBA13 , 1
	}
	if Gdip_Line~="i)on" {
		GuiControl,98:, SBA10 , 1
	}
	if Fix_Switch~="i)on" {
		GuiControl,98:, SBA5 , 1
	}
	if ToolTipStyle ~="i)on|off"{
		GuiControl, 98:Disable, LineColor
		GuiControl, 98:Disable, BorderColor
	}
	if Wubi_Schema~="zi"{
		GuiControl, 98:Disable, ciku1
		GuiControl, 98:Disable, ciku2
	}
	if Srf_Hotkey~="i)Ctrl"
		GuiControl,98:choose, sethotkey_1 , 1
	else if Srf_Hotkey~="i)Shift"
		GuiControl,98:choose, sethotkey_1 , 2
	else if Srf_Hotkey~="i)Alt"
		GuiControl,98:choose, sethotkey_1 , 3
	else if Srf_Hotkey~="i)LWin"
		GuiControl,98:choose, sethotkey_1 , 4
	if Initial_Mode~="i)on" {
		GuiControl,98:choose, sChoice1 , 2
	}else{
		GuiControl,98:choose, sChoice1 , 1
	}
	if Select_Enter~="i)clean" {
		GuiControl,98:choose, sChoice2 , 2
	}else{
		GuiControl,98:choose, sChoice2 , 1
	}
	if Textdirection~="i)vertical" {
		GuiControl,98:choose, sChoice3 , 2
	}else{
		GuiControl,98:choose, sChoice3 , 1
	}
	if Wubi_Schema~="i)ci" {
		GuiControl,98:choose, sChoice4 , 1
	}else if Wubi_Schema~="i)zi" {
		GuiControl,98:choose, sChoice4 , 2
	}else if Wubi_Schema~="i)chaoji" {
		GuiControl,98:choose, sChoice4 , 3
	}
	if Fix_Switch~="i)on"{
		GuiControl, 98:Enable, SBA0
	}else{
		GuiControl, 98:Disable, SBA0
	}
	if UIAccess
		GuiControl,98:, UIAccess , 1
	if Trad_Mode~="on" {
		GuiControl,98:, SBA1 , 1
	}
	if not FontType ~="i)98WB-V|98WB-P0|五笔拆字字根字体|98WB-1|98WB-3|98WB-ZG|98WB-0"
		GuiControl, 98:Disable, SBA2
	if Cut_Mode~="i)on" {
		GuiControl,98:, SBA2 , 1
	}
	if Prompt_Word~="i)on" {
		GuiControl,98:, SBA3 , 1
	}
	if Startup~="i)on" {
		GuiControl,98:, SBA4 , 1
	}
	if symb_send~="i)on" {
		GuiControl,98:, SBA6 , 1
	}
	if limit_code~="i)on" {
		GuiControl,98:, SBA7 , 1
	}
	if (symb_mode=1) {
		GuiControl,98:, SBA14 , 1
	}
	if ToolTipStyle ~="i)off|gdip" {
		GuiControl, 98:Disable, set_regulate_Hx
		GuiControl, 98:Disable, set_regulate
	}
Return

Show_Setting:
	Gui, 98:Destroy
	Gosub More_Setting
	SG1.Show("高级设置", "ycenter xcenter")
Return

EnableUIAccess(hwnd:=""){
	global
	AhkPath:=RegExReplace(A_AhkPath,".exe$",(A_AhkPath~="UIA"?".exe":"_UIA.exe"))
	If (hwnd){
		GuiControlGet, UIA_, 98:, UIAccess
		WubiIni["Settings","UIAccess"]:=UIA_, WubiIni.Save()
		if (InStr(DllCall("GetCommandLine", "Str"), "_UIA.exe")&&!UIA_){
			Try Run % StrReplace(DllCall("GetCommandLine", "Str"), "_UIA", "")
			ExitApp
		}
	}
	If (UIA_){
		if (FileExist(AhkPath)=""){
			Run *RunAs "%A_AhkPath%" "%A_ScriptDir%\Config\EnableUIAccess.ahk" EnableUIAccess
			Try Run % StrReplace(DllCall("GetCommandLine", "Str"), "_UIA", "")
			ExitApp
		}else
			Run *RunAs "%AhkPath%" /restart "%A_ScriptFullPath%"
	}else If (UIAccess&&!InStr(DllCall("GetCommandLine", "Str"), "_UIA.exe")&&FileExist(AhkPath)<>""){
		Run *RunAs "%AhkPath%" /restart "%A_ScriptFullPath%"
	}else If (UIAccess&&FileExist(AhkPath)=""){
		WubiIni["Settings","UIAccess"]:=0, WubiIni.Save()
	}
	Return
}

sChoice1:
	GuiControlGet, sChoice1,, sChoice1, text
	if sChoice1~="常规"
		Initial_Mode:=WubiIni.Settings["Initial_Mode"]:="off",WubiIni.save()
	else
		Initial_Mode:=WubiIni.Settings["Initial_Mode"]:="on",WubiIni.save()
Return

sChoice2:
	GuiControlGet, sChoice2,, sChoice2, text
	if sChoice2~="清空"
		Select_Enter:=WubiIni.Settings["Select_Enter"]:="clean",WubiIni.save()
	else
		Select_Enter:=WubiIni.Settings["Select_Enter"]:="send",WubiIni.save()
Return

sChoice3:
	GuiControlGet, sChoice3,, sChoice3, text
	if sChoice3~="横"
		Textdirection:=WubiIni.Settings["Textdirection"]:="horizontal",WubiIni.save()
	else
		Textdirection:=WubiIni.Settings["Textdirection"]:="vertical",WubiIni.save()
Return

sChoice4:
	GuiControlGet, sChoice4,, sChoice4, text
	if sChoice4~="词" {
		Wubi_Schema:=WubiIni.Settings["Wubi_Schema"]:="ci",WubiIni.save()
		Menu, Tray, Enable, 快捷造词
		Menu, Tray, Enable, 导入词库
		Menu, Tray, Enable, 导出词库
		GuiControl, 98:Enable, ciku1
		GuiControl, 98:Enable, ciku2
	}else if sChoice4~="单"{
		Wubi_Schema:=WubiIni.Settings["Wubi_Schema"]:="zi",WubiIni.save()
		Menu, Tray, Disable, 快捷造词
		Menu, Tray, Disable, 导入词库
		Menu, Tray, Disable, 导出词库
		GuiControl, 98:Disable, ciku1
		GuiControl, 98:Disable, ciku2
	}else if sChoice4~="超"{
		Wubi_Schema:=WubiIni.Settings["Wubi_Schema"]:="chaoji",WubiIni.save()
		Menu, Tray, Disable, 快捷造词
		Menu, Tray, Enable, 导入词库
		Menu, Tray, Enable, 导出词库
		GuiControl, 98:Enable, ciku1
		GuiControl, 98:Enable, ciku2
	}
Return

ciku1:
	SG1.hide("高级设置")
	GuiControlGet, Choice,, sChoice4, text
	Gosub Write_DB
	keywait, LControl, D T1
	keywait, LControl
	SG1.Show("高级设置", "ycenter xcenter")
	Gui, 98:show,NA
Return

ciku2:
	SG1.hide("高级设置")
	GuiControlGet, Choice,, sChoice4, text
	Gosub Backup_DB
	keywait, LControl, D T1
	keywait, LControl
	SG1.Show("高级设置", "ycenter xcenter")
	Gui, 98:show,NA
Return

ciku3:
	SG1.hide("高级设置")
	GuiControlGet, ck3,, ciku3, text
	bd:=""
	if ck3 {
		global bd:="En"
		Gosub Write_En
	}
	keywait, LControl, D T1
	keywait, LControl
	SG1.Show("高级设置", "ycenter xcenter")
	Gui, 98:show,NA
Return

ciku4:
	SG1.hide("高级设置")
	GuiControlGet, ck4,, ciku4, text
	bd:=""
	if ck4 {
		global bd:="En"
		Gosub Backup_En
	}
	keywait, LControl, D T1
	keywait, LControl
	SG1.Show("高级设置", "ycenter xcenter")
	Gui, 98:show,NA
Return

ciku5:
	SG1.hide("高级设置")
	GuiControlGet, ck5,, ciku5, text
	bd:=""
	if ck5 {
		global bd:="Sym"
		Gosub Write_En
	}
	keywait, LControl, D T1
	keywait, LControl
	SG1.Show("高级设置", "ycenter xcenter")
	Gui, 98:show,NA
Return

ciku6:
	SG1.hide("高级设置")
	GuiControlGet, ck6,, ciku6, text
	bd:=""
	if ck6 {
		global bd:="Sym"
		Gosub Backup_En
	}
	keywait, LControl, D T1
	keywait, LControl
	SG1.Show("高级设置", "ycenter xcenter")
	Gui, 98:show,NA
Return

SBA0:
	SG1.hide("高级设置")
	TransGui("将光标放在要选择的位置，然后按<左Ctrl键>获取坐标!`n如果不操作3s内自动获取鼠标光标当前坐标！", A_ScreenWidth/4 , A_ScreenHeight/2 , "s22","bold","cred")
	keywait, LControl, D T3
	keywait, LControl
	mousegetpos, XXX, YYY
	GuiControl,, xx, %XXX%
	GuiControl,, yy, %YYY%
	Fix_X:=WubiIni.TipStyle["Fix_X"]:=XXX
	Fix_Y:=WubiIni.TipStyle["Fix_Y"]:=YYY ,WubiIni.Save()
	Gui, Submit
	TransGui()
	SG1.Show("高级设置", "ycenter xcenter")
	Gui, 98:show,NA
Return

SBA1:
	GuiControlGet, SBA ,, SBA1, Checkbox
	if (SBA==1) {
		Trad_Mode:=WubiIni.Settings["Trad_Mode"]:="on",WubiIni.save()
		Menu, setting, Rename, 中文简体 , 中文繁体
	}else{
		Trad_Mode:=WubiIni.Settings["Trad_Mode"]:="off",WubiIni.save()
		Menu, setting, Rename, 中文繁体 , 中文简体
	}
Return

SBA2:
	GuiControlGet, SBA ,, SBA2, Checkbox
	if (SBA==1) {
		Cut_Mode:=WubiIni.Settings["Cut_Mode"]:="on",WubiIni.save()
		Menu, setting, Rename, 拆分显示	× , 拆分显示	√
	}else{
		Cut_Mode:=WubiIni.Settings["Cut_Mode"]:="off",WubiIni.save()
	}
Return

SBA3:
	GuiControlGet, SBA ,, SBA3, Checkbox
	if (SBA==1) {
		Prompt_Word:=WubiIni.Settings["Prompt_Word"]:="on",WubiIni.save()
		Menu, setting, Rename, 空码提示	× , 空码提示	√
	}else{
		Prompt_Word:=WubiIni.Settings["Prompt_Word"]:="off",WubiIni.save()
		Menu, setting, Rename, 空码提示	√ , 空码提示	×
	}
Return

SBA4:
	Gosub Startup
	Result:= cmdClipReturn(cmd_zq)
	if Result~=Startup_Name{
		Traytip,自启提示:,已设为开机自启!
	}else if not Result~=Startup_Name {
		Traytip,自启提示:,已取消开机自启!
	}else{
		Traytip,自启提示:,操作失败!
	}
Return

SBA5:
	GuiControlGet, SBA ,, SBA5, Checkbox
	if (SBA==1) {
		Fix_Switch:=WubiIni.TipStyle["Fix_Switch"]:="on",WubiIni.save()
		GuiControl, 98:Enable, SBA0
	}else{
		Fix_Switch:=WubiIni.TipStyle["Fix_Switch"]:="off",WubiIni.save()
		GuiControl, 98:Disable, SBA0
	}
Return

SBA6:
	GuiControlGet, SBA ,, SBA6, Checkbox
	if (SBA==1) {
		symb_send:=WubiIni.Settings["symb_send"]:="on",WubiIni.save()
	}else{
		symb_send:=WubiIni.Settings["symb_send"]:="off",WubiIni.save()
	}
Return

SBA7:
	GuiControlGet, SBA ,, SBA7, Checkbox
	if (SBA==1) {
		limit_code:=WubiIni.Settings["limit_code"]:="on",WubiIni.save()
		Menu, setting, Rename, 四码上屏	× , 四码上屏	√
	}else{
		limit_code:=WubiIni.Settings["limit_code"]:="off",WubiIni.save()
		Menu, setting, Rename, 四码上屏	√ , 四码上屏	×
	}
Return

SBA9:
	GuiControlGet, SBA ,, SBA9, Checkbox
	if (SBA==1) {
		Radius:=WubiIni.TipStyle["Radius"]:="on",WubiIni.save()
	}else{
		Radius:=WubiIni.TipStyle["Radius"]:="off",WubiIni.save()
	}
Return

SBA10:
	GuiControlGet, SBA ,, SBA10, Checkbox
	if (SBA==1) {
		Gdip_Line:=WubiIni.TipStyle["Gdip_Line"]:="on",WubiIni.save()
	}else{
		Gdip_Line:=WubiIni.TipStyle["Gdip_Line"]:="off",WubiIni.save()
	}
Return

SBA12:
	GuiControlGet, SBA ,, SBA12, Checkbox
	if (SBA==1) {
		FontStyle:=WubiIni.TipStyle["FontStyle"]:="on",WubiIni.save()
	}else{
		FontStyle:=WubiIni.TipStyle["FontStyle"]:="off",WubiIni.save()
	}
	Gui, houxuankuang:Destroy
	Gosub houxuankuangguicreate
Return

SBA13:
	Gosub Logo_Switch
Return

SBA14:
	GuiControlGet, SBA ,, SBA14, Checkbox
	if (SBA==1) {
		global symb_mode:=WubiIni.Settings["symb_mode"]:=1
	}else{
		global symb_mode:=WubiIni.Settings["symb_mode"]:=2
	}
	WubiIni.save()
Return

StyleMenu:
	WinGetPos, X, Y, W, H, ahk_id %HExportBtn%
	X += W // 2
	Menu_ShowAligned(HMENU, hwndgui98, X, Y, "Center", "Bottom")
	if A_ThisMenuItem~="i)gdip" {
		GuiControl, 98:Enable, SBA12
		GuiControl, 98:Enable, SBA9
		GuiControl, 98:Enable, SBA10
	}else{
		GuiControl, 98:Disable, SBA9
		GuiControl, 98:Disable, SBA10
		GuiControl, 98:Disable, SBA12
	}
	if A_ThisMenuItem~="i)ToolTip" {
		GuiControl, 98:Enable, set_regulate_Hx
	}else{
		GuiControl, 98:Disable, set_regulate_Hx
	}
Return

Export:
	Menu_CheckRadioItem(HMENU, A_ThisMenuItemPos)
	if A_ThisMenuItem~="i)gdip"{
		GuiControl, 98:Text, StyleMenu , % A_ThisMenuItem
		if not ToolTipStyle ~="i)gdip"
			Menu, Tip_Style, Rename, Gdip候选样式,Gdip候选样式	√
		if ToolTipStyle ~="i)off"
			Menu, Tip_Style, Rename, Gui候选样式	√,Gui候选样式
		else if ToolTipStyle ~="i)on"
			Menu, Tip_Style, Rename, ToolTip样式	√,ToolTip样式
		global ToolTipStyle :=WubiIni.TipStyle["ToolTipStyle"] :="Gdip"
		global FontSize :=WubiIni.TipStyle["FontSize"] :="20"
	}else if A_ThisMenuItem~="i)Gui"{
		GuiControl, 98:Text, StyleMenu , % A_ThisMenuItem
		if not ToolTipStyle ~="i)off"
			Menu, Tip_Style, Rename, Gui候选样式,Gui候选样式	√
		if ToolTipStyle ~="i)on"
			Menu, Tip_Style, Rename, ToolTip样式	√,ToolTip样式
		else if ToolTipStyle ~="i)gdip"
			Menu, Tip_Style, Rename, Gdip候选样式	√,Gdip候选样式
		global ToolTipStyle :=WubiIni.TipStyle["ToolTipStyle"] :="off"
		global FontSize :=WubiIni.TipStyle["FontSize"] :="14"
	}else if A_ThisMenuItem~="i)ToolTip"{
		GuiControl, 98:Text, StyleMenu , % A_ThisMenuItem
		if not ToolTipStyle ~="i)on"
			Menu, Tip_Style, Rename, ToolTip样式,ToolTip样式	√
		if ToolTipStyle ~="i)off"
			Menu, Tip_Style, Rename, Gui候选样式	√,Gui候选样式
		else if ToolTipStyle ~="i)gdip"
			Menu, Tip_Style, Rename, Gdip候选样式	√,Gdip候选样式
		global ToolTipStyle :=WubiIni.TipStyle["ToolTipStyle"] :="on"
		global FontSize :=WubiIni.TipStyle["FontSize"] :="14"
	}
	WubiIni.Save()
	Gui, houxuankuang:Destroy
	Gosub houxuankuangguicreate
	if ToolTipStyle ~="i)on|off"{
		GuiControl, 98:Disable, LineColor
		GuiControl, 98:Disable, BorderColor
	}else{
		GuiControl, 98:Enable, LineColor
		GuiControl, 98:Enable, BorderColor
	}
Return

About:
	GuiControlGet, About,, About, text
	FileDelete, config\ReadMe.txt
	FileAppend,%About%, config\ReadMe.txt,UTF-8
return

;gdip边框线开关（边框线开则中间的分割线消除，反之）
Gdip_Line:
	Gdip_Line :=(Gdip_Line~="off"?"on":"off")
	WubiIni.TipStyle["Gdip_Line"] :=Gdip_Line
	WubiIni.save()
Return

;中文状态下使用英文符号
En_Sym:
	symb_mode:=WubiIni.Settings["symb_mode"] :=symb_mode~=1?2:1
	WubiIni.save()
Return

;剪切板通道
Initial_Mode:
	Initial_Mode :=(Initial_Mode~="i)off"?"on":"off")
	if Initial_Mode~="i)off"
		Menu, setting, Rename, 剪切板通道	√ , 剪切板通道	×
	else
		Menu, setting, Rename, 剪切板通道	× , 剪切板通道	√
	WubiIni.Settings["Initial_Mode"] :=Initial_Mode
	WubiIni.save()
Return

;选色面板结果处理
setcolor:
	CustomColors :=[]
	loop,parse,Color_Row1,`,
	{
		StrLen(A_LoopField)=8?(A_LoopField:=A_LoopField):(A_LoopField :=RegExReplace(A_LoopField,"0x","0x0"))
		CustomColors[A_index] := SubStr(A_LoopField,1,2) SubStr(A_LoopField,7,2) SubStr(A_LoopField,5,2) SubStr(A_LoopField,3,2)
	}
	loop,parse,Color_Row2,`,
	{
		StrLen(A_LoopField)=8?(A_LoopField:=A_LoopField):(A_LoopField :=RegExReplace(A_LoopField,"0x","0x0"))
		CustomColors[A_index+8] := SubStr(A_LoopField,1,2) SubStr(A_LoopField,7,2) SubStr(A_LoopField,5,2) SubStr(A_LoopField,3,2)
	}
	if (CustomColors.Length()<>16){   ;色值区域超规默认值设置
		CustomColors :=[0x99731C,0xECEEEE,0x8B4E01,0x444444,0xE89F00,0xFAF9DE,0x2DB6F8,0xFFC90,0xD77800,0x0A1B0D,0x97D4B9,0xEFAD00,0xBF7817,0xE3F6FD,0x362B00,0xDEDEDE]
		WubiIni.CustomColors["Color_Row1"]:= "0x1C7399,0xEEEEEC,0x014E8B,0x444444,0x009FE8,0xDEF9FA,0xF8B62D,0x90FC0F"
		WubiIni.CustomColors["Color_Row2"]:= "0x0078D7,0x0D1B0A,0xB9D497,0x00ADEF,0x1778BF,0xFDF6E3,0x002B36,0xDEDEDE"
	}
	If Dlg_Color(tempColor, hwndgui98, CustomColors*){
		WubiIni.TipStyle[A_GuiControl]:=%A_GuiControl%:=SubStr(tempColor, 3)
		CreateImageButton(hwnd%A_GuiControl%,[{BC: %A_GuiControl%, 3D: 0}],5)
	}
	WubiIni.Save()
	Gui, houxuankuang:Destroy
	Gosub houxuankuangguicreate
Return

;设置页面字号输入结果处理
font_value:
	GuiControlGet, font_value,, font_value, text
	global FontSize :=WubiIni.TipStyle["FontSize"]:= font_value
	WubiIni.Save()
	Gui, houxuankuang:Destroy
	Gosub houxuankuangguicreate
Return

;设置页面字号选择结果处理
font_size:
	global FontSize :=WubiIni.TipStyle["FontSize"]:= font_size
	WubiIni.Save()
	Gui, houxuankuang:Destroy
	Gosub houxuankuangguicreate
Return

;设置页面字体选择结果处理
fonts_type:
	GuiControlGet, fonts_type_add,, FontType, text
	FontType :=WubiIni.TipStyle["FontType"]:= fonts_type_add
	GuiControl, 98:ChooseString, fonts_type, %FontType%
	if FontType ~="i)98WB-V|98WB-P0|五笔拆字字根字体|98WB-1|98WB-3|98WB-ZG|98WB-0"
		GuiControl, 98:Enable, SBA2
	else
		GuiControl, 98:Disable, SBA2
	WubiIni.Settings["Cut_Mode"] :="off"
	WubiIni.Save()
	Gui, houxuankuang:Destroy
	Gosub houxuankuangguicreate
Return

;设置页面候选数量输入结果处理
select_value:
	GuiControlGet, select_value,, select_value, text
	ListNum := WubiIni.TipStyle["ListNum"]:= select_value
	WubiIni.Save()
Return

;设置页面候选数量选择结果处理
set_select_value:
	ListNum := WubiIni.TipStyle["ListNum"]:= set_select_value
	WubiIni.Save()
Return

;ToolTip偏移距离选择结果处理
set_regulate:
	Set_Range :=WubiIni.TipStyle["Set_Range"]:= set_regulate
	WubiIni.Save()
Return

;ToolTip偏移距离输入结果处理
set_regulate_Hx:
	GuiControlGet, set_regulate_Hx,, set_regulate_Hx, text
	Set_Range :=WubiIni.TipStyle["Set_Range"]:= set_regulate_Hx
	WubiIni.Save()
Return

;开机自启动>>>批处理创建系统自启任务
Startup:
	If Startup ~="i)off" {
		Startup_path:=RegExReplace(DllCall("GetCommandLine", "Str"),"i)""( | /restart )"""," ")
		Command = schtasks /Create /TN %Startup_Name% /TR %Startup_path% /SC ONLOGON /RL HIGHEST /F
		Try {
			Run *RunAs cmd.exe /c %Command%, , Hide
			Result:= cmdClipReturn(cmd_zq)
			if Result~=Startup_Name{
				Startup :=WubiIni.Settings["Startup"]:="on", WubiIni.save()
				Menu, setting, Rename, 开机自启	× , 开机自启	√
				Traytip,自启提示:,已设为开机自启!
			}else{
				Traytip,失败提示:,设置失败，请「以管理员身份」运行后重新设置！,,2
			}
		} Catch {
			Startup :="off"
		}
	} Else {
		Command = schtasks /Delete /TN %Startup_Name% /F
		Try {
			Run *RunAs cmd.exe /c %Command%, , Hide
			Result:= cmdClipReturn(cmd_zq)
			if not Result~=Startup_Name{
				Startup :=WubiIni.Settings["Startup"]:="off", WubiIni.save()
				Menu, setting, Rename, 开机自启	√ , 开机自启	×
				Traytip,自启提示:,已取消开机自启!
			}else{
				Traytip,失败提示:,取消失败!,,2
			}
		} Catch {
			Startup :="on"
		}
	}
	WubiIni.Save()
Return

;符号顶屏
symb_send:
	symb_send :=(symb_send~="i)off"?"on":"off")
/*
	if symb_send~="i)off"
		Menu, setting, Rename, 符号顶屏	√ , 符号顶屏	×
	else
		Menu, setting, Rename, 符号顶屏	× , 符号顶屏	√
*/
	WubiIni.Settings["symb_send"] :=symb_send
	WubiIni.save()
Return

;Gdip候选框圆角
Radius:
	Radius :=(Radius~="i)off"?"on":"off")
	if Radius~="i)on"
		WubiIni.TipStyle["Gdip_Line"] :="on"
	WubiIni.TipStyle["Radius"] :=Radius
	WubiIni.save()
return

;查询转换功能开关
lookup_status:
	lookup_status :=(lookup_status~="i)off"?"on":"off")
	WubiIni.Settings["lookup_status"] :=lookup_status
	WubiIni.save()
return

;空码提示
Prompt_Word:
	Prompt_Word :=(Prompt_Word~="i)off"?"on":"off")
	if Prompt_Word ~="i)off"
		Menu, setting, Rename, 空码提示	√,空码提示	×
	else
		Menu, setting, Rename,空码提示	×,空码提示	√
	WubiIni.Settings["Prompt_Word"] :=Prompt_Word
	WubiIni.save()
return

;含词/单字选择
Wubi_Schema:
	Wubi_Schema :=(Wubi_Schema~="i)zi|chaoji"?"ci":"zi")
	if Wubi_Schema ~="i)zi"{
		Gosub Disable_Tray
		Menu, Tray, Disable, 快捷造词
	}
	else if Wubi_Schema~="i)ci|chaoji"{
		Gosub Enable_Tray
		if Wubi_Schema~="i)ci"
			Menu, Tray, Enable, 快捷造词
		else
			Menu, Tray, Disable, 快捷造词
	}
	WubiIni.Settings["Wubi_Schema"] :=Wubi_Schema
	WubiIni.save()
return

;超集方案选择
Extend_Schema:
	Wubi_Schema :=(Wubi_Schema~="i)zi|ci"&&a_FontList ~="i)98WB-V|98WB-P0|98WB-1|98WB-3|98WB-ZG|98WB-0"?"chaoji":"ci")
	if Wubi_Schema~="i)ci|chaoji"{
		Gosub Enable_Tray
		if Wubi_Schema~="i)ci"
			Menu, Tray, Enable, 快捷造词
		else
			Menu, Tray, Disable, 快捷造词
	}else{
		Gosub Disable_Tray
		Menu, Tray, Disable, 快捷造词
	}
	if (Wubi_Schema<>"chaoji"){
		Traytip,  失败提示,您的电脑可能没有安装支持超集的字体`n或多次操作无效，当前切换为「98含词」方案!
		WubiIni.Settings["Wubi_Schema"]:=Wubi_Schema
	}
	else
		WubiIni.Settings["Wubi_Schema"]:=Wubi_Schema
	WubiIni.save()
return

;字根拆分
Cut_Mode:
	Cut_Mode :=(Cut_Mode~="i)off"?"on":"off")
	if Cut_Mode~="i)off"
		Menu, setting, Rename, 拆分显示	√ , 拆分显示	×
	else
		Menu, setting, Rename, 拆分显示	× , 拆分显示	√
	WubiIni.Settings["Cut_Mode"] :=Cut_Mode
	WubiIni.save()
return

;四码上屏
limit_code:
	limit_code :=(limit_code~="i)off"?"on":"off")
	if limit_code~="i)off"
		Menu, setting, Rename, 四码上屏	√ , 四码上屏	×
	else
		Menu, setting, Rename, 四码上屏	× , 四码上屏	√
	WubiIni.Settings["limit_code"] :=limit_code
	WubiIni.save()
return

;简繁转换
Trad_Mode:
	Trad_Mode :=(Trad_Mode~="off"?"on":"off")
	if Trad_Mode~="off"
		Menu, setting, Rename, 中文繁体 , 中文简体
	else
		Menu, setting, Rename, 中文简体 , 中文繁体
	WubiIni.Settings["Trad_Mode"] :=Trad_Mode
	WubiIni.save()
return

SwitchToEngIME:
	SwitchToEngIME()
return

SwitchToChsIME:
	SwitchToChsIME()
return

;候选样式标签选择处理
ToolTipStyle:
	if ToolTipStyle ~="i)on"
	{
		ToolTip(1), ToolTip(2)
		global ToolTipStyle :="off"
		global FontSize :=WubiIni.TipStyle["FontSize"]:=16
		WubiIni.TipStyle["ToolTipStyle"]:=ToolTipStyle
		WubiIni.save()
	}
	else if ToolTipStyle ~="i)off"
	{
		Gui, houxuankuang:Hide
		global ToolTipStyle :="gdip"
		global FontSize :=WubiIni.TipStyle["FontSize"]:=20
		WubiIni.TipStyle["ToolTipStyle"]:=ToolTipStyle
		WubiIni.save()
	}
	else if ToolTipStyle ~="i)gdip"
	{
		GdipText("")
		global ToolTipStyle :="on"
		global FontSize :=WubiIni.TipStyle["FontSize"]:=14
		WubiIni.TipStyle["ToolTipStyle"]:=ToolTipStyle
		WubiIni.save()
	}
	Gui, houxuankuang:Destroy
	Gosub houxuankuangguicreate
return

;快捷造词
Add_Code:
if WinExist("造词窗口"){
	Traytip,  警告提示:,不能重复打开「快捷造词」窗口！,,2
	Return
}
else
{
	Gui, 29:Default
	Gui,29:Add, Edit, xp+0 yp+10 r10 w300 vSet_Value WantTab
	Gui, 29:Add, Button, gSave vSave, 确定
	Gui, 29:Margin, 10 10
	Gui, 29:Submit
	Gui,29:show,,造词窗口
}
return

;造词窗口关闭销毁
29GuiClose:
	Gui, 29:Destroy
	29GuiEscape:
Return

;造词保存处理
Save:
	GuiControlGet, mb_add,, Set_Value, text
	return_num :=Save_word(mb_add)
	if (return_num>0)
	{
		Gui, 29:Destroy
		TrayTip,, 写入成功%return_num%个
	}
	else
		TrayTip,, 该词条已存在或自由选词格式不正确！
return

;标签设置页
Label_show:
	Gui, 25:Default
	Gui, 25:Add, text, ,<<<<<<<标签调用以/引导！「/+标签别名」>>>>>>>
	If DB.gettable("SELECT * FROM label", Result){
		label_RowCount := Result.RowCount
		Gui, 25:Add, ListView, r%label_RowCount% w500 Grid AltSubmit -ReadOnly -Multi -LV0x10 gMyLabel hwndHLV, 标签别名|label标签名|标签说明|当前状态
		GuiControl, +Hdr, MyLabel
		loop, % Result.RowCount
		{
			LV_Add("", Result.Rows[A_index,2], Result.Rows[A_index,3],Result.Rows[A_index,4],(WubiIni.Settings[Result.Rows[A_index,3]]!=""?(WubiIni.Settings[Result.Rows[A_index,3]]):(WubiIni.TipStyle[Result.Rows[A_index,3]])))
		}
		Loop, % LV_GetCount("Column"){
			LV_ModifyCol(1,"60 Integer center")
			LV_ModifyCol(2,"220 Integer left")
			LV_ModifyCol(3,"150 Integer left")
			LV_ModifyCol(4,"100 Integer left")
		}
		CLV := New LV_Colors(HLV)
		CLV.SelectionColors(0xfecd1b)
	}
	Gui, 25:Add, Button, gRest, 重置标签页
	Gui, 25:Add, Button,x+25 gBackup_label, 标签页导出
	Gui, 25:Add, Button,x+25 gWrite_label, 标签页导入
	Gui, 25:Add, CheckBox,xm+25 yp+30 w120 vColorsOn gSubShowColors Checked, 行列色开/关
	Gui, 25:Add, Radio, x+0 yp wp Checked vAltRows gSubColors, 行色错开
	CLV.AlternateRows(0x808080, 0xFFFFFF)
	Gui, 25:Add, Radio, x+0 yp wp vAltCols gSubColors, 列色错开
	Gui, 25:Add, Radio, x+0 yp wp vColors gSubColors, 行列色错开
	Gui, 25:Add, text, xm+0 yp+25,时间标签添加时以A_开头的多个内置变量以空格隔开，中间夹中文字符也以空格隔开！
	WinSet, Redraw, , ahk_id %HLV%
	Gui, 25:show,w520, 标签设置页

return

;标签页关闭销毁处理
25GuiClose:
	25GuiEscape:
	Gui, 25:Destroy
Return

SubShowColors:
	Gui, 25:Submit, NoHide
	If (ColorsOn)
		CLV.OnMessage()
	Else
		CLV.OnMessage(False)
	GuiControl, Focus, %HLV%
Return

SubColors:
	Gui, 25:Submit, NoHide
	GuiControl, -Redraw, %HLV%
	CLV.Clear(1, 1)
	If (Colors)
		GoSub, SetColors
	If (AltRows)
		CLV.AlternateRows(0x808080, 0xFFFFFF)
	If (AltCols)
		CLV.AlternateCols(0x808080, 0xFFFFFF)
	GuiControl, +Redraw, %HLV%
Return

SetColors:
	Loop, % LV_GetCount() {
		If (A_Index & 1) {
			CLV.Cell(A_Index, 1, 0x808080, 0xFFFFFF)
			CLV.Cell(A_Index, 3, 0x808080, 0xFFFFFF)
			CLV.Cell(A_Index, 5, 0x808080, 0xFFFFFF)
		} Else {
			CLV.Cell(A_Index, 2, 0x808080, 0xFFFFFF)
			CLV.Cell(A_Index, 4, 0x808080, 0xFFFFFF)
			CLV.Cell(A_Index, 6, 0x808080, 0xFFFFFF)
		}
	}
Return

;标签导入
Write_label:
	FileSelectFile, LabelFile, 3, , 导入标签文件, Text Documents (*.txt)
	SplitPath, LabelFile, , , , filename
	If (LabelFile = ""){
		TrayTip,, 取消导入
		Return
	} Else {
		TrayTip,, 你选择了文件「%filename%」
	}
	If !filename
		Return
	MsgBox, 52, 提示, 要导入以下标签文件进行替换？`n标签格式为：标签别名+Tab+标签名+Tab+标签说明
	IfMsgBox, No
	{
		TrayTip,, 导入已取消！
		Return
	} Else {
		TrayTip,, 标签写入中，请稍后...
		Create_label(DB,LabelFile)
		tarr:=[],count :=0
		FileEncoding, UTF-8
		FileRead, label_all, %LabelFile%
		Loop, Parse, label_all, `n, `r
		{
			count++
			If (A_LoopField = "")
				Continue
			tarr:=StrSplit(A_LoopField,A_Tab,A_Tab)
			Insert_label .="(null,'" tarr[1] "','" tarr[2] "','" tarr[3] "')" ","
		}
		Insert_label :=RegExReplace(Insert_label,"\,$","")
		if DB.Exec("INSERT INTO label VALUES" Insert_label "")>0
		{
			Gosub 25GuiClose
			Gosub Label_show
			TrayTip,, 写入%count%行label标签！
		}
		else
		{
			TrayTip,, 格式不对...
			return
		}
	}
	label_all:=Insert_label:=""
Return

;标签导出
Backup_label:
	FileSelectFolder, OutFolder,,3,请选择导出后保存的位置
	if OutFolder<>
	{
		if DB.gettable("SELECT B_Key,C_Key,D_Key FROM label",Result){
			FileDelete, %OutFolder%\label.txt
			Loop % Result.RowCount
			{
				Resoure_ .=Result.Rows[A_index,1] A_tab Result.Rows[A_index,2] A_tab Result.Rows[A_index,3] "`n"
			}
			FileAppend,%Resoure_%,%OutFolder%\label.txt, UTF-8
			TrayTip,, 导出完成，文件名路径为：`n「%OutFolder%\label.txt」
			Resoure_ :=OutFolder :=""
		}
	}
Return

;标签重置为默认
Rest:
	msgbox,1, 重置页面,是否重置标签页所有内容?
	IfMsgBox OK
	{
		if DB.Exec("DROP TABLE label")>0
		{
			DB.Exec("create table label as select * from label_init")
			Gosub reload_label
		}
	}
return

;标签页右击操作
MyLabel:
	if (A_GuiEvent = "RightClick")
	{
		LV_GetText(Out_value, A_EventInfo)
		Gosub GuiRightMenu
	}
return

;标签页右击菜单
GuiRightMenu:
	Menu, CONFIG,Add,编辑标签, update_label
	Menu, CONFIG, add,
	Menu, CONFIG,Add,刷新界面, reload_label
	Menu, CONFIG, add,
	Menu, CONFIG,Add,删除标签, delete_label
	MouseGetPos, xpos, ypos
	if (A_GuiEvent = "RightClick")
	{
		LV_GetText(pos, A_EventInfo)
		x_pos :=xpos-600,y_pos :=ypos-""
	}
	label_value :=pos
	label_num :=A_EventInfo
	Menu, CONFIG, Show, %A_careX%, %A_careY%
	Menu, CONFIG, delete

return

;刷新标签页
reload_label:
	Gosub 25GuiClose
	Gosub Label_show
Return

;标签页标签更名
update_label:
	InputBox, label_name, 标签自定义, 当前的标签名为`n「%label_value%」, ,150, 150
	if (ErrorLevel=0)
	{
		if (DB.Exec(SQL:="UPDATE label SET B_Key ='" label_name "' WHERE B_Key ='" label_value "';"))>0
		{
			LV_Modify(label_num,"text",label_name)
			TrayTip,, 修改成功
		}
	}
return

;标签删除
delete_label:
	msgbox,1, 删除确认,是否删除「%label_value%」标签
	IfMsgBox OK
	{
		if (label_value ="")
			SQL :="delete from label where C_Key is null or C_Key is null"
		else
			SQL :="DELETE FROM label WHERE B_Key ='" label_value "';"
		if (DB.Exec(SQL))>0
		{
			LV_Delete(label_num)
			TrayTip,, 删除成功
		}
	}
return

;方案词库导入（超集+含词+单字）
Write_DB:
	FileSelectFile, MaBiaoFile, 3, , 导入词库, Text Documents (*.txt)
	SplitPath, MaBiaoFile, , , , filename
	If (MaBiaoFile = ""){
		TrayTip,, 取消导入
		Return
	} Else {
		TrayTip,, 你选择了文件「%filename%」
	}
	If !filename
		Return
	MsgBox, 52, 提示, 要导入以下词库进行替换？`n词库格式为：词条+Tab+编码
	IfMsgBox, No
	{
		TrayTip,, 导入已取消！
		Return
	} Else {
		Start:=A_TickCount
		TrayTip,, 词库写入中，请稍后...
		Create_Ci(DB,MaBiaoFile)
		tarr:=[],count :=0
		FileEncoding, UTF-8
		FileRead, MaBiao, %MaBiaoFile%
		Loop, Parse, MaBiao, `n, `r
		{
			count++
			If (A_LoopField = "")
				Continue
			tarr:=StrSplit(A_LoopField,A_Tab,A_Tab)
			Insert_ci .="('" tarr[1] "','" tarr[2] "')" ","
		}
		Insert_ci :=RegExReplace(Insert_ci,"\,$","")
		SQL :="INSERT INTO " (Wubi_Schema ~="i)ci"?"ci":(Wubi_Schema ~="i)zi"?"zi":"chaoji")) " VALUES " Insert_ci " "
		if DB.Exec(SQL)>0
		{
			ElapsedTime := (A_TickCount - Start)/1000
			if (ElapsedTime>60)
				timecount:=Ceil(ElapsedTime/60) "分" Mod(Ceil(ElapsedTime),60) "秒"
			Else
				timecount:=Ceil(ElapsedTime) "秒"
			TrayTip,, 写入%count%行！完成用时 %timecount%
		}
		else
		{
			TrayTip,, 格式不对...
			return
		}
	}
	MaBiao:=Insert_ci:=""
return

;词库导入（英文+symbols）
Write_En:
	FileSelectFile, MaBiaoFile, 3, , 导入词库, Text Documents (*.txt)
	SplitPath, MaBiaoFile, , , , filename
	If (MaBiaoFile = ""){
		TrayTip,, 取消导入
		Return
	} Else {
		TrayTip,, 你选择了文件「%filename%」
	}
	If !filename
		Return
	MsgBox, 52, 提示, 要导入以下词库进行替换？
	IfMsgBox, No
	{
		TrayTip,, 导入已取消！
		Return
	} Else {
		Start:=A_TickCount
		TrayTip,, 词库写入中，请稍后...
		Create_En(DB,MaBiaoFile)
		tarr:=[],count :=0
		FileEncoding, UTF-8
		FileRead, MaBiao, %MaBiaoFile%
		Loop, Parse, MaBiao, `n, `r
		{
			count++
			If (A_LoopField = "")
				Continue
			tarr:=StrSplit(A_LoopField,A_Tab,A_Tab)
			Insert_ci .="('" tarr[1] "','" tarr[2] "')" ","
		}
		Insert_ci :=RegExReplace(Insert_ci,"\,$","")
		if bd ~="i)En"?(DB.Exec("INSERT INTO encode VALUES" Insert_ci "")):(DB.Exec("INSERT INTO symbols VALUES" Insert_ci ""))>0
		{
			ElapsedTime := (A_TickCount - Start)/1000
			if (ElapsedTime>60)
				timecount:=Ceil(ElapsedTime/60) "分" Mod(Ceil(ElapsedTime),60) "秒"
			Else
				timecount:=Ceil(ElapsedTime) "秒"
			TrayTip,, 写入%count%行！完成用时 %timecount%
		}
		else
		{
			TrayTip,, 格式不对...
			return
		}
	}
	MaBiao:=Insert_ci:=""
return

;词库导出（超集+含词+单字）	
Backup_DB:
	FileSelectFolder, OutFolder,,3,请选择导出后保存的位置
	if OutFolder<>
	{
		Start_out:=A_TickCount
		SQL := "SELECT aim_chars,A_Key FROM " (Wubi_Schema ~="i)ci"?"ci":(Wubi_Schema ~="i)zi"?"zi":"chaoji")) ""
		if DB.gettable(SQL,Result){
			FileDelete, %OutFolder%\wubi98-%Wubi_Schema%.txt
			Loop % Result.RowCount
			{
				Resoure_ .=Result.Rows[A_index,1] A_tab Result.Rows[A_index,2] "`n"
			}
			ElapsedTime := (A_TickCount - Start_out)/1000
			if (ElapsedTime>60)
				timecount:=Ceil(ElapsedTime/60) "分" Mod(Ceil(ElapsedTime),60) "秒"
			Else
				timecount:=Ceil(ElapsedTime) "秒"
			FileAppend,%Resoure_%,%OutFolder%\wubi98-%Wubi_Schema%.txt, UTF-8
			Resoure_ :=OutFolder :=""
			TrayTip,, 导出完成用时 %timecount%
		}else{
			TrayTip,, 导出失败！
		}
	}
return

;词库导出（英文db+特殊符号db）	
Backup_En:
	FileSelectFolder, OutFolder,,3,请选择导出后保存的位置
	if OutFolder<>
	{
		Start_out:=A_TickCount
		if DB.gettable("SELECT aim_chars,A_Key FROM " (bd~="En"?"encode":"symbols") "",Result){
			FileDelete, %OutFolder%\wubi98-%bd%.txt
			Loop % Result.RowCount
			{
				Resoure_ .=Result.Rows[A_index,1] A_tab Result.Rows[A_index,2] "`n"
			}
			ElapsedTime := (A_TickCount - Start_out)/1000
			if (ElapsedTime>60)
				timecount:=Ceil(ElapsedTime/60) "分" Mod(Ceil(ElapsedTime),60) "秒"
			Else
				timecount:=Ceil(ElapsedTime) "秒"
			FileAppend,%Resoure_%,%OutFolder%\wubi98-%bd%.txt, UTF-8
			Resoure_ :=OutFolder :=""
		}	TrayTip,, 导出完成用时 %timecount%
	}
return

;候选横竖排
Textdirection:
	Textdirection :=(Textdirection="vertical"?"horizontal":"vertical")
	if Textdirection~="i)horizontal"
		Menu, setting, Rename, 候选竖排 , 候选横排
	else
		Menu, setting, Rename, 候选横排 , 候选竖排
	WubiIni.TipStyle["Textdirection"] :=Textdirection
	WubiIni.save()
return

;回车设定
Select_Enter:
	Select_Enter :=(Select_Enter="send"?"clean":"send")
	if Select_Enter~="i)send"
		Menu, setting, Rename, 回车清屏 , 回车上屏
	else
		Menu, setting, Rename, 回车上屏 , 回车清屏
	WubiIni.Settings["Select_Enter"] :=Select_Enter
	WubiIni.save()
return

;划词反查ToolTip窗口关闭设定
RemoveToolTip:
	SetTimer, RemoveToolTip, Off
	ToolTip(1,"")
return

;当前时间获取
get_time_now:
	StringRight, wk, A_YWeek, 2
	FormatTime, TimeVar, , tth时mm分ss秒
	FormatTime, DateVar, , ggyyyy年M月d日-ddd
	time=「%TimeVar%%A_MSec%"」
	send %time%
return

;农历日期时间获取
get_lunarDate_now:
	FormatTime, MIVar, , H
	FormatTime, RQVar, , yyyyMMdd
	lunar :=Date_GetLunarDate(RQVar)
	lunar_time :=Time_GetShichen(MIVar)
	send %lunar%%lunar_time%
return

;当前日期获取
get_date_now:
	StringRight, wk, A_YWeek, 2
	FormatTime, TimeVar, , tth时mm分ss秒
	FormatTime, DateVar, , ggyyyy年M月d日-ddd
	date=「%DateVar%｜第%wk%周」
	send %date%
return

;当前日期+时间获取
get_week_now:
	StringRight, wk, A_YWeek, 2
	FormatTime, TimeVar, , tth时mm分ss秒
	FormatTime, DateVar, , ggyyyy年M月d日-ddd
	week=「%DateVar%｜第%wk%周｜%TimeVar%%A_MSec%"」
	send %week%
return

Ime_Tips:
	If !pToken := Gdip_Startup()
	{
		MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
		Return
	}
	OnExit, TipExit
	Width := 40, Height := 40
	Gui, tips: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
	Gui, tips: Add, Edit, w%Width% h20 y300, vMeEdit
	Gui, tips: Show, NA
	hwnd1 := WinExist()
	hbm := CreateDIBSection(Width, Height)
	hdc := CreateCompatibleDC()
	obm := SelectObject(hdc, hbm)
	G := Gdip_GraphicsFromHDC(hdc)
	Gdip_SetSmoothingMode(G, 4)
	pBrush := Gdip_BrushCreateSolid("0xaa" FontColor_Code)
	Gdip_FillRoundedRectangle(G, pBrush, 0, 0, Width, Height, 10)
	Gdip_DeleteBrush(pBrush)
	Font := font_,
	GetKeyState, cps_state, CapsLock, T
	tips_text:=cps_state ~="i)D"?"A":srf_mode?"中":"英"
	If !Gdip_FontFamilyCreate(Font)
	{
		MsgBox, 48, Font error!, The font you have specified does not exist on the system
		Gui, tips: Destroy
	}
	Options = x10p y18p w80p Centre cbbffffff r4 s22 bold
	Gdip_TextToGraphics(G, tips_text, Options, Font, Width, Height)
	UpdateLayeredWindow(hwnd1, hdc, tip_pos.x, tip_pos.y, Width, Height)
	SelectObject(hdc, obm)
	DeleteObject(hbm)
	DeleteDC(hdc)
	Gdip_DeleteGraphics(G)
Return

TipExit:
	Gdip_Shutdown(pToken)
	ExitApp
Return

