def quit_BECivil(self): """退出BECivil""" w0 = WinControl(self.BECivilWin) if w0.exists(): m1 = MouseControl() w0.wait(3) m1.click(self.BECivilWin, '', 1900, 13) if w0.exists(): w0.wait(3) t = w0.getPos() if t == (845, 438, 1075, 602): pass else: raise Exception('Something went wrong.') sleep(1) w0.controlClick('[CLASS:Button; INSTANCE:1]') else: raise Exception('未弹出确认关闭软件窗口') else: raise Exception('未识别BECivil打开的窗口') sleep(5) if w0.exists(): raise Exception('关闭软件未成功') else: pass
def clear_cache(self): """清理缓存""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.系统[0], screen_point.系统[1]) m1.click(self.BECivilWin, '', screen_point.清除[0], screen_point.清除[1]) sleep(2) if w0.exists(): w0.wait(3) t1 = w0.getPos() if t1 == (832, 437, 1088, 603): pass else: raise Exception('Something went wrong.') w0.controlClick('[CLASS:Button; INSTANCE:1]') sleep(3) if w0.exists(): w0.wait(3) t2 = w0.getPos() if t2 == (845, 438, 1075, 602): pass else: raise Exception('Something went wrong.') w0.controlClick('[CLASS:Button; INSTANCE:2]') else: raise Exception("没有弹出退出确认窗口") else: raise Exception("没有弹出清理缓存窗口") else: raise Exception("未识别BECivil窗口")
def format_painter(self): """格式刷""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.沙盘[0], screen_point.沙盘[1]) m1.click(self.BECivilWin, '', screen_point.格式刷[0], screen_point.格式刷[1]) sleep(2) # 勾选“未定义状态”构件 w0.controlClick("[CLASS:Button; INSTANCE:14]") sleep(2) # 选择需要使用格式刷的构件 m1.click(self.BECivilWin, '', 1060, 505) sleep(1) m1.click(self.BECivilWin, '', 980, 640) sleep(1) m1.click(self.BECivilWin, '', 980, 640, button='right') sleep(2) if w0.exists(): w0.wait(3) t = w0.getPos() if t == (832, 437, 1088, 603): pass else: raise Exception('Something went wrong.') w0.controlClick('[CLASS:Button; INSTANCE:1]') else: raise Exception("未弹出刷新状态确认框") else: raise Exception("未识别BECivil窗口")
def manage_working_set(self): """管理工作集""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.系统[0], screen_point.系统[1]) m1.click(self.BECivilWin, '', screen_point.管理工作集[0], screen_point.管理工作集[1]) sleep(2) w1 = WinControl('管理工作集') if w1.exists(): w1.wait(3) #w1.setState(3) w1.controlSetText('[CLASS:Edit; INSTANCE:1]', '测试脚本用创建工作集') sleep(3) # 选中要删除的工作集 m1.click('管理工作集', '', 880, 390) sleep(2) # 点击删除 m1.click('管理工作集', '', 870, 760) sleep(2) if w0.exists(): sleep(2) t1 = w0.getPos() if t1 == (844, 438, 1076, 602): pass else: raise Exception('Something went wrong.') w0.controlClick('[CLASS:Button; INSTANCE:1]') sleep(3) if w0.exists(): t2 = w0.getPos() if t2 == (880, 438, 1040, 602): pass else: raise Exception('Something went wrong.') sleep(2) if w0.exists(): t3 = w0.getPos() if t3 == (880, 438, 1040, 602): pass else: raise Exception('Something went wrong.') w0.controlClick('[CLASS:Button; INSTANCE:1]') else: raise Exception('未弹出删除确认框') else: raise Exception('未弹出删除成功选择框') else: raise Exception('未弹出删除工作集选择框') sleep(2) # 关闭管理工作集窗口 m1.click('管理工作集', '', 1114, 263) else: raise Exception("未弹出管理工作集窗口") else: raise Exception("未识别BECivil窗口")
def setting(self): """设置""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.任务[0], screen_point.任务[1]) m1.click(self.BECivilWin, '', screen_point.设置[0], screen_point.设置[1]) ''' m1.click(self.BECivilWin, '', screen_point.设置[0], 140)# 仪器信息 sleep(1) w1 = WinControl('仪器信息') if w1.exists(): w1.wait(3) w1.controlClick('[CLASS:Button; INSTANCE:1]') sleep(1) m1.click('仪器信息', '', 910, 650) autoit.send('测试脚本用添加仪器') m1.click('仪器信息', '', 1080, 650) autoit.send('134652') autoit.send("{ENTER}") m1.click('仪器信息', '', 1180, 370)# 关闭仪器信息 else: raise Exception('未打开仪器信息窗口') sleep(1) m1.click(self.BECivilWin, '', screen_point.设置[0], screen_point.设置[1]) ''' # 点位图管理 m1.click(self.BECivilWin, '', screen_point.设置[0], 160) sleep(2) w2 = WinControl('点位图管理') if w2.exists(): w2.wait(3) w2.controlClick("[CLASS:Button; INSTANCE:1]") sleep(1) # 截图点位图 m1.click(self.BECivilWin, '', 710, 390, button='right') m1.click(self.BECivilWin, '', 660, 405) sleep(2) w3 = WinControl('点位图命名') if w3.exists(): w3.wait(3) w3.controlSetText('[CLASS:Edit; INSTANCE:1]', '测试脚本用点位图') sleep(1) w3.controlClick('[CLASS:Button; INSTANCE:1]') else: raise Exception('未打开点位图命名窗口') sleep(1) # 关闭点位图管理 m1.click('点位图管理', '', 1336, 183) else: raise Exception('未打开点位图管理窗口') else: raise Exception('未识别市政窗口')
def monitoring_panel(self): """监控面板""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.沙盘[0], screen_point.沙盘[1]) m1.click(self.BECivilWin, '', screen_point.监控面板[0], screen_point.监控面板[1]) sleep(1) # 启用沙盘模式 if w0.exists(): w0.wait(3) t = w0.getPos() if t == (830, 438, 1090, 602): pass else: raise Exception('Something went wrong.') w0.controlClick('[CLASS:Button; INSTANCE:1]') else: raise Exception('未打开开启沙盘模式窗口') sleep(13) # 点击添加监控 m1.click(self.BECivilWin, '', 1800, 320) sleep(7) w1 = WinControl('添加监控') if w1.exists(): w1.wait(3) w1.controlClick("[CLASS:Button; INSTANCE:1]") else: raise Exception("未弹出添加监控窗口") sleep(4) m1.click(self.BECivilWin, '', screen_point.沙盘模式[0], screen_point.沙盘模式[1]) else: raise Exception("未识别BECivil窗口")
def statistics_panel(self): """统计面板""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.沙盘[0], screen_point.沙盘[1]) m1.click(self.BECivilWin, '', screen_point.统计面板[0], screen_point.统计面板[1]) sleep(2) w0.controlClick("[CLASS:Button; INSTANCE:29]") sleep(2) w0.controlClick("[CLASS:Button; INSTANCE:29]") else: raise Exception("未识别BECivil窗口")
def download_porject(self): """下载工程""" w0 = WinControl(self.BECivilWin) if w0.exists(): m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.系统[0], screen_point.系统[1]) m1.click(self.BECivilWin, '', screen_point.下载工程[0], screen_point.下载工程[1]) sleep(2) w1 = WinControl('浏览文件夹') if w1.exists(): w1.wait(3) # 选择下载的目标地址 w1.controlTreeView('[CLASS:SysTreeView32; INSTANCE:1]', 'Select', extra='桌面') choose_direction(6) choose_direction(3) choose_direction(1) choose_direction(2) sleep(2) w1.controlClick('Button1') if w0.exists(): w0.wait(3) t = w0.getPos() # 目标文件夹没有下载过该工程 if t == (0, 0, 1920, 1040): pass # 目标文件夹曾经下载过该工程 elif t == (832, 438, 1088, 602): pass else: raise Exception('Something went wrong.') sleep(2) w0.controlClick('[CLASS:Button; INSTANCE:1]') else: pass sleep(1) w2 = WinControl('下载管理器') if w2.exists(): pass else: raise Exception('未弹出下载管理器窗口') else: raise Exception("未选中浏览文件夹窗口") else: raise Exception("未识别BECivil窗口")
def service_setting(self): """ 、服务设置""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.沙盘[0], screen_point.沙盘[1]) m1.click(self.BECivilWin, '', screen_point.服务设置[0], screen_point.服务设置[1]) sleep(1) w1 = WinControl("第三方监控服务设置") if w1.exists(): w1.wait(3) # 检测 w1.controlClick("[CLASS:Button; INSTANCE:1]") sleep(7) if w0.exists(): w0.wait(3) t1 = w0.getPos() if t1 == (880, 438, 1040, 602): pass else: raise Exception('Something went wrong.') w0.controlClick("[CLASS:Button; INSTANCE:1]") else: raise Exception("未弹出检测成功窗口") sleep(2) # 确定 w1.controlClick("[CLASS:Button; INSTANCE:2]") sleep(7) if w0.exists(): w0.wait(3) t2 = w0.getPos() if t2 == (868, 438, 1052, 602): pass else: raise Exception('Something went wrong.') w0.controlClick("[CLASS:Button; INSTANCE:1]") else: raise Exception("未弹出保存设置成功窗口") else: raise Exception("未弹出第三方监控服务设置") else: raise Exception("未识别BECivil窗口")
def project_time(self): """工程时间""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.沙盘[0], screen_point.沙盘[1]) m1.click(self.BECivilWin, '', screen_point.工程时间[0], screen_point.工程时间[1]) sleep(2) w1 = WinControl("工程时间") if w1.exists(): w1.wait(3) w1.controlClick("[CLASS:Button; INSTANCE:1]") else: raise Exception("未打开工程时间窗口") else: raise Exception("未识别BECivil窗口")
def edit_contract_management(self): """编辑合同""" if WinControl(self.IMWin).exists(): m1 = MouseControl() m1.click(self.IMWin, '', screen_point.编辑施工合同[0], screen_point.编辑施工合同[1]) sleep(3) m1.click(self.IMWin, '', screen_point.施工负责人[0], screen_point.施工负责人[1]) autoit.send(self.message12) m1.click(self.IMWin, '', screen_point.总监理工程师[0], screen_point.总监理工程师[1]) autoit.send(self.message13) m1.click(self.IMWin, '', screen_point.项目总工[0], screen_point.项目总工[1]) autoit.send(self.message14) m1.click(self.IMWin, '', screen_point.保存[0], screen_point.保存[1]) else: raise Exception('没有检测到IM窗口!')
def start_IM(self): """启动IM""" if WinControl(self.BECivilWin).exists(): m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.资料[0], screen_point.资料[1]) sleep(1) m1.click(self.BECivilWin, '', screen_point.质检计量[0], screen_point.质检计量[1]) # 等待IM界面 w1 = WinControl(self.IMWin) w1.wait(30) # 关闭筑业升级进程 if autoit.process_exists("ZY.Downloader.exe"): autoit.process_close("ZY.Downloader.exe") else: pass w1.setState(3) else: print('BECivil未启动,无法启动IM。')
def component_search(self): """构建搜索""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.操作[0], screen_point.操作[1]) m1.click(self.BECivilWin, '', screen_point.构件搜索[0], screen_point.构件搜索[1]) w1 = WinControl('构件搜索') sleep(2) if w1.exists(): w1.wait(2) w1.controlSetText('[CLASS:Edit; INSTANCE:1]', 'TWQ2') w1.controlClick('[CLASS:Button; INSTANCE:5]') sleep(2) w1.controlClick('[CLASS:Button; INSTANCE:1]') sleep(2) w2 = WinControl('搜索结果') if w2.exists(): w2.wait(3) w2.controlClick('[CLASS:Button; INSTANCE:3]') else: raise Exception("未打开搜索结果窗口") else: raise Exception("未打开构件搜索窗口") sleep(2) m1.click(self.BECivilWin, '', screen_point.构件搜索[0], screen_point.构件搜索[1]) else: raise Exception("未识别BECivil窗口")
def upload_project(self, projectname): """上传工程""" w0 = WinControl(self.BECivilWin) if w0.exists(): m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.系统[0], screen_point.系统[1]) m1.click(self.BECivilWin, '', screen_point.上传工程[0], screen_point.上传工程[1]) w1 = WinControl("打开") sleep(4) if w1.exists(): w1.wait(3) w1.setState(3) # 输入保存上传工程的地址 m1.click('打开', '', 820, 45) w1.controlSetText('[CLASS:Edit; INSTANCE:2]', self.uploadaddress) autoit.send("{ENTER}") sleep(2) w1.controlSetText('[CLASS:Edit; INSTANCE:1]', projectname) w1.controlClick('[CLASS:Button; INSTANCE:1]') sleep(2) w2 = WinControl("上传工程") sleep(2) if w2.exists(): w2.wait(3) w2.controlClick('[CLASS:Button; INSTANCE:3]') sleep(3) w3 = WinControl("上传位置") if w3.exists(): w3.wait(3) # 选择IM测试 m1.click(self.BECivilWin, '', 940, 435) sleep(1) w3.controlClick("[CLASS:Button; INSTANCE:1]") else: raise Exception('未选中上传位置窗口') sleep(1) w2.controlClick('[CLASS:Button; INSTANCE:1]') else: raise Exception('未选中上传工程窗口') else: raise Exception('未选中打开窗口') sleep(22) w5 = WinControl("Luban Explorer(Civil)提醒您") w5.wait(60) if w5.exists(): pass else: raise Exception("上传成功提示未显示") else: raise Exception("未识别BECivil窗口")
def refresh_data(self): """刷新数据""" w0 = WinControl(self.BECivilWin) if w0.exists(): m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.沙盘[0], screen_point.沙盘[1]) m1.click(self.BECivilWin, '', screen_point.刷新数据[0], screen_point.刷新数据[1]) sleep(4) if w0.exists(): w0.wait(3) t = w0.getPos() if t == (838, 438, 1082, 602): pass else: raise Exception('Something went wrong.') w0.controlClick("[CLASS:Button; INSTANCE:1]") else: raise Exception("数据刷新未完成") else: raise Exception("未识别BECivil窗口")
def delete_contract_managemeng(self): """删除合同""" if WinControl(self.IMWin).exists(): m1 = MouseControl() m1.click(self.IMWin, '', screen_point.工程管理[0], screen_point.工程管理[1]) m1.click(self.IMWin, '', screen_point.合同管理[0], screen_point.合同管理[1]) m1.click(self.IMWin, '', screen_point.删除施工合同[0], screen_point.删除施工合同[1]) m1.click(self.IMWin, '', screen_point.确认删除合同[0], screen_point.确认删除合同[1]) else: raise Exception('没有检测到IM窗口!')
def quit_BECivil(self): """退出""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.系统[0], screen_point.系统[1]) m1.click(self.BECivilWin, '', screen_point.退出[0], screen_point.退出[1]) sleep(2) if w0.exists(): w0.wait(3) t = w0.getPos() if t == (845, 438, 1075, 602): pass else: raise Exception('Something went wrong.') w0.controlClick('[CLASS:Button; INSTANCE:1]') else: raise Exception("没有弹出退出确认窗口") else: raise Exception("未识别BECivil窗口")
def local_task(self): """本地任务""" w0 = WinControl(self.BECivilWin) if w0.exists(): m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.系统[0], screen_point.系统[1]) m1.click(self.BECivilWin, '', screen_point.本地任务[0], screen_point.本地任务[1]) w1 = WinControl(" 本机处理任务") if w1.exists(): w1.wait(3) w1.setState(3) # 历史记录 m1.click(" 本机处理任务", '', 85, 30) # 删除此次上传的两条记录 for i in range(2): m1.click(" 本机处理任务", '', 50, 90) w1.controlClick('Button1') if w0.exists(): w0.waitActive(3) # 识别确定删除窗口关联的进程ID t = w0.getPos() if t == (845, 438, 1075, 602): pass else: raise Exception("未成功删除该任务") sleep(1) w0.controlClick('Button1') sleep(1) else: raise Exception("未成功删除该任务") sleep(1) # 关闭本机处理任务 m1.click(" 本机处理任务", '', 1905, 5) else: raise Exception("未选中本机任务窗口") else: raise Exception("未识别BECivil窗口")
def export_the_qr_code(self): """导出二维码""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.操作[0], screen_point.操作[1]) m1.click(self.BECivilWin, '', screen_point.导出二维码[0], screen_point.导出二维码[1]) # 选中需要导出二维码的构件 m1.click(self.BECivilWin, '', 810, 500) # 右键导出 m1.click(self.BECivilWin, '', 810, 500, button='right') m1.click(self.BECivilWin, '', 730, 510) sleep(2) w1 = WinControl('选择文件夹') if w1.exists(): w1.wait(3) w1.controlSetText('[CLASS:Edit; INSTANCE:1]', self.downloadaddress + '\二维码下载') sleep(1) w1.controlClick('[CLASS:Button; INSTANCE:1]') else: raise Exception("未打开选择文件夹窗口") sleep(3) if w0.exists(): w0.wait(3) t = w0.getPos() if t == (862, 438, 1058, 602): pass else: raise Exception('Something went wrong.') sleep(1) w0.controlClick('[CLASS:Button; INSTANCE:1]') else: raise Exception("未弹出导出二维码成功窗口") else: raise Exception("未识别BECivil窗口")
def creat_working_set(self): """创建工作集""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.系统[0], screen_point.系统[1]) m1.click(self.BECivilWin, '', screen_point.创建工作集[0], screen_point.创建工作集[1]) w1 = WinControl('创建工作集') sleep(2) if w1.exists(): w1.wait(3) w1.controlSetText('[CLASS:Edit; INSTANCE:1]', '测试脚本用创建工作集') w1.controlClick('[CLASS:Button; INSTANCE:1]') w2 = WinControl('选择所属项目部') sleep(2) if w2.exists(): # 选择IM测试 m1.click('选择所属项目部', '', 850, 385) w2.controlClick('[CLASS:Button; INSTANCE:1]') else: raise Exception("未选中选择所属项目部窗口") sleep(2) # 选中需要创建工作集的两个工程 m1.click('创建工作集', '', 780, 390) m1.click('创建工作集', '', 780, 420) w1.controlClick('[CLASS:Button; INSTANCE:3]') sleep(2) if w0.exists(): w0.wait(3) t = w0.getPos() if t == (826, 438, 1094, 602): pass else: raise Exception('未弹出打开工作集选择框') sleep(1) w0.controlClick('[CLASS:Button; INSTANCE:2]') else: raise Exception('未弹出打开工作集选择框') else: raise Exception("未选中创建工作集窗口") else: raise Exception("未识别BECivil窗口")
def add_form(self, y1=515, message='封面'): """添加表单用""" w0 = WinControl("添加表单") if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click('添加表单', '', 990, 495) sleep(1) m1.click('添加表单', '', 990, y1) sleep(0.5) m1.click('添加表单', '', 990, 530) autoit.send(message) sleep(0.5) w0.controlClick("[CLASS:Button; INSTANCE:1]") else: raise Exception('添加表单未成功')
def cooperation_management(self): """协作管理""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.协作[0], screen_point.协作[1]) m1.click(self.BECivilWin, '', screen_point.协作管理[0], screen_point.协作管理[1]) sleep(15) w1 = WinControl('Luban Cooperation') if w1.exists(): w1.wait(3) w1.setState(3) sleep(2) # 确认协作已删除 m1.click('Luban Cooperation', '', 960, 575) sleep(1) # 关闭CO m1.click('Luban Cooperation', '', 1882, 29) else: raise Exception("未能打开鲁班协作窗口") # 从后台关闭CO sleep(3) ps = [ ProcessControl(self.COProcess), ProcessControl(self.SuspernsionCtrlProcess) ] for p in ps: if p.exists(): p.wait(6) p.close() else: print('未找到运行的鲁班协作程序') else: raise Exception("未识别BECivil窗口")
def state_statistics(self): """状态统计""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.沙盘[0], screen_point.沙盘[1]) m1.click(self.BECivilWin, '', screen_point.状态统计[0], screen_point.状态统计[1]) sleep(2) w0.controlClick("[CLASS:Button; INSTANCE:24]") sleep(2) w0.controlClick("[CLASS:Button; INSTANCE:25]") sleep(3) w1 = WinControl("另存为") if w1.exists(): w1.wait(3) w1.setState(3) m1.click('另存为', '', 1060, 50) autoit.send(self.downloadaddress) autoit.send("{ENTER}") sleep(2) w1.controlClick("[CLASS:Button; INSTANCE:1]") sleep(1) w2 = WinControl("确认另存为") if w2.exists(): w2.wait(3) w2.controlClick("[CLASS:Button; INSTANCE:1]") else: pass sleep(35) if w0.exists(): w0.wait(3) t = w0.getPos() if t == (832, 438, 1088, 602): pass else: raise Exception('Something went wrong.') w0.controlClick("[CLASS:Button; INSTANCE:2]") else: raise Exception("未能打开另存为窗口") else: raise Exception("未识别BECivil窗口")
def open_working_set(self): """打开工作集""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.系统[0], screen_point.系统[1]) m1.click(self.BECivilWin, '', screen_point.打开工作集[0], screen_point.打开工作集[1]) sleep(3) w1 = WinControl('打开工作集') if w1.exists(): w1.setState(3) w1.controlSetText('[CLASS:Edit; INSTANCE:1]', '测试脚本用创建工作集') sleep(3) # 打开工作集,因为有时候双击会出现打不开的情况,故设置点击数为3 m1.click('打开工作集', '', 92, 134, clicks=3) else: raise Exception("未选中打开工作集窗口") else: raise Exception("未识别BECivil窗口")
def upload_picture(self): """ """ w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.沙盘[0], screen_point.沙盘[1]) m1.click(self.BECivilWin, '', screen_point.上传图片[0], screen_point.上传图片[1]) sleep(1) w1 = WinControl('打开') if w1.exists(): w1.wait(3) m1.click('打开', '', 1110, 45) sleep(1) w1.controlSetText('[CLASS:Edit; INSTANCE:2]', self.uploadaddress) autoit.send("{ENTER}") sleep(1) w1.controlSetText('[CLASS:Edit; INSTANCE:1]', r'picture1.jpg') sleep(1) w1.controlClick("[CLASS:Button; INSTANCE:1]") sleep(3) if w0.exists(): w0.wait(3) t = w0.getPos() if t == (874, 438, 1046, 602): pass else: raise Exception('Something went wrong.') w0.controlClick("[CLASS:Button; INSTANCE:1]") else: raise Exception("未弹出上传成功窗口") else: raise Exception("未弹出打开窗口") else: raise Exception("未识别BECivil窗口")
def open_project(self, projectname): """打开工程""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.系统[0], screen_point.系统[1]) m1.click(self.BECivilWin, '', screen_point.打开工程[0], screen_point.打开工程[1]) sleep(3) w1 = WinControl("选择工程") if w1.exists(): w1.wait(3) w1.setState(3) # 输入名字搜索 m1.click("选择工程", '', 50, 35) autoit.send(projectname) sleep(5) # 打开测试脚本用土建工程 m1.click(self.BECivilWin, '', 92, 133, clicks=3) else: raise Exception("未选中选择工程窗口") sleep(10) # 使视图视角变为俯视视角 m1.click(self.BECivilWin, '', 440, 440, button='right') m1.click(self.BECivilWin, '', 490, 475) else: raise Exception("未识别BECivil窗口")
def sand_table_cockpit(self): """沙盘驾驶舱""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.沙盘[0], screen_point.沙盘[1]) m1.click(self.BECivilWin, '', screen_point.沙盘模式[0], screen_point.沙盘模式[1]) m1.click(self.BECivilWin, '', screen_point.沙盘驾驶舱[0], screen_point.沙盘驾驶舱[1]) sleep(3) w1 = WinControl(" 沙盘驾驶舱") if w1.exists(): w1.wait(3) # 播放 m1.click(' 沙盘驾驶舱', '', 190, 970) sleep(3) # 刷新 m1.click(' 沙盘驾驶舱', '', 450, 40) sleep(3) if w0.exists(): w0.wait(3) t = w0.getPos() if t == (838, 438, 1082, 602): pass else: raise Exception('Something went wrong.') sleep(1) w0.controlClick("[CLASS:Button; INSTANCE:1]") else: raise Exception("未弹出刷新完成窗口") # 关闭沙盘驾驶舱窗口 m1.click(' 沙盘驾驶舱', '', 1905, 10) else: raise Exception("未打开沙盘驾驶舱窗口") else: raise Exception("未识别BECivil窗口")
def creat_contract_management(self): # 新增合同 if WinControl(self.IMWin).exists(): m1 = MouseControl() m1.click(self.IMWin, '', screen_point.选择项目部[0], screen_point.选择项目部[1]) sleep(1) m1.click(self.IMWin, '', screen_point.工程管理[0], screen_point.工程管理[1]) m1.click(self.IMWin, '', screen_point.合同管理[0], screen_point.合同管理[1]) m1.click(self.IMWin, '', screen_point.新增施工合同[0], screen_point.新增施工合同[1]) sleep(5) m1.click(self.IMWin, '', screen_point.合同编号[0], screen_point.合同编号[1]) autoit.send(self.message1) m1.click(self.IMWin, '', screen_point.合同金额[0], screen_point.合同金额[1]) autoit.send(self.message2) m1.click(self.IMWin, '', screen_point.合同签订日期[0], screen_point.合同签订日期[1]) m1.click(self.IMWin, '', screen_point.今天签订[0], screen_point.今天签订[1]) m1.click(self.IMWin, '', screen_point.建设单位[0], screen_point.建设单位[1]) autoit.send(self.message3) m1.click(self.IMWin, '', screen_point.施工单位[0], screen_point.施工单位[1]) autoit.send(self.message4) m1.click(self.IMWin, '', screen_point.起止桩号[0], screen_point.起止桩号[1]) autoit.send(self.message5) m1.click(self.IMWin, '', screen_point.合同段长度[0], screen_point.合同段长度[1]) autoit.send(self.message6) m1.click(self.IMWin, '', screen_point.计划开工日期[0], screen_point.计划开工日期[1]) m1.click(self.IMWin, '', screen_point.今天开工[0], screen_point.今天开工[1]) m1.click(self.IMWin, '', screen_point.标段号[0], screen_point.标段号[1]) autoit.send(self.message7) m1.click(self.IMWin, '', screen_point.项目名称[0], screen_point.项目名称[1]) autoit.send(self.message8) m1.click(self.IMWin, '', screen_point.监理名称[0], screen_point.监理名称[1]) autoit.send(self.message9) m1.click(self.IMWin, '', screen_point.结束桩号[0], screen_point.结束桩号[1]) autoit.send(self.message10) m1.click(self.IMWin, '', screen_point.计划完工日期[0], screen_point.计划完工日期[1]) m1.click(self.IMWin, '', screen_point.今天完工[0], screen_point.今天完工[1]) m1.move(self.IMWin, '', 960, 590) autoit.mouse_wheel('down', 2) m1.click(self.IMWin, '', screen_point.工期[0], screen_point.工期[1]) autoit.send(self.message11) m1.click(self.IMWin, '', screen_point.保存[0], screen_point.保存[1]) else: raise Exception('没有检测到IM窗口!')
def measure_point_management(self): """测点管理""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.任务[0], screen_point.任务[1]) m1.click(self.BECivilWin, '', screen_point.测点管理[0], screen_point.测点管理[1]) sleep(1) # 无法识别测点列表窗口 # 添加 m1.click(self.BECivilWin, '', 1185, 270) sleep(1) w1 = WinControl('新建测点') if w1.exists(): w1.wait(3) # 选择深层位移 m1.click('新建测点', '', 980, 445) sleep(1) m1.click('新建测点', '', 980, 515) sleep(1) # 测点名称 m1.click('新建测点', '', 980, 480) autoit.send('测点名称123') sleep(1) # 选择位置 m1.click('新建测点', '', 850, 520) sleep(1) m1.click(self.BECivilWin, '', 750, 620) m1.click(self.BECivilWin, '', 750, 620, button='right') m1.click(self.BECivilWin, '', 710, 635) sleep(1) w1.controlClick("[CLASS:Button; INSTANCE:1]") else: raise Exception('未打开新建测点窗口') sleep(2) # 数据读取 m1.click(self.BECivilWin, '', 1380, 270) sleep(1) w2 = WinControl("打开") if w2.exists(): w2.wait(3) m1.click('打开', '', 940, 45) w2.controlSetText('[CLASS:Edit; INSTANCE:2]', self.uploadaddress) autoit.send("{ENTER}") sleep(1) w2.controlSetText('[CLASS:Edit; INSTANCE:1]', '测点数据读取模板.xlsx') w2.controlClick('[CLASS:Button; INSTANCE:1]') sleep(2) w3 = WinControl('数据读取设置') if w3.exists(): w3.wait(3) # 数据表名 m1.click('数据读取设置', '', 980, 435) sleep(1) # 深层位移 m1.click('数据读取设置', '', 980, 455) sleep(1) # 数据类型 m1.click('数据读取设置', '', 980, 470) sleep(1) # 深层位移 m1.click('数据读取设置', '', 980, 597) sleep(1) w3.controlClick('[CLASS:Button; INSTANCE:1]') else: raise Exception('未打开数据读取设置窗口') else: raise Exception('未识别打开窗口') sleep(1) # 关闭测点管理 m1.click(self.BECivilWin, '', screen_point.测点管理[0], screen_point.测点管理[1]) else: raise Exception("未识别市政窗口")
def measure_report(self): """监测报告""" w0 = WinControl(self.BECivilWin) if w0.exists(): w0.wait(3) m1 = MouseControl() m1.click(self.BECivilWin, '', screen_point.任务[0], screen_point.任务[1]) m1.click(self.BECivilWin, '', screen_point.监测报告[0], screen_point.监测报告[1]) sleep(1) # 创建报告 m1.click(self.BECivilWin, '', 1190, 270) sleep(1) w1 = WinControl("新建报告") if w1.exists(): w1.wait(3) # 报告名称 m1.click('新建报告', '', 980, 400) autoit.send('测试脚本用报告') # 期号 m1.click('新建报告', '', 980, 440) autoit.send('1') # 编号 m1.click('新建报告', '', 980, 480) autoit.send('123456') # 承包单位 m1.click('新建报告', '', 980, 570) autoit.send('测试脚本用承包单位') # 监理单位 m1.click('新建报告', '', 980, 615) autoit.send('测试脚本用监理单位') sleep(1) w1.controlClick('[CLASS:Button; INSTANCE:1]') else: raise Exception('未打开新建报告窗口') # 点击名称 m1.click(self.BECivilWin, '', 1320, 340) sleep(2) w2 = WinControl("表单列表") if w2.exists(): w2.wait(3) w2.controlClick("[CLASS:Button; INSTANCE:1]") sleep(1) MissionFunctions().add_form() sleep(1) w2.controlClick("[CLASS:Button; INSTANCE:1]") sleep(1) MissionFunctions().add_form(565, '脚本测试用监测成果分析报告') m1.click('表单列表', '', 1260, 235) else: raise Exception('未打开表单列表窗口') # 点击编辑 m1.click(self.BECivilWin, '', 1800, 340) sleep(1) w3 = WinControl("编辑报告") if w3.exists(): w3.wait(3) m1.click('编辑报告', '', 960, 400) autoit.send('测试脚本用报告更改') sleep(1) w3.controlClick("[CLASS:Button; INSTANCE:1]") else: raise Exception("未打开编辑报告窗口") # 点击导出 m1.click(self.BECivilWin, '', 1860, 340) sleep(1) w4 = WinControl('另存为') if w4.exists(): w4.wait(3) m1.click('另存为', '', 1030, 45) w4.controlSetText("[CLASS:Edit; INSTANCE:2]", self.downloadaddress) sleep(1) w4.controlClick('[CLASS:Button; INSTANCE:1]') sleep(1) w5 = WinControl('确认另存为') if w5.exists(): w5.wait(3) w5.controlClick("[CLASS:Button; INSTANCE:1]") else: pass sleep(2) if w0.exists(): w0.wait(3) t1 = w0.getPos() if t1 == (845, 438, 1075, 602): pass else: raise Exception('Something went wrong.') w0.controlClick("[CLASS:Button; INSTANCE:2]") else: pass else: raise Exception('未成功导出报告') sleep(2) # 全部勾选报告 m1.click(self.BECivilWin, '', 1172, 340) sleep(1) # 删除 m1.click(self.BECivilWin, '', 1290, 270) sleep(1) if w0.exists(): w0.wait(3) t2 = w0.getPos() if t2 == (845, 438, 1075, 602): pass else: raise Exception('Something went wrong.') w0.controlClick("[CLASS:Button; INSTANCE:1]") else: raise Exception('删除报告失败') sleep(1) m1.click(self.BECivilWin, '', screen_point.监测报告[0], screen_point.监测报告[1]) else: raise Exception('未识别市政窗口')