改名是准备以后加一个切换其他输入法的选项,方便不会小鹤输入法的人使用,独乐乐不如众乐乐
脚本说明:
- 用ahk 写的一个简单输入法,自带的码表是小鹤音形
- 适合使用形码,无数字键候选功能
- shift 切换中英文
- ; 上屏第二码
- space 上屏文字,无候选词则上屏编码
- enter 上屏编码
- 输入状态下 shift 切换中英文并上屏编码
- 输入状态下 esc 清空编码并切换为英文
- 使用 unicode 编码, 这样在 qq 输入框输出的字符好像会好看一点,支持更多符号
- 部分过程封装为函数,看起来应该显得更简洁, 可能吧…
- 加了个托盘图标,三十秒钟画出来,丑是肯定的
- 文章末尾有下载连接
;>> 小鹤拼音输入法ahk版本
;>> input 0.2
;>> AHKVerion: Unicode 64bit
;>> Author: fuwt
;>> date: 2017-05-2
;>> 分号选择第二码
;>> shift切换中英文
sendmode input
SetWorkingDir %A_ScriptDir%
#SingleInstance, force
FileEncoding UTF-8
CoordMode, Caret, Screen
CoordMode, Mouse, Screen
global dic := {}
global KeyText
global StrText
global key
global symbolcount := {}
GroupAdd, EN, ahk_class
GroupAdd, EN, ahk_class Vim
GroupAdd, EN, ahk_class TTOTAL_CMD
GroupAdd, EN, ahk_class ConsoleWindowClass
GroupAdd, EN, ahk_class Photoshop
GroupAdd, EN, ahk_class AfxMDIFrame140u
; global box := 0 ;box等于0不显示候选框
ReadDic("dic_flapy")
ReadDic("dic_user")
Gui, Margin, 10, 3
Gui, font, s13
Gui, +ToolWindow -Caption +AlwaysOnTop +LastFound -DPIScale
Gui, color, ffffff
Gui, Add, text, cblue r0.8 vKeyText,test font
; Gui, Add, text, w300 h1 +0x4, split
Gui, font, s16 w700
Gui, Add, text, r1.2 vStrText, test font
UpdateIcon()
loop, 26
{
thisHotkey := Chr(A_Index + 96)
Hotkey, ~%thisHotkey%, flapy
}
Loop
{
WinWaitActive, ahk_group EN
switch(0)
ActiveHwnd := WinExist("A")
WinWaitNotActive, ahk_id %ActiveHwnd%
}
return
flapy:
key .= StrReplace(A_ThisHotkey, "~")
; key .= A_ThisHotkey
ShowBox()
if (dic[key] && InStr(dic[key],"|") < 1 && StrLen(key) = 4)
SendStr()
else if (StrLen(key) = 5 && dic[SubStr(key,1,4)])
{
str := StrSplit(dic[SubStr(key,1,4)], "|")
send {bs 5}
Send % str[1] StrReplace(A_ThisHotkey,"~")
key := ""
goto flapy
}
return
shift::
Suspend Toggle
UpdateIcon()
key := ""
Gui Hide
return
; 本人使用CapsLock热键, 后面两个命令避免弹出候选框
~CapsLock::
Suspend on
return
CapsLock Up::
Suspend off
return
~!s::
~rbutton::
Suspend on
sleep 350
Suspend off
return
; 标点自动上屏文字
,::SendSymbol(",")
?::SendSymbol("?")
!::SendSymbol("!")
`;::SendSymbol(";")
-::SendSymbol("—")
^::SendSymbol("……")
~::SendSymbol("~")
(::SendSymbol("(")
)::SendSymbol(")")
[::SendSymbol("〔")
]::SendSymbol("〕")
<::SendSymbol("《") >::SendSymbol("》")
'::DoubleSymbol("‘","’")
"::DoubleSymbol("“","”")
; 特殊处理几个符号
#UseHook on ; 冒号不知道怎么加$,直接UseHook,避免热键触发本身
/::
if (!StrLen(dic[key]) && StrLen(Key))
{
key .= "/"
ShowBox()
send /
}
else
SendSymbol("、")
return
:::
if (!StrLen(dic[key]) && StrLen(Key) || key="http" || key="https" || key="file" || key="ftp")
{
key .= ":"
ShowBox()
send :
}
else
SendSymbol(":")
return
.::
if (!StrLen(dic[key]) && StrLen(Key) || key="www" || key="baidu" || key="google" || key="chn")
{
key .= "."
ShowBox()
send .
}
else
SendSymbol("。")
return
#UseHook off
#If StrLen(key)
space::
SendStr()
return
`;::
SendStr(2)
return
~@::
~0::
~1::
~2::
~3::
~4::
~5::
~6::
~7::
~8::
~9::
key .= StrReplace(A_ThisHotkey,"~")
ShowBox()
return
esc::
CleanCode()
Suspend on
UpdateIcon()
return
~Backspace::
key := SubStr(key, 1, StrLen(key) - 1)
ShowBox()
if (StrLen(key)=0)
Gui Hide
return
enter::
SendCode()
return
shift::
SendCode()
Suspend on
UpdateIcon()
return
#If StrLen(key)=0
; [::send 「」『』[]〔〕【】
; <::send 《》〈〉
#if WinActive("ahk_group EN")
~esc:: switch(0)
#if
ShowBox(){
if (box = 0)
return
GuiControl text, KeyText, % key
GuiControl Move, KeyText, % "w" StrLen(key)*13
GuiControl text, StrText, % dic[key]
posx := posY := 0
if(A_CaretX){
posX := A_CaretX + 10
posY := A_CaretY + 20
}
Gui show, AutoSize NA x%posX% y%posY%
}
ReadDic(dictionary){
Loop, Read, % dictionary
{
line := StrSplit(A_LoopReadLine,A_Tab)
if (StrLen(dic[line[2]]))
dic[line[2]] .= "|" . line[1]
else
dic[line[2]] := line[1]
}
}
SendCode(){
key := ""
Gui Hide
}
CleanCode(){
DllCall("SendMessage", UInt, WinActive("A"), UInt, 80, UInt, 1, UInt, DllCall("LoadKeyboardLayout", Str,, UInt, 1))
i := StrLen(key)
send {bs %i%}
key := ""
Gui Hide
}
SendStr(n:=1){
if (StrLen(dic[key]))
{
if (InStr(dic[key], "|"))
{
str := StrSplit(dic[key], "|")
i := StrLen(key)
send {bs %i%}
clipsave := clipboardall
clipboard := str[n]
Send % clipboard
clipboard := clipsave
clipsave := ""
}
else{
i := StrLen(key)
send {bs %i%}
clipsave := clipboardall
clipboard := dic[key]
send % clipboard
clipboard := clipsave
clipsave := ""
}
}
else
SendCode()
key := ""
Gui Hide
}
SendSymbol(symbol := ""){
SendStr()
send % symbol
}
DoubleSymbol(a := "", b := ""){
SendStr()
if (!symbolcount[A_ThisHotkey])
symbolcount[A_ThisHotkey] := 0
symbolcount[A_ThisHotkey] += 1
if (mod(symbolcount[A_ThisHotkey],2) = 0)
; send {Right}
send % b
else
; send % a b "{left}"
send % a
}
UpdateIcon(){
if (A_IsSuspended = 1)
menu tray, icon, ico\eng.ico,,1
else
menu tray, icon, ico\chi.ico,,1
}
switch(i := "A"){
if (i = 1)
Suspend off
else if (i = 0)
Suspend on
else
Suspend Toggle
UpdateIcon()
key := ""
Gui Hide
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


可以,可以终于看懂了
链接失效了,建议放github或gitee更好
链接失效了
链接:https://pan.baidu.com/s/1t0TsW2oR1H1eO6vWDRQGOg
提取码:jt2o
coding仿佛是不能用了,文章也不能修改,我重新在百度网盘传了一份完整版。
这 代码 没有 用 呀
想找这种完整的, 可是原址下不到了, 哪里能下到?
链接:https://pan.baidu.com/s/1t0TsW2oR1H1eO6vWDRQGOg
提取码:jt2o
coding仿佛是不能用了,文章也不能修改,我重新在百度网盘传了一份完整版。
头痛的是我好像只有H2和L1的,竟然还一个V2,有点混乱啊 ➡
用好一个版本就好
作者很有创意,我已经处理好了五笔的码表,配合这个脚本来作为默认的输入法使用了。以下根据个人习惯对原来的代码作了一点点简单的修改。
;添加单引号作为第三候选词上屏的按键
'::
if InStr(dic[key], "|")
str := StrSplit(dic[key], "|")
Send, % str[3]
key := ""
Gui, Hide
return
;中文标点添加了几个符号
#If StrLen(key)=0
.::Send, 。
?::Send, ?
!::Send, !
,::Send, ,
/::Send, 、
\::Send, 、
:::Send, :
`;::Send, ;
_::Send, ——
^::Send, ……
::Send, 》
;候选窗格式部分添加如下一行,用来解决第二、第三以及更多的候选词显示不全的问题
GuiControl, Move, StrText, % "w" StrLen(key)*100
感觉这个程序放在U盘里比较好,这样到哪里都可以用自己习惯的输入法了。另外挂载多个词库的功能非常棒。
你这个想法真是不错!
支持站长!!
感觉你这个想法不错!