send string to text window by window handle
from pywinauto import application
import psutil
import re
def getPid(pName):
process = psutil.process_iter()
for pro in process :
str_pro = str(pro)
pat = re.compile(pName)
if pat.search(str_pro):
pid = str_pro.split('pid=')[1].split(',')[0]
return pid
app = application.Application()
pid = getPid(app_name)
print pid, type(pid)
app.connect(process=int(pid))
# handle 是编辑框的ID
app.window_(title_re=chat_name).window(handle=1121066).TypeKeys('中文'.decode(
'utf-8'))