自学python的windows办公自动化的库pywinauto,实现了一个自动打开四个si工程并同步代码的用例。
import os
import webbrowser
import pyautogui
#import pywinauto
from pywinauto.application import Application
import time
def open_si_proj( si_proj_name ):
app = Application().start("C:\Program Files (x86)\Source Insight 4.0\sourceinsight4.exe")
time.sleep(10)
app.top_window().maximize()
time.sleep(3)
app.top_window().menu_select('Project->Open Project...')
app['Open Project']['edit'].type_keys(si_proj_name)
app['Open Project']['OK'].click()
time.sleep(10)
app.top_window().menu_select('Project->Synchronize Files...')
time.sleep(10)
app['Synchronize Files']['Start'].click()
time.sleep(10)
mmiao_si_proj_name = ['git_code_win','git_code_win1','git_code_win2','git_code_win3']
def mmiao_si_proj_open(all_si_proj_name):
for si_proj_name in all_si_proj_name:
print 'current open proj name is:',si_proj_name
open_si_proj(si_proj_name)
mmiao_si_proj_open(mmiao_si_proj_name)