用autohotkey打造的分音输入法原代码

#Include Class_SQLiteDB.ahk

;-------------------------------打开数据库
DBFileName := A_ScriptDir . "\fenyin-xy.DB"
db:=sqlitedb()
sleep(1000)
 If !DB.OpenDB(DBFileName) 
 {       
    MsgBox("Msg:`t" . DB.ErrorMsg . "`nCode:`t" . DB.ErrorCode, "SQLite Error", 16)
    exitapp
}

;-------------------------------初始化变量/数组
global zi:=[]
global bianma:=[]
global changyong:=[]
global zhongwen :="1"
global result:=""
global ma:=""

global shengmu:= array2D(30,30)
global yunmu:= array2D(30,30)
global yinjie:= array2D(30,30)
loop 30
{
    i:=a_index
    loop 30
    {
    shengmu[i,a_index]:=""
    yunmu[i,a_index]:=""
    yinjie[i,a_index]:=""
    }
}


;-------------------------------按shift切换中英文
shift::
{
    global zhongwen:=!zhongwen
    if(zhongwen)
    {
        trayseticon("中.ico")
        }
    else{
        trayseticon("英.ico")
    }
}
trayseticon("中.ico")

#hotif zhongwen
;--------------------------------------------------处理输入字母
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::
{
    global result:=""
    global neirong:=""
    global ma:=ma . a_thishotkey     
    global zi:=[]
    global zishu:=0
   
    zit:=[]
    cit:=[]
    zit:=souzi(ma)
    Loop zit.Length
    {
        zishu:=A_Index
        if (zishu>9)
           break
        neirong:= neirong . " " . zishu  . "." .  zit[zishu]                  
        zi.Push(zit[zishu])
    }
    if strlen(ma)>1 
    {
        cit:=souci(ma)
        if (cit.length>0)
            neirong:= neirong . "`n"
        Loop cit.Length
        {
            if (A_Index+zishu>9)
                 break
            neirong:= neirong . " " . A_Index+zishu   . "." .  cit[A_Index]                  
            zi.Push(cit[A_Index])
        }
    }
    xianshi(ma . "`n" . StrReplace(neirong,"-",""))
    
    if (zi.Length=1)
    {
    
        shuchu:=zi[1]
        if (instr(shuchu,"-")>0)
            shuchu:=substr(shuchu,1,instr(shuchu,"-")-1)  
        send(shuchu)
        ma:=""
        tooltip()
        neirong:=""
    } 
}

;--------------------------------------------------按空格
space::
1::
2::
3::
4::
5::
6::
7::
8::
9::
{
    global xuan:= a_thishotkey   
    global ma  
    
 
    
    if ( zi.length>0)
    {
        if (xuan="space"){        
            xuan:="1"
        }
        if (xuan <= zi.length)
        {
            shuchu:=zi[xuan]
            if (instr(shuchu,"-")>0)
                shuchu:=substr(shuchu,1,instr(shuchu,"-")-1)
            send(shuchu) 
            ma:=""
            tooltip()
            neirong:=""
            global zi:=[]
        }

    }
    else
    {
        if (a_thishotkey="space"){
            key:=" "
        }
        else{
            key:=a_thishotkey
        }<

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值