cPAMIE中winGuiAuto中文处理问题

 

版权声明

请尊重原创作品。转载请保持文章完整性,并以超链接形式注明原始作者“tingsking18”和主站点地址,方便其他朋友提问和指正。

 

winGuiAuto处理中文的时候会有问题。

先暂时用下面的方法解决一下,等有时间了仔细阅读一下winGuiAuto的代码,看看能不能改改代码,让他支持中文处理。

下面是暂时的解决方法:

 #!/usr/bin/env python #coding=utf-8 import cPAMIE import winGuiAuto import win32gui import sys from time import sleep reload(sys) sys.setdefaultencoding("utf-8") ie= cPAMIE.PAMIE() ie.navigate ('http://127.0.0.1/index.html') ie.linkClick(u"下载") ie._wait() sleep(1) hwnds = winGuiAuto.findTopWindows(wantedClass="#32770") for i in hwnds: text = win32gui.GetWindowText(i) #print text text = unicode(text, "gbk") if text.find(u"文件下载") >=0: control_list=winGuiAuto.dumpWindow(i) for control_item in control_list: btntext = control_item[1] btntext = unicode(btntext, "gbk") if btntext.find(u"保存(&S)")>=0: winGuiAuto.clickButton(control_item[0]) sleep(1) savehwnds = winGuiAuto.findTopWindows(wantedClass="#32770") for h in savehwnds: savetext = win32gui.GetWindowText(h) savetext = unicode(savetext, "gbk") if savetext.find(u"另存为") >=0: savecontrol_list=winGuiAuto.dumpWindow(h) for savecontrol_item in savecontrol_list: savebtntext = savecontrol_item[1] savebtntext = unicode(savebtntext, "gbk") if savebtntext.find(u"保存(&S)")>=0: winGuiAuto.clickButton(savecontrol_item[0])

你可能感兴趣的:(list,IE,import)