;~ 作者:无关风月 #SingleInstance Force Gui Destroy search_list_ori := "清华大学|北京大学|南京大学|上海交通大学|武汉大学|西安交通大学" global ser,search_list_new Gui Add, Edit, x87 y54 w120 vser gStartSearch HwndMyEdit DllCall("user32\SendMessage", "Ptr", MyEdit, "uint", 0x1501, "int", 1, "Str", "输入 ""交通"" 测试", "int") Gui Add, DropDownList, x268 y51 w120 vlist_choice , %search_list_ori% ;~ Gui Add, ComboBox, x162 y98 w124 vser gStartSearch Choose1, %search_list_ori% Gui Show, w493 h165, 精炼搜索 Sleep,300 ControlFocus, Edit1, 精炼搜索 Control, ShowDropDown, , ComboBox1, 精炼搜索 Return GuiEscape: GuiClose: Gui Destroy return StartSearch: SetTimer, Search, -100 ;这里设置转到translate的延时 避免正在输入过程中一直查询,也可以设置为负值,表示实时查询 Return Search: Gui, Submit, NoHide Control, ShowDropDown, , ComboBox1, 精炼搜索 search_list_new := "" Loop,Parse,search_list_ori,| { pinying_word := zh2py(A_LoopField) if (keyValueFind(A_LoopField,ser) or keyValueFind(pinying_word,ser)) { search_list_new := search_list_new . "|" . A_LoopField ; 一定要以|开头,这才时替换列表,否则默认为增加列表 } } ;~ MsgBox % search_list_new if (search_list_new = "") GuiControl,,list_choice,|无匹配项 else GuiControl,,list_choice,%search_list_new% return keyValueFind(haystack,needle) { findSign:=1 needleArray := StrSplit(needle, " ") Loop % needleArray.MaxIndex() { if(!InStr(haystack, needleArray[A_Index], false)) { findSign:=0 break } } return findSign } ;~ MsgBox, % zh2py("二级汉字 -> 廿") ; 输出“EJHZ -> N” ;~ Return ; 从 php 转换而来的 (http://www.sjyhome.com/php/201311170606.html) zh2py(str) { ; 根据汉字区位表,(http://www.mytju.com/classcode/tools/QuWeiMa_FullList.asp) ; 我们可以看到从16-55区之间是按拼音字母排序的,所以我们只需要判断某个汉字的区位码就可以得知它的拼音首字母. ; 区位表第一部份,按拼音字母排序的. ; 16区-55区 /* 'A'=>0xB0A1, 'B'=>0xB0C5, 'C'=>0xB2C1, 'D'=>0xB4EE, 'E'=>0xB6EA, 'F'=>0xB7A2, 'G'=>0xB8C1,'H'=>0xB9FE, 'J'=>0xBBF7, 'K'=>0xBFA6, 'L'=>0xC0AC, 'M'=>0xC2E8, 'N'=>0xC4C3, 'O'=>0xC5B6, 'P'=>0xC5BE,'Q'=>0xC6DA, 'R'=>0xC8BB, 'S'=>0xC8F6, 'T'=>0xCBFA, 'W'=>0xCDDA, 'X'=>0xCEF4, 'Y'=>0xD1B9, 'Z'=>0xD4D1 */ static FirstTable := [ 0xB0C5, 0xB2C1, 0xB4EE, 0xB6EA, 0xB7A2, 0xB8C1, 0xB9FE, 0xBBF7, 0xBFA6, 0xC0AC, 0xC2E8, 0xC4C3, 0xC5B6, 0xC5BE, 0xC6DA, 0xC8BB, 0xC8F6, 0xCBFA, 0xCDDA, 0xCEF4, 0xD1B9, 0xD4D1, 0xD7FA ] static FirstLetter := StrSplit("ABCDEFGHJKLMNOPQRSTWXYZ") ; 区位表第二部份,不规则的,下面的字母是每个区里面对应字的拼音首字母.从网上查询整理出来的,可能会有部份错误. ; 56区-87区 static SecondTable := [ StrSplit("CJWGNSPGCGNEGYPBTYYZDXYKYGTZJNMJQMBSGZSCYJSYYFPGKBZGYDYWJKGKLJSWKPJQHYJWRDZLSYMRYPYWWCCKZNKYYG") , StrSplit("TTNGJEYKKZYTCJNMCYLQLYPYSFQRPZSLWBTGKJFYXJWZLTBNCXJJJJTXDTTSQZYCDXXHGCKBPHFFSSTYBGMXLPBYLLBHLX") , StrSplit("SMZMYJHSOJNGHDZQYKLGJHSGQZHXQGKXZZWYSCSCJXYEYXADZPMDSSMZJZQJYZCJJFWQJBDZBXGZNZCPWHWXHQKMWFBPBY") , StrSplit("DTJZZKXHYLYGXFPTYJYYZPSZLFCHMQSHGMXXSXJYQDCSBBQBEFSJYHWWGZKPYLQBGLDLCDTNMAYDDKSSNGYCSGXLYZAYPN") , StrSplit("PTSDKDYLHGYMYLCXPYCJNDQJWXQXFYYFJLEJPZ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LSLYGKDZPZXJYYZLWCXSZFGWYYDLYHCLJS") , StrSplit("CMBJHBLYZLYCBLYDPDQYSXQZBYTDKYXJYYCNRJMPDJGKLCLJBCTBJDDBBLBLCZQRPYXJCJLZCSHLTOLJNMDDDLNGKATHQH") , StrSplit("JHYKHEZNMSHRPHQQJCHGMFPRXHJGDYCHGHLYRZQLCYQJNZSQTKQJYMSZSWLCFQQQXYFGGYPTQWLMCRNFKKFSYYLQBMQAMM") , StrSplit("MYXCTPSHCPTXXZZSMPHPSHMCLMLDQFYQXSZYJDJJZZHQPDSZGLSTJBCKBXYQZJSGPSXQZQZRQTBDKYXZKHHGFLBCSMDLDG") , StrSplit("DZDBLZYYCXNNCSYBZBFGLZZXSWMSCCMQNJQSBDQSJTXXMBLTXZCLZSHZCXRQJGJYLXZFJPHYMZQQYDFQJJLZZNZJCDGZYG") , StrSplit("CTXMZYSCTLKPHTXHTLBJXJLXSCDQXCBBTJFQZFSLTJBTKQBXXJJLJCHCZDBZJDCZJDCPRNPQCJPFCZLCLZXZDMXMPHJSGZ") , StrSplit("GSZZQLYLWTJPFSYASMCJBTZYYCWMYTZSJJLJCQLWZMALBXYFBPNLSFHTGJWEJJXXGLLJSTGSHJQLZFKCGNNNSZFDEQFHBS") , StrSplit("AQTGYLBXMMYGSZLDYDQMJJRGBJTKGDHGKBLQKBDMBYLXWCXYTTYBKMRTJZXQJBHLMHMJJZMQASLDCYXYQDLQCAFYWYXQHZ") ] static nothing := VarSetCapacity(var, 2) ; 如果不包含中文字符,则直接返回原字符 if !RegExMatch(str, "[^\x{00}-\x{ff}]") Return str Loop, Parse, str { StrPut(A_LoopField, &var, "CP936") H := NumGet(var, 0, "UChar") L := NumGet(var, 1, "UChar") ; 字符集非法 if (H < 0xB0 || L < 0xA1 || H > 0xF7 || L = 0xFF) { newStr .= A_LoopField Continue } if (H < 0xD8)//(H >= 0xB0 && H <=0xD7) { ; 查询文字在一级汉字区(16-55) W := (H << 8) | L For key, value in FirstTable { if (W < value) { newStr .= FirstLetter[key] Break } } } else ; if (H >= 0xD8 && H <= 0xF7) ; 查询中文在二级汉字区(56-87) newStr .= SecondTable[ H - 0xD8 + 1 ][ L - 0xA1 + 1 ] } Return newStr }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)