Commits

gao shuai committed f0dc99a

start

Comments (0)

Files changed (4)

Added
New image
+pinYin=('a','ai','an','ang','ao','ba','bai','ban','bang','baobei','ben','beng','bi','bian','biao','bie','bin','bing','bo','bu','ca','cai','can','cang','cao','ce','ceng','cha','chai','chan','chang','chao','che','chen','cheng','chi','chong','chou','chu','chuai','chuan','chuang','chui','chun','chuo','ci','cong','cou','cu','cuan','cui','cun','cuo','da','dai','dan','dang','dao','de','deng','di','dian','diao','die','ding','diu','dong','dou','du','duan','dui','dun','duo','e','en','er','fa','fan','fang','fei','fen','feng','fo','fou','fu','ga','gai','gan','gang','gao','ge','gei','gen','geng','gong','gou','gu','gua','guai','guan','guang','gui','gun','guo','ha','hai','han','hang','hao','he','hei','hen','heng','hong','hou','hu','hua','huai','huan','huang','hui','hun','huo','ji','jia','jian','jiang','jiao','jie','jin','jing','jiong','jiu','ju','juan','jue','jun','ka','kai','kan','kang','kao','ke','ken','keng','kong','kou','ku','kua','kuai','kuan','kuang','kui','kun','kuo','la','lai','lan','lang','lao','le','lei','leng','li','lia','lian','liang','liao','lie','lin','ling','liu','long','lou','lu','lv','luan','lue','lun','luo','ma','mai','man','mang','mao','me','mei','men','meng','mi','mian','miao','mie','min','ming','miu','mo','mou','mu','na','nai','nan','nang','nao','ne','nei','nen','neng','ni','nian','niang','niao','nie','nin','ning','niu','nong','nu','nv','nuan','nue','nuo','o','ou','pa','pai','pan','pang','pao','pei','pen','peng','pi','pian','piao','pie','pin','ping','po','pu','qi','qia','qian','qiang','qiao','qie','qin','qing','qiong','qiu','qu','quan','que','qun','ran','rang','rao','re','ren','reng','ri','rong','rou','ru','ruan','rui','run','ruo','sa','sai','san','sang','sao','se','sen','seng','sha','shai','shan','shang','shao','she','shen','sheng','shi','shou','shu','shua','shuai','shuan','shuang','shui','shun','shuo','si','song','sou','su','suan','sui','sun','suo','ta','tai','tan','tang','tao','te','teng','ti','tian','tiao','tie','ting','tong','tou','tu','tuan','tui','tun','tuo','wa','wai','wan','wang','wei','wen','weng','wo','wu','xi','xia','xian','xiang','xiao','xie','xin','xing','xiong','xiu','xu','xuan','xue','xun','ya','yan','yang','yao','ye','yi','yin','ying','yo','yong','you','yu','yuan','yue','yun','za','zai','zan','zang','zao','ze','zei','zen','zeng','zha','zhai','zhan','zhang','zhao','zhe','zhen','zheng','zhi','zhong','zhou','zhu','zhua','zhuai','zhuan','zhuang','zhui','zhun','zhuo','zi','zong','zou','zu','zuan','zui','zun','zuo')
+PC�ϵ��ֻ�ƴ�����뷽ʽ�� ����426��Ӧ gan,gao,hao,han

wd_key_mapping.pyw

+# -*- coding: utf-8 -*-
+shengMu=['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','zh','ch','sh']
+yunMu= ['a','o','e','i','u','ai','ei','ui','ao','ou','iu','ie','ve','er','an','en','in','un','vn','ang','eng','ing','ong']
+from pinyin import pinYin
+import random
+keyDic={"2":"abc","3":"def","4":"ghi","5":"jkl","6":"mno","7":"pqrs","8":"tuv","9":"wxyz"}
+#for (key,value) in keyDic.items():
+	#print key,value
+running=0
+def py(inputKey):
+	inputKey=list(inputKey)
+	tempList=[]
+	word=[]
+	output=[]
+	for key in inputKey:
+		tempList.append(list(keyDic[key]))
+	pinYinNum=1
+	for key in inputKey:
+		pinYinNum*=len(keyDic[key])
+
+	while 1:
+		word=[]
+		for j in range(len(inputKey)):
+			try:
+				w=random.choice(tempList[j])
+				word.append(w)
+				#tempList[j].remove(w)
+			except:
+				pass
+		word="".join(word)
+		if word not in output:
+			output.append(word)
+		word=[]
+		if len(output)==pinYinNum:
+			break
+	return [word for word in output if word  in pinYin]
+
+
+import win32api
+import win32con
+
+# A 65 0 48
+def up(key):
+	if type(key)==type(''):
+		win32api.keybd_event(ord(key.upper()),0,win32con.KEYEVENTF_KEYUP,0)
+	elif type(key)==type(1):
+		win32api.keybd_event(key,0,win32con.KEYEVENTF_KEYUP,0)
+def down(key):
+	if type(key)==type(''):
+		win32api.keybd_event(ord(key.upper()),0,0,0)
+	elif type(key)==type(1):
+		win32api.keybd_event(key,0,0,0)
+def press(key):
+	if type(key)==type(''):
+		win32api.keybd_event(ord(key.upper()),0,0,0)
+		win32api.keybd_event(ord(key.upper()),0,win32con.KEYEVENTF_KEYUP,0)
+	elif type(key)==type(1):
+		win32api.keybd_event(key,0,0,0)
+		win32api.keybd_event(key,0,win32con.KEYEVENTF_KEYUP,0)
+def out(keys):
+	# outputChar.set('')
+	# outputEntry.focus_set()
+	for char in keys:
+		press(char)
+def backToInputScreen():
+	'''���ص�ԭ�������'''
+	tab=9
+	alt=18
+	down(alt)
+	down(tab)
+	up(tab)
+	up(alt)
+def getpinyin(x=0):
+	# global pybt
+	global pinyin
+	# for bt in pybt:
+		# bt.unpcak()
+	pinyin=py(inputChar.get())
+	# for p in pinyin:
+		# exec("""bt=Button(root,text="%s",command=lambda : out("%s"))\nbt.pack()\npybt.append(bt)"""%(p,p))
+	pinyinChar.set(','.join([p+str(pinyin.index(p)+1) for p in pinyin]))
+	inputIndexChar.set('')
+	inputIndexEntry.focus_set()
+
+def putpinyin(x=0):
+	global pinyin
+	# outputEntry.focus_set()
+	backToInputScreen()
+	out(pinyin[int(inputIndexChar.get())-1])
+	inputChar.set('')
+	inputEntry.focus_set()
+
+
+pinyin=[]
+# win32api.keybd_event(17,0,0,0)  #ctrl�����17
+# win32api.keybd_event(86,0,0,0)  #v�����86
+# win32api.keybd_event(86,0,win32con.KEYEVENTF_KEYUP,0) #�ͷŰ���
+# win32api.keybd_event(17,0,win32con.KEYEVENTF_KEYUP,0)
+from Tkinter import *
+root = Tk()
+# pybt=[]
+inputChar = StringVar()
+inputEntry = Entry(root,textvariable = inputChar)
+inputEntry.bind("<Return>",getpinyin)
+inputEntry.pack()
+inputEntry.focus_set()
+
+inputIndexChar = StringVar()
+inputIndexEntry = Entry(root,textvariable = inputIndexChar)
+inputIndexEntry.bind("<Return>",putpinyin)
+inputIndexEntry.pack()
+
+
+# outputChar = StringVar()
+# outputEntry = Entry(root,textvariable = outputChar)
+# outputEntry.bind("<Return>",lambda x=0: inputEntry.focus_set())
+# outputEntry.pack()
+
+pinyinChar = StringVar()
+pinyinEntry = Entry(root,textvariable = pinyinChar)
+pinyinEntry.pack()
+
+img=PhotoImage(file="keymap.gif")
+label=Label(root,image=img)
+label.pack()
+# SENDBUTTON=Button(root,text='SEND',command=putpinyin)
+# SENDBUTTON.pack()
+root.mainloop()