; Lshift键切换模式
;#if symb_send ~="off"||symb_send ~="on"&&!srf_all_input
Shift::
	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\wubi86.icl
		}
		Menu, Tray, Icon, ..\config\wubi86.icl,9,1
		SetCapsLockState , off
		Gosub srf_value_off
		srf_for_select_Array :=[], select_sym:=0
		WubiIni.Settings["IMEmode"]:="on"
		WubiIni.save()
	}
	else
	{
		Gosub Write_Pos
		GuiControl,3:, Pics,*Icon19 ..\config\wubi86.icl
		;Gui, 3:Show, NA x%Logo_X% y%Logo_Y%,sign_wb
		Menu, Tray, Icon, ..\config\wubi86.icl,12,1
		sendinput % RegExReplace(srf_all_input,"^z\'","")
		SetCapsLockState , off
		Gosub srf_value_off
		srf_for_select_Array :=[], select_sym:=0
		WubiIni.Settings["IMEmode"]:="off"
		WubiIni.save()
	}
Return
;#if

#if srf_mode&&!GetKeyState("CapsLock", "T")
;{{{ a-z定义
	a::
	b::
	c::
	d::
	e::
	f::
	g::
	h::
	i::
	j::
	k::
	l::
	m::
	n::
	o::
	p::
	q::
	r::
	s::
	t::
	u::
	v::
	w::
	x::
	y::
	z::
	srf_all_input .= A_ThisHotkey, waitnum:=numberfg:=select_sym:=0,num_for_select_arrays:=[], num__:=""
	gosub srf_tooltip_fanye
return

#If srf_mode&&(InStr(srf_all_Input,"/"))&&select_sym<>1
	1::
	2::
	3::
	4::
	5::
	6::
	7::
	8::
	9::
	0::
	Numpad1::
	Numpad2::
	Numpad3::
	Numpad4::
	Numpad5::
	Numpad6::
	Numpad7::
	Numpad8::
	Numpad9::
	Numpad0::
	srf_all_input .= A_ThisHotkey, select_sym:=0
	gosub srf_tooltip_fanye
Return
#If

#If srf_mode&&lookup_status ~="on"&&srf_for_select_Array.Length()<1
	1::
	2::
	3::
	4::
	5::
	6::
	7::
	8::
	9::
	0::
	Numpad0::
	Numpad1::
	Numpad2::
	Numpad3::
	Numpad4::
	Numpad5::
	Numpad6::
	Numpad7::
	Numpad8::
	Numpad9::
	NumpadDot::
	.::
	,::
	srf_all_Input .= A_ThisHotkey, num__:=A_ThisHotkey
	Gosub srf_tooltip 
Return
#If

#if num_for_select_arrays0&&srf_mode
	space::num_selects(1)
	`;::num_selects(2)
	'::num_selects(3)
	[::num_selects(4)
	]::num_selects(5)
#if

#if srf_mode&&!srf_all_input
	Numpad1::
	1::
		send {1}
		num__:=A_ThisHotkey
	Return
	Numpad2::
	2::
		send {2}
		num__:=A_ThisHotkey
	Return
	Numpad3::
	3::
		send {3}
		num__:=A_ThisHotkey
	Return
	Numpad4::
	4::
		send {4}
		num__:=A_ThisHotkey
	Return
	Numpad5::
	5::
		send {5}
		num__:=A_ThisHotkey
	Return
	Numpad6::
	6::
		send {6}
		num__:=A_ThisHotkey
	Return
	Numpad7::
	7::
		send {7}
		num__:=A_ThisHotkey
	Return
	Numpad8::
	8::
		send {8}
		num__:=A_ThisHotkey
	Return
	Numpad9::
	9::
		send {9}
		num__:=A_ThisHotkey
	Return
	Numpad0::
	0::
		send {0}
		num__:=A_ThisHotkey
	Return

	;快速多行注释
	^/::
		ClipSaved:=ClipboardAll
		send ^x
		send {/}{*}{`n 2}{*}{/}{up}
		send ^v
		Clipboard:=ClipSaved, ClipSaved:=""
	Return

	'::send {‘}{’}{left}
	`;::send {；}
	,::send {，}
	\::send {、}
	[::send {「}
	]::send {」}
	+[::send {『}
	+]::send {』}
	+,::send {《}
	+.::send {》}
	+/::send {？}
	^+w::run,http://98wb.ys168.com/   ;ctrl+Shift+w
	^q::run, ..\config\码元图.jpg    ;cltr+q键打开码元
	+1::send {！}
	+2::send {@}
	+3::send {#}
	+4::send {￥}
	+6::send {…}{…}
	+7::send {&}
	+8::send {*}
	+9::send {（}
	+0::send {）}
	+-::send {—}{—}
	+;::send {：}
	+'::send {“}{”}{left}
	.::
		if num__~="\d"
			send {.}
		else
			send {。}
		num__:=""
	Return
	CapsLock::
		GetKeyState, CL_State, CapsLock, T
		if CL_State ~="U"{
			SetCapsLockState , on
			Menu, Tray, Icon, ..\config\wubi86.icl,21,1
			GuiControl,3:, Pics,*Icon17 ..\config\wubi86.icl
		}
		else
		{
			SetCapsLockState , off
			Menu, Tray, Icon, ..\config\wubi86.icl,9,1
			GuiControl,3:, Pics,*Icon1 ..\config\wubi86.icl
		}
		select_sym:=0
	Return
	`::
		srf_all_Input .= A_ThisHotkey, select_sym:=0
		;[ ` ]引导常用符号自定义，Sym_Array多维数组首位置空，其它按顺序排列，增加的话 直接在数组里添加格式 >>  ,["符号"]
		Sym_Array :=[[""],["·"],["～"],["☯"],["•"],["℃"],["‰"],["℉"],["％"],["※"],["●"],["○"],["★"],["☆"],["©"],["ㄓ"]]
		gosub srf_tooltip_fanye
	Return
	/::
		srf_all_Input .= A_ThisHotkey, select_sym:=0
		;[ / ]引导常用符号自定义，Sym_Array多维数组首位置空，其它按顺序排列，增加的话 直接在数组里添加格式 >>  ,["符号"]
		Sym_Array_1 :=[[""],["？"],["、"]]
		gosub srf_tooltip_fanye
	Return
	~::
		srf_all_Input .= A_ThisHotkey, select_sym:=0
		gosub srf_tooltip_fanye 
	Return
return
#if

#if !srf_mode&&!srf_all_input
	+'::send {"}{"}{left}

	;快速多行注释
	^/::
		ClipSaved:=ClipboardAll
		send ^x
		send {/}{*}{`n 2}{*}{/}{up}
		send ^v
		Clipboard:=ClipSaved, ClipSaved:=""
	Return

	CapsLock::
		GetKeyState, CL_State, CapsLock, T
		if CL_State ~="D"{
			SetCapsLockState , off
			Menu, Tray, Icon, ..\config\wubi86.icl,12,1
			GuiControl,3:, Pics,*Icon19 ..\config\wubi86.icl
		}
		else
		{
			SetCapsLockState , on
			Menu, Tray, Icon, ..\config\wubi86.icl,21,1
			GuiControl,3:, Pics,*Icon17 ..\config\wubi86.icl
		}
		select_sym:=0
	Return
return
#if

#if srf_all_input
	CapsLock::
		GetKeyState, CL_State, CapsLock, T
		if CL_State ~="U"{
			;sendinput % StringUpper(srf_all_input)    ;去掉行首分号启用按下CapsLock上屏大写英文
			Gosub srf_value_off
			srf_for_select_Array :=[]
			SetCapsLockState , on
			Menu, Tray, Icon, ..\config\wubi86.icl,21,1
			GuiControl,3:, Pics,*Icon17 ..\config\wubi86.icl
		}
		else
			GuiControl,3:, Pics,*Icon1 ..\config\wubi86.icl
		select_sym:=0
	Return
	;快速选词快捷键
	Space::
	1::
		srf_select(1)
	Return
	`;::
	2::
		srf_select(2)
	Return
	'::
	3::
		srf_select(3)
	Return
	4::srf_select(4)
	5::srf_select(5)
	6::srf_select(6)
	7::srf_select(7)
	8::srf_select(8)
	9::srf_select(9)
	0::srf_select(10)
	;快速删词快捷键「Ctrl+Alt+{1-0}」
	^!1::Delete_Word(1)
	^!2::Delete_Word(2)
	^!3::Delete_Word(3)
	^!4::Delete_Word(4)
	^!5::Delete_Word(5)
	^!6::Delete_Word(6)
	^!7::Delete_Word(7)
	^!8::Delete_Word(8)
	^!9::Delete_Word(9)
	^!0::Delete_Word(10)
	;快速置顶「Ctrl+{1-0}」
	^1::set_top(1),srf_select(1)
	^2::set_top(2),srf_select(2)
	^3::set_top(3),srf_select(3)
	^4::set_top(4),srf_select(4)
	^5::set_top(5),srf_select(5)
	^6::set_top(6),srf_select(6)
	^7::set_top(7),srf_select(7)
	^8::set_top(8),srf_select(8)
	^9::set_top(9),srf_select(9)
	^0::set_top(10),srf_select(10)
	-::
		Gosub lessWait
	Return
	=::
		Gosub MoreWait
	Return
	Esc::
		Gosub srf_value_off
		srf_for_select_Array :=[], select_sym:=0
	Return
	BackSpace::
		srf_all_Input:=SubStr(RegExReplace(srf_all_Input,"'",""), 1, -1), select_sym:=waitnum:=0
		If strlen(srf_all_Input)<1
		{
			Gosub srf_value_off
			srf_for_select_Array :=[]
		}
		Else
			Gosub srf_tooltip_fanye
	Return

	Enter::
	NumpadEnter::
		if Select_Enter~="send"
		{
			sendinput % RegExReplace(srf_all_input,"^z\'","")
			Gosub srf_value_off
			srf_for_select_Array :=[]
		}
		else
		{
			Gosub srf_value_off
			srf_for_select_Array :=[]
		}
		select_sym:=0
	Return
#if

#if srf_mode&&srf_all_input&&srf_for_select_Array.Length()>0&&symb_send ~="on"
{
	+1::
		srf_select(1)
		send {！}
	Return
	+2::
		srf_select(1)
		send {@}
	Return
	+3::
		srf_select(1)
		send {#}
	Return
	+4::
		srf_select(1)
		send {$}
	Return

	+5::
		srf_select(1)
		send {`%}
	Return

	+6::
		srf_select(1)
		send {…}{…}
	Return
	+7::
		srf_select(1)
		send {&}
	Return
	+8::
		srf_select(1)
		send {*}
	Return
	+9::
		srf_select(1)
		send {（}
	Return
	+0::
		srf_select(1)
		send {）}
	Return
	+-::
		srf_select(1)
		send {—}{—}
	Return
	++::
		srf_select(1)
		send {+}
	Return
	+[::
		srf_select(1)
		send {「}
	Return
	+]::
		srf_select(1)
		send {」}
	Return
	+`;::
		srf_select(1)
		send {：}
	Return
	+'::
		srf_select(1)
		send {“}{”}{left}
	Return
	+,::
		srf_select(1)
		send {《}
	Return
	+.::
		srf_select(1)
		send {》}
	Return
	+/::
		srf_select(1)
		send {？}
	Return
	,::
		srf_select(1)
		send {，}
	Return
	.::
		srf_select(1)
		send {。}
	Return
	/::
		srf_select(1)
		send {、}
	Return
	[::
		srf_select(1)
		send {「}
	Return
	]::
		srf_select(1)
		send {」}
	Return
	+\::
		srf_select(1)
		send {·}
	Return
	\::
		srf_select(1)
		send {、}
	Return
	`::
		srf_select(1)
		send {-}{-}{-}{>}
	Return
}
#if

;{{{ 脚本修改自动reload
#if WinActive("ahk_class i)Notepad") or WinActive("ahk_class i)EmEditor*") or WinActive("ahk_class i)Notepad*") or WinActive("ahk_class i)Chrome_WidgetWin*")
	~^s::
		WinGetTitle, title4, ahk_class i)Chrome_WidgetWin*
		WinGetTitle, title1, ahk_class i)EmEditor*
		WinGetTitle, title2, ahk_class i)Notepad*
		WinGetTitle, title3, ahk_class i)Notepad
		if (title1~="i)\.ahk"||title2~="i)\.ahk"||title3~="i)\.ahk"||title4~="i)\.ahk")
			Gosub OnReload
	return
#If
;}}}

/*
;************两组挂起快捷键已注释，去掉多行注释符即可启用*********************

^>RAlt::
	Suspend
	if A_IsSuspended =1
		Traytip,  提示:,已切换至挂起状态！
	else if A_IsSuspended =0
		Traytip,  提示:,已切换至启用状态！
return

!>RCtrl::
	Suspend
	if A_IsSuspended =1
		Traytip,  提示:,已切换至挂起状态！
	else if A_IsSuspended =0
		Traytip,  提示:,已切换至启用状态！
return

*/


!q::
	send ^c
	sleep 100
	select_for_code = %clipboard%
	select_for_code :=RegExReplace(select_for_code, "\d+|[a-zA-Z]{1,}|\s+|`n", "")
	select_for_code_result := Tip_rvlk(select_for_code)
	if (a_FontList ~="五笔拆字字根字体|五笔字根字体"&&FontType ~="五笔拆字字根字体|五笔字根字体")          ;判断是否安装「折分显示的字体」没安装的话只显示编码
	{
		srf_for_select_for_tooltip := select_for_code_result
		Caret:=GetCaretPos(), hasCaretPos:=1
		ToolTip(1, "", "Q1 B" BgColor " T" FontColor_Code " S" FontSize " F" FontType)
		ToolTip(1, srf_for_select_for_tooltip, "x" Caret.x " y" Caret.y+Caret.h)
	}
	else          ;判断是否安装「折分显示的字体」没安装的话只显示编码
	{
		Loop, Parse, select_for_code_result, `n
		{
			select_for_code_result_1 :=RegExReplace(A_LoopField, "〔.+\〕|^`n", "")
			srf_for_select_for_tooltip .=select_for_code_result_1 . "`n"
		}
		Caret:=GetCaretPos(), hasCaretPos:=1
		ToolTip(1, "", "Q1 B" BgColor " T" FontColor_Code " S" FontSize " F" FontType)
		ToolTip(1, srf_for_select_for_tooltip, "x" Caret.x " y" Caret.y+Caret.h)
		srf_for_select_for_tooltip :=
	}
	SetTimer, RemoveToolTip, 3200
	clipboard = 
return

^esc::
	Gosub OnExit
return

^CapsLock::
if WinExist("造词窗口"){
	Traytip,  警告提示:,不能重复打开「快捷造词」窗口！,,2
	Return
}
else
{
	if Wubi_Schema~="ci"
		gosub Add_Code
	else
		Traytip,,造词仅在86含词方案有效！
}
return

vk5d::return ; 屏蔽键盘上的菜单右键
