一,环境检查
操作系统:windows 2008 R2 64位版本
二,准备安装包
1.python 2.7 32位
2.pip 9.0.1
三,安装环境
安装完python和pip之后
pip install -U pyautoit
python setup.py install
四,调试环境
# -*- coding: utf-8 -*-
#此用例在Win2008中文版下测试通过,由于没有做本地化处理,在编写程序时,应该特别注意语言的匹配
import autoit
import time
autoit.run("C:\Program Files (x86)\PLSQL Developer\plsqldev.exe")
time.sleep(2)
autoit.send("queryuser",2)
time.sleep(2)
autoit.control_click("Oracle 登录","确定")
time.sleep(5)
autoit.send("!os")
time.sleep(2)
autoit.control_set_text("打开","[CLASS:Edit; INSTANCE:1]","sql.sql")
time.sleep(2)
autoit.send("!o")
time.sleep(2)
autoit.send("!se")
time.sleep(5)
autoit.send("!{END}")
time.sleep(5)
autoit.mouse_click("right",720,450,1)
time.sleep(2)
autoit.send("x")
time.sleep(2)
autoit.send("{ENTER}")
time.sleep(2)
autoit.win_activate("Microsoft Excel - tmp001.xls [兼容模式]")
time.sleep(2)
autoit.send("!fa")
time.sleep(2)
autoit.send("!d")
time.sleep(2)
autoit.win_activate("另存为")
time.sleep(2)
autoit.send("{ASC 68}{ASC 58}{ASC 92}{ASC 114}{ASC 101}{ASC 112}{ASC 111}{ASC 114}{ASC 116}{ASC 115}{ASC 92}{ASC 122}{ASC 105}{ASC 106}{ASC 105}{ASC 110}{ASC 115}{ASC 117}{ASC 111}{ASC 92}{ASC 115}{ASC 101}{ASC 114}{ASC 118}{ASC 105}{ASC 99}{ASC 101}{ASC 70}{ASC 101}{ASC 101}")
time.sleep(2)
autoit.send("{ENTER}")
time.sleep(5)
autoit.control_set_text("另存为","[CLASS:ComboBox; INSTANCE:1]","temphahaha.xls")
time.sleep(5)
autoit.send("!s")
autoit.win_activate("确认另存为")
time.sleep(2)
autoit.send("!y")
注意:含有中文字符要在notepad++上调整为ansi格式,不然会有乱码