class test001: def __init__(self): self.__logger = ILog(__file__) self.path = set_img_res_path(__file__) def Main(self): #网站 self.__logger.debug(' "StepNodeTag:171243492372",Note:') iie.open_url(url='www.baidu.com')
def __init__(self, **kwargs): self.__logger = ILog(__file__) self.path = set_img_res_path(__file__) self.robot_no = '' self.proc_no = '' self.job_no = '' self.input_arg = '' if ('robot_no' in kwargs.keys()): self.robot_no = kwargs['robot_no'] if ('proc_no' in kwargs.keys()): self.proc_no = kwargs['proc_no'] if ('job_no' in kwargs.keys()): self.job_no = kwargs['job_no'] ILog.JOB_NO, ILog.OLD_STDOUT = self.job_no, sys.stdout sys.stdout = StdOutHook(self.job_no, sys.stdout) ExceptionHandler.JOB_NO, ExceptionHandler.OLD_STDERR = self.job_no, sys.stderr sys.excepthook = ExceptionHandler.handle_exception if ('input_arg' in kwargs.keys()): self.input_arg = kwargs['input_arg'] if (len(self.input_arg) <= 0): self.input_arg = iinput.load_init(__file__) if self.input_arg is None: sys.exit(0) self.dict_info = { 'AmountInWords': '佰叁拾圆叁角肆分', 'NoteDrawer': '谢登梅', 'SellerAddress': '深州市龙华区庆湾街道庆津大道乌庆旺路文汇处民治商务中心1栋115栋、2、3栋、4幢009栋7553323188', 'CommodityPrice': '[]', 'CommodityNum': '[]', 'SellerRegisterNum': '91440300689404127F', 'SellerBank': '农业银行龙华支行41028900040099987', 'Remarks': '订单号1047426466044621910支付日期2020-06-07', 'CommodityTaxRate': '[]', 'TotalTax': '62.05', 'CheckCode': '17960524178417916383', 'InvoiceCode': '044031900111', 'InvoiceDate': '2020年06月11日', 'PurchaserRegisterNum': '91440300MA5EGKDJ92', 'InvoiceTypeOrg': '深圳增值税电子普通发票', 'Password': '', 'PurchaserBank': '', 'AmountInFiguers': '937.34', 'Checker': '郑晓碧', 'TotalAmount': '875.29', 'CommodityAmount': "[{'row':'1','word':'875.29'}]", 'PurchaserName': '深圳市蓝禾技术有限公司', 'CommodityType': '[]', 'InvoiceType': '电子普通发票', 'PurchaserAddress': '', 'CommodityTax': "[{'row':'1','word':'62.05'}]", 'CommodityUnit': '[]', 'Payee': '刘笑额', 'SellerName': '深圳康润华商贸有限公司', 'CommodityName': "[{'row':'1','word':'(详见销货清单'}]", 'InvoiceNum': '23838102' }
class IResult(object): ''' classdocs ''' __logger = ILog(__file__) def __init__(self): ''' Constructor ''' ''' 返回状态 0:成功 1:失败 ''' status = 0 err = None obj = None def echo_result(self): if self.status == 0: msg = "[success]" else: msg = "[fail]" msg = u'return result :' + msg + '[err=' + str( self.err) + '][obj=' + str(self.obj) + ']' self.__logger.info(msg)
def __init__(self, **kwargs): self.__logger = ILog(__file__) self.path = set_img_res_path(__file__) self.robot_no = '' self.proc_no = '' self.job_no = '' self.input_arg = '' if ('robot_no' in kwargs.keys()): self.robot_no = kwargs['robot_no'] if ('proc_no' in kwargs.keys()): self.proc_no = kwargs['proc_no'] if ('job_no' in kwargs.keys()): self.job_no = kwargs['job_no'] if ('input_arg' in kwargs.keys()): self.input_arg = kwargs['input_arg'] self.input_arg = self.input_arg.replace("\\", "/") self.pwd = 'xKiMIyo=' self.user = '******'
def __init__(self, **kwargs): self.__logger = ILog(__file__) self.path = set_img_res_path(__file__) self.robot_no = '' self.proc_no = '' self.job_no = '' self.input_arg = '' if ('robot_no' in kwargs.keys()): self.robot_no = kwargs['robot_no'] if ('proc_no' in kwargs.keys()): self.proc_no = kwargs['proc_no'] if ('job_no' in kwargs.keys()): self.job_no = kwargs['job_no'] ILog.JOB_NO, ILog.OLD_STDOUT = self.job_no, sys.stdout sys.stdout = StdOutHook(self.job_no, sys.stdout) ExceptionHandler.JOB_NO, ExceptionHandler.OLD_STDERR = self.job_no, sys.stderr sys.excepthook = ExceptionHandler.handle_exception if ('input_arg' in kwargs.keys()): self.input_arg = kwargs['input_arg'] if (len(self.input_arg) <= 0): self.input_arg = iinput.load_init(__file__) if self.input_arg is None: sys.exit(0)
def __init__(self,**kwargs): self.__logger = ILog(__file__) self.path = set_img_res_path(__file__) self.robot_no = '' self.proc_no = '' self.job_no = '' self.input_arg = '' if('robot_no' in kwargs.keys()): self.robot_no = kwargs['robot_no'] if('proc_no' in kwargs.keys()): self.proc_no = kwargs['proc_no'] if('job_no' in kwargs.keys()): self.job_no = kwargs['job_no'] if('input_arg' in kwargs.keys()): self.input_arg = kwargs['input_arg'] if(len(self.input_arg) <= 0): self.input_arg = iinput.load_init(__file__) if self.input_arg is None: sys.exit(0)
class lanhe_fapiao_1: def __init__(self, **kwargs): self.__logger = ILog(__file__) self.path = set_img_res_path(__file__) self.robot_no = '' self.proc_no = '' self.job_no = '' self.input_arg = '' if ('robot_no' in kwargs.keys()): self.robot_no = kwargs['robot_no'] if ('proc_no' in kwargs.keys()): self.proc_no = kwargs['proc_no'] if ('job_no' in kwargs.keys()): self.job_no = kwargs['job_no'] ILog.JOB_NO, ILog.OLD_STDOUT = self.job_no, sys.stdout sys.stdout = StdOutHook(self.job_no, sys.stdout) ExceptionHandler.JOB_NO, ExceptionHandler.OLD_STDERR = self.job_no, sys.stderr sys.excepthook = ExceptionHandler.handle_exception if ('input_arg' in kwargs.keys()): self.input_arg = kwargs['input_arg'] if (len(self.input_arg) <= 0): self.input_arg = iinput.load_init(__file__) if self.input_arg is None: sys.exit(0) self.dict_info = { 'AmountInWords': '佰叁拾圆叁角肆分', 'NoteDrawer': '谢登梅', 'SellerAddress': '深州市龙华区庆湾街道庆津大道乌庆旺路文汇处民治商务中心1栋115栋、2、3栋、4幢009栋7553323188', 'CommodityPrice': '[]', 'CommodityNum': '[]', 'SellerRegisterNum': '91440300689404127F', 'SellerBank': '农业银行龙华支行41028900040099987', 'Remarks': '订单号1047426466044621910支付日期2020-06-07', 'CommodityTaxRate': '[]', 'TotalTax': '62.05', 'CheckCode': '17960524178417916383', 'InvoiceCode': '044031900111', 'InvoiceDate': '2020年06月11日', 'PurchaserRegisterNum': '91440300MA5EGKDJ92', 'InvoiceTypeOrg': '深圳增值税电子普通发票', 'Password': '', 'PurchaserBank': '', 'AmountInFiguers': '937.34', 'Checker': '郑晓碧', 'TotalAmount': '875.29', 'CommodityAmount': "[{'row':'1','word':'875.29'}]", 'PurchaserName': '深圳市蓝禾技术有限公司', 'CommodityType': '[]', 'InvoiceType': '电子普通发票', 'PurchaserAddress': '', 'CommodityTax': "[{'row':'1','word':'62.05'}]", 'CommodityUnit': '[]', 'Payee': '刘笑额', 'SellerName': '深圳康润华商贸有限公司', 'CommodityName': "[{'row':'1','word':'(详见销货清单'}]", 'InvoiceNum': '23838102' } def flow1(self): #增值税发票OCR self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:flow1,StepNodeTag:20201030113643160121,Title:增值税发票OCR,Note:') tvar_20201030113643161122 = iocr.vat_recognize( image_path='E:/fapiao/不干胶发票0608.pdf') print('[flow1] [增值税发票OCR] [20201030113643160121] 返回值:[' + str(type(tvar_20201030113643161122)) + ']' + str(tvar_20201030113643161122)) #输出 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:flow1,StepNodeTag:20201030113715259124,Title:输出,Note:' ) rpa_str.iprints(tvar_20201030113643161122) def flow2(self): yzm_pic = None tishi = None list_1 = [ '电子普通发票', '深圳增值税电子普通发票', '91440300MA5EGKDJ92', '2020年06月11日', '044031900111', '23838102', '17960524178417916383', '875.29', '62.05', '937.34', "[{'row': '1', 'word': '(详见销货清单'}]" ] dict_info = { 'AmountInWords': '佰叁拾圆叁角肆分', 'NoteDrawer': '谢登梅', 'SellerAddress': '深州市龙华区庆湾街道庆津大道乌庆旺路文汇处民治商务中心1栋115栋、2、3栋、4幢009栋7553323188', 'CommodityPrice': '[]', 'CommodityNum': '[]', 'SellerRegisterNum': '91440300689404127F', 'SellerBank': '农业银行龙华支行41028900040099987', 'Remarks': '订单号1047426466044621910支付日期2020-06-07', 'CommodityTaxRate': '[]', 'TotalTax': '62.05', 'CheckCode': '17960524178417916383', 'InvoiceCode': '044031900111', 'InvoiceDate': '2020年06月11日', 'PurchaserRegisterNum': '91440300MA5EGKDJ92', 'InvoiceTypeOrg': '深圳增值税电子普通发票', 'Password': '', 'PurchaserBank': '', 'AmountInFiguers': '937.34', 'Checker': '郑晓碧', 'TotalAmount': '875.29', 'CommodityAmount': "[{'row':'1','word':'875.29'}]", 'PurchaserName': '深圳市蓝禾技术有限公司', 'CommodityType': '[]', 'InvoiceType': '电子普通发票', 'PurchaserAddress': '', 'CommodityTax': "[{'row':'1','word':'62.05'}]", 'CommodityUnit': '[]', 'Payee': '刘笑额', 'SellerName': '深圳康润华商贸有限公司', 'CommodityName': "[{'row':'1','word':'(详见销货清单'}]", 'InvoiceNum': '23838102' } code = None #网站 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:2317224431623,Title:网站,Note:') time.sleep(0.5) iie.open_url( ie_path='C:/Program Files (x86)/Internet Explorer/iexplore.exe', url='https://inv-veri.chinatax.gov.cn/index.html') time.sleep(0.5) # Try异常 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:flow2,StepNodeTag:20201027172041803566,Title:Try异常,Note:') try: #鼠标点击 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:flow2,StepNodeTag:20201027172049219568,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000, button='left', curson='Center', image=r'snapshot_20201029175005894.png', image_size=r'64X15', win_title=r'此站点不安全 - Internet Explorer', continue_on_error='break', img_res_path=self.path) #鼠标点击 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:flow2,StepNodeTag:20201027172102123570,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000, button='left', curson='Center', image=r'snapshot_20201029175415351.png', image_size=r'161X28', win_title=r'此站点不安全 - Internet Explorer', continue_on_error='break', img_res_path=self.path) except Exception as e: pass finally: pass #热键输入 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:240950181343,Title:热键输入,Note:') ikeyboard.key_send_cs(waitfor=10.000, text=r'#{UP}') time.sleep(2.5) #鼠标点击 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:2317224431622,Title:鼠标点击,Note:') iie.do_click_pos(waitfor=10.000, run_mode='unctrl', button='left', curson='center', continue_on_error='break', win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', selector=r'#fpdm', url=r'https://inv-veri.chinatax.gov.cn/index.html') time.sleep(0.8) #模拟按键 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:2317224431621,Title:模拟按键,Note:输入发票代码' ) time.sleep(0.5) ikeyboard.key_send_cs(waitfor=10.000, text='044031900111') time.sleep(0.6) #模拟按键 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:2317224431620,Title:模拟按键,Note:') time.sleep(0.5) ikeyboard.key_send_cs(waitfor=10.000, text='{TAB}') #模拟按键 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:2317224431619,Title:模拟按键,Note:输入发票号码' ) time.sleep(0.5) ikeyboard.key_send_cs(waitfor=10.000, text='23838102') #模拟按键 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:2317224431618,Title:模拟按键,Note:') time.sleep(0.5) ikeyboard.key_send_cs(waitfor=10.000, text='{TAB}') #模拟按键 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:2317224431617,Title:模拟按键,Note:开票日期') time.sleep(0.5) ikeyboard.key_send_cs(waitfor=10.000, text='20200611') #模拟按键 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:2317224431616,Title:模拟按键,Note:') time.sleep(0.5) ikeyboard.key_send_cs(waitfor=10.000, text='{Tab}') #图片检测 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:2317224431613,Title:图片检测,Note:判断输入内容' ) tvar_2020102717112596416 = iimg.img_exists( waitfor=30.000, win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', image=r'snapshot_20201030101359793.png', img_res_path=self.path) print('[flow2] [图片检测] [2317224431613] 返回值:[' + str(type(tvar_2020102717112596416)) + ']' + str(tvar_2020102717112596416)) time.sleep(0.5) def Main(self): #子流程 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:Main,StepNodeTag:20201027172332623803,Title:子流程,Note:' ) tvar202010271723326238031 = self.flow2() print('[Main] [子流程] [20201027172332623803] 返回值:[' + str(type(tvar202010271723326238031)) + ']' + str(tvar202010271723326238031))
class Open_SQL2008: def __init__(self, **kwargs): self.__logger = ILog(__file__) self.path = set_img_res_path(__file__) self.robot_no = '' self.proc_no = '' self.job_no = '' self.input_arg = '' if ('robot_no' in kwargs.keys()): self.robot_no = kwargs['robot_no'] if ('proc_no' in kwargs.keys()): self.proc_no = kwargs['proc_no'] if ('job_no' in kwargs.keys()): self.job_no = kwargs['job_no'] if ('input_arg' in kwargs.keys()): self.input_arg = kwargs['input_arg'] self.input_arg = self.input_arg.replace("\\", "/") self.pwd = 'xKiMIyo=' self.user = '******' def approval(self): # 鼠标点击 self.__logger.debug('Flow:approval,StepNodeTag:14160829843157,Note:') iie.do_click_pos(win_title=r'合同管理系统 - Internet Explorer', url=r'http://localhost/grwl/Main.aspx', selector=r'#TreeView1n1 > IMG:nth-of-type(1)', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', waitfor=10, scroll_view='no') # 鼠标点击 self.__logger.debug('Flow:approval,StepNodeTag:14160906410160,Note:') time.sleep(0.5) iie.do_click_pos(win_title=r'合同管理系统 - Internet Explorer', url=r'http://localhost/grwl/Main.aspx', selector=r'#TreeView1t3', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', waitfor=10, scroll_view='no') # 鼠标点击 self.__logger.debug('Flow:approval,StepNodeTag:14161050177162,Note:') time.sleep(0.5) iie.do_click_pos(win_title=r'合同管理系统 - Internet Explorer', title=r'合同发起', selector=r'#btnAdd', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', waitfor=10, scroll_view='no') # 鼠标点击 self.__logger.debug('Flow:approval,StepNodeTag:14161213450164,Note:') iie.do_click_pos(win_title=r'合同管理系统 - Internet Explorer', title=r'合同发起', selector=r'#searchcn10291', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', waitfor=10, scroll_view='no') # 键盘输入 self.__logger.debug('Flow:approval,StepNodeTag:14161908967175,Note:') time.sleep(0.5) ikeyboard.key_send_cs(text='{DOWN}{ENTER}', waitfor=10) # 鼠标点击 self.__logger.debug('Flow:approval,StepNodeTag:14162054646178,Note:') iie.do_click_pos(win_title=r'合同管理系统 - Internet Explorer', title=r'合同发起', selector=r'#searchcn10270', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', waitfor=10, scroll_view='no') # 键盘输入 self.__logger.debug('Flow:approval,StepNodeTag:14162054646177,Note:') time.sleep(0.5) ikeyboard.key_send_cs(text='{DOWN}{ENTER}', waitfor=10) # 键盘输入 self.__logger.debug('Flow:approval,StepNodeTag:14162214581185,Note:') time.sleep(0.5) ikeyboard.key_send_cs(text='20191114_test_1{RSHIFT}', waitfor=10) # 鼠标点击 self.__logger.debug('Flow:approval,StepNodeTag:14162330489186,Note:') iie.do_click_pos(win_title=r'合同管理系统 - Internet Explorer', title=r'合同发起', selector=r'#searchcn10273', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', waitfor=10, scroll_view='no') # 键盘输入 self.__logger.debug('Flow:approval,StepNodeTag:14162330489187,Note:') time.sleep(0.5) ikeyboard.key_send_cs(text='{DOWN}{ENTER}', waitfor=10) # 鼠标点击 self.__logger.debug('Flow:approval,StepNodeTag:14162354762195,Note:') iie.do_click_pos(win_title=r'合同管理系统 - Internet Explorer', title=r'合同发起', selector=r'#searchcn10274img', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', waitfor=10, scroll_view='no') # 鼠标点击 self.__logger.debug('Flow:approval,StepNodeTag:14162436852202,Note:') iie.do_click_pos(win_title=r'合同管理系统 - Internet Explorer', title=r'请选择', selector=r'#xgvData_DXDataRow0 > TD:nth-of-type(1)', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', waitfor=10, scroll_view='no') # 鼠标点击 self.__logger.debug('Flow:approval,StepNodeTag:14162447299204,Note:') iie.do_click_pos(win_title=r'合同管理系统 - Internet Explorer', title=r'请选择', selector=r'#btnSearchSelect', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', waitfor=10, scroll_view='no') def login(self): # 打开浏览器 self.__logger.debug('Flow:login,StepNodeTag:14155052697138,Note:') ibrowse.open_browser(browser_type='ie', url="http://localhost/grwl/") # 热键输入 self.__logger.debug('Flow:login,StepNodeTag:14155052697137,Note:') ikeyboard.key_send_cs(text='!{SPACE}', waitfor=10) # 键盘输入 self.__logger.debug('Flow:login,StepNodeTag:14155052697136,Note:') time.sleep(0.5) ikeyboard.key_send_cs(text='X', waitfor=10) # 键盘输入 self.__logger.debug('Flow:login,StepNodeTag:14155052697130,Note:') time.sleep(0.5) ikeyboard.key_send_cs(text='{TAB}', waitfor=10) # 键盘输入 self.__logger.debug('Flow:login,StepNodeTag:14155052697131,Note:') time.sleep(0.5) ikeyboard.key_send_cs(text='ZCAdmin{LSHIFT}', waitfor=10) # 键盘输入 self.__logger.debug('Flow:login,StepNodeTag:14155052697135,Note:') time.sleep(0.5) ikeyboard.key_send_cs(text='{TAB}', waitfor=10) # 键盘输入 self.__logger.debug('Flow:login,StepNodeTag:14155052697134,Note:') time.sleep(0.5) ikeyboard.key_send_cs(text=self.pwd, waitfor=10) # 鼠标点击 self.__logger.debug('Flow:login,StepNodeTag:14155052697139,Note:') time.sleep(0.5) iie.do_click_pos( win_title=r'合同管理系统 - Internet Explorer', url= r'http://localhost/grwl/Login.aspx?ReturnUrl=%2fgrwl%2fdefault.aspx', selector=r'#imgbtnLogin', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', waitfor=10, scroll_view='no') def Main(self): # 子流程:login self.__logger.debug('Flow:Main,StepNodeTag:14155314001153,Note:') (temptemp) = self.login() # 子流程:approval self.__logger.debug('Flow:Main,StepNodeTag:14161350985170,Note:') (temptemp) = self.approval()
class weibo: def __init__(self, **kwargs): self.__logger = ILog(__file__) self.path = set_img_res_path(__file__) self.robot_no = '' self.proc_no = '' self.job_no = '' self.input_arg = '' if ('robot_no' in kwargs.keys()): self.robot_no = kwargs['robot_no'] if ('proc_no' in kwargs.keys()): self.proc_no = kwargs['proc_no'] if ('job_no' in kwargs.keys()): self.job_no = kwargs['job_no'] ILog.JOB_NO, ILog.OLD_STDOUT = self.job_no, sys.stdout sys.stdout = StdOutHook(self.job_no, sys.stdout) ExceptionHandler.JOB_NO, ExceptionHandler.OLD_STDERR = self.job_no, sys.stderr sys.excepthook = ExceptionHandler.handle_exception if ('input_arg' in kwargs.keys()): self.input_arg = kwargs['input_arg'] if (len(self.input_arg) <= 0): self.input_arg = iinput.load_init(__file__) if self.input_arg is None: sys.exit(0) def flow1(self): #鼠标点击 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:flow1,StepNodeTag:2020112121391871676,Title:鼠标点击,Note:' ) selectorJson = { "selector": [{ "ControlType": "文本", "ControlTypeID": "0xC364", "Index": "1" }, { "ControlType": "窗格", "ControlTypeID": "0xC371", "Index": "1" }, { "ControlType": "窗格", "ControlTypeID": "0xC371", "Index": "1" }, { "ControlType": "列表项目", "ControlTypeID": "0xC357", "Index": "8" }, { "ControlType": "列表", "ControlTypeID": "0xC358", "Index": "1" }, { "ControlType": "窗格", "ControlTypeID": "0xC371", "Index": "1" }, { "ControlType": "窗格", "ControlTypeID": "0xC371", "Index": "2" }, { "ControlType": "窗格", "ControlTypeID": "0xC371", "Index": "2" }, { "ControlType": "窗格", "ControlTypeID": "0xC371", "Index": "2" }, { "ControlType": "窗格", "ControlTypeID": "0xC371", "Index": "2" }] } iautomation.do_click(waitfor=10.000, run_mode='unctrl', button='left', curson='center', win_name=r'微信', win_class=r'WeChatMainWndForPC', selector=selectorJson) def Main(self): lv_1 = 'body > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(2) > DIV:nth-of-type(1) > DIV:nth-of-type(2) > DIV:nth-of-type(2) > DIV:nth-of-type(7) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(3) > UL:nth-of-type(1) > LI:nth-of-type(' lv_2 = ') > DIV:nth-of-type(1) > DIV:nth-of-type(2) > DIV:nth-of-type(5) > P:nth-of-type(1) > A:nth-of-type(1) > SPAN:nth-of-type(1)' lv_3 = None lv_4 = None flag = None
button='left', curson='center', win_name=r'微信', win_class=r'WeChatMainWndForPC', selector=selectorJson) def Main(self): lv_1 = 'body > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(2) > DIV:nth-of-type(1) > DIV:nth-of-type(2) > DIV:nth-of-type(2) > DIV:nth-of-type(7) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(3) > UL:nth-of-type(1) > LI:nth-of-type(' lv_2 = ') > DIV:nth-of-type(1) > DIV:nth-of-type(2) > DIV:nth-of-type(5) > P:nth-of-type(1) > A:nth-of-type(1) > SPAN:nth-of-type(1)' lv_3 = None lv_4 = None flag = None if __name__ == '__main__': ILog.begin_init() robot_no = '' proc_no = '' job_no = '' input_arg = '' try: argv = sys.argv[1:] opts, args = getopt.getopt( argv, "hr:p:j:i:", ["robot = ", "proc = ", "job = ", "input = "]) except getopt.GetoptError: print('robot.py -r <robot> -p <proc> -j <job>') for opt, arg in opts: if opt == '-h': print('robot.py -r <robot> -p <proc> -j <job>') elif opt in ("-r", "--robot"): robot_no = arg
''' Created on 2018。3.29 @author: Wu.Xin 主要用于键盘类的操作 ''' from ctypes import * from ubpa.ierror import * from ubpa.iconstant import * from ubpa.ilog import ILog import ubpa.iwin as iwin import ubpa.encrypt as encrypt import time __logger = ILog(__file__) dll = windll.LoadLibrary( "../Com.Isearch.Func.AutoIt/AutoItX3.dll") # 调AutoItX3动态库 str_dll = windll.LoadLibrary("../Com.Isearch.Driver.WinIO/RpaClientWinio.dll") ''' 发送键盘事件 win_title :窗口标题 ''' def key_send_cs(win_title=None, text=None, waitfor=WAIT_FOR): __logger.debug('keyboard send key:[win:' + str(win_title) + ']' + str(text)) try:
class lanhe_fapiao: def __init__(self, **kwargs): self.__logger = ILog(__file__) self.path = set_img_res_path(__file__) self.robot_no = '' self.proc_no = '' self.job_no = '' self.input_arg = '' if ('robot_no' in kwargs.keys()): self.robot_no = kwargs['robot_no'] if ('proc_no' in kwargs.keys()): self.proc_no = kwargs['proc_no'] if ('job_no' in kwargs.keys()): self.job_no = kwargs['job_no'] if ('input_arg' in kwargs.keys()): self.input_arg = kwargs['input_arg'] self.input_arg = self.input_arg.replace("\\", "/") self.dict_info = { 'AmountInWords': '佰叁拾圆叁角肆分', 'NoteDrawer': '谢登梅', 'SellerAddress': '深州市龙华区庆湾街道庆津大道乌庆旺路文汇处民治商务中心1栋115栋、2、3栋、4幢009栋7553323188', 'CommodityPrice': '[]', 'CommodityNum': '[]', 'SellerRegisterNum': '91440300689404127F', 'SellerBank': '农业银行龙华支行41028900040099987', 'Remarks': '订单号1047426466044621910支付日期2020-06-07', 'CommodityTaxRate': '[]', 'TotalTax': '62.05', 'CheckCode': '17960524178417916383', 'InvoiceCode': '044031900111', 'InvoiceDate': '2020年06月11日', 'PurchaserRegisterNum': '91440300MA5EGKDJ92', 'InvoiceTypeOrg': '深圳增值税电子普通发票', 'Password': '', 'PurchaserBank': '', 'AmountInFiguers': '937.34', 'Checker': '郑晓碧', 'TotalAmount': '875.29', 'CommodityAmount': "[{'row':'1','word':'875.29'}]", 'PurchaserName': '深圳市蓝禾技术有限公司', 'CommodityType': '[]', 'InvoiceType': '电子普通发票', 'PurchaserAddress': '', 'CommodityTax': "[{'row':'1','word':'62.05'}]", 'CommodityUnit': '[]', 'Payee': '刘笑额', 'SellerName': '深圳康润华商贸有限公司', 'CommodityName': "[{'row':'1','word':'(详见销货清单'}]", 'InvoiceNum': '23838102' } def flow2(self): yzm_pic = None tishi = None list_1 = [ '电子普通发票', '深圳增值税电子普通发票', '91440300MA5EGKDJ92', '2020年06月11日', '044031900111', '23838102', '17960524178417916383', '875.29', '62.05', '937.34', "[{'row': '1', 'word': '(详见销货清单'}]" ] dict_info = { 'AmountInWords': '佰叁拾圆叁角肆分', 'NoteDrawer': '谢登梅', 'SellerAddress': '深州市龙华区庆湾街道庆津大道乌庆旺路文汇处民治商务中心1栋115栋、2、3栋、4幢009栋7553323188', 'CommodityPrice': '[]', 'CommodityNum': '[]', 'SellerRegisterNum': '91440300689404127F', 'SellerBank': '农业银行龙华支行41028900040099987', 'Remarks': '订单号1047426466044621910支付日期2020-06-07', 'CommodityTaxRate': '[]', 'TotalTax': '62.05', 'CheckCode': '17960524178417916383', 'InvoiceCode': '044031900111', 'InvoiceDate': '2020年06月11日', 'PurchaserRegisterNum': '91440300MA5EGKDJ92', 'InvoiceTypeOrg': '深圳增值税电子普通发票', 'Password': '', 'PurchaserBank': '', 'AmountInFiguers': '937.34', 'Checker': '郑晓碧', 'TotalAmount': '875.29', 'CommodityAmount': "[{'row':'1','word':'875.29'}]", 'PurchaserName': '深圳市蓝禾技术有限公司', 'CommodityType': '[]', 'InvoiceType': '电子普通发票', 'PurchaserAddress': '', 'CommodityTax': "[{'row':'1','word':'62.05'}]", 'CommodityUnit': '[]', 'Payee': '刘笑额', 'SellerName': '深圳康润华商贸有限公司', 'CommodityName': "[{'row':'1','word':'(详见销货清单'}]", 'InvoiceNum': '23838102' } code = None #网站 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431623,Note:') iie.open_url(url='https://inv-veri.chinatax.gov.cn/index.html') time.sleep(0.5) # 热键输入 self.__logger.debug('Flow:flow2,StepNodeTag:240950181343,Note:') ikeyboard.key_send_cs(text='#{UP}', waitfor=10) time.sleep(2.5) # 鼠标点击 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431622,Note:') iie.do_click_pos(win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', url=r'https://inv-veri.chinatax.gov.cn/index.html', selector=r'#fpdm', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', continue_on_error=r'break', waitfor=10) time.sleep(0.8) # 键盘输入 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431621,Note:输入发票代码') time.sleep(0.5) ikeyboard.key_send_cs(text='044031900111', waitfor=10) time.sleep(0.6) # 键盘输入 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431620,Note:') time.sleep(0.5) ikeyboard.key_send_cs(text='{TAB}', waitfor=10) # 键盘输入 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431619,Note:输入发票号码') time.sleep(0.5) ikeyboard.key_send_cs(text='23838102', waitfor=10) # 键盘输入 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431618,Note:') time.sleep(0.5) ikeyboard.key_send_cs(text='{TAB}', waitfor=10) # 键盘输入 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431617,Note:开票日期') time.sleep(0.5) ikeyboard.key_send_cs(text='20200611', waitfor=10) # 键盘输入 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431616,Note:') time.sleep(0.5) ikeyboard.key_send_cs(text='{TAB}', waitfor=10) # 图像检测 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431613,Note:判断输入内容') tvar2317224431613 = iimg.img_exists( win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', img_res_path=self.path, image=r'snapshot_20200623142820581.png', fuzzy=True, confidence=0.85, waitfor=30) time.sleep(0.5) # IF-N分支 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431614,Note:判断') if tvar2317224431613: # 键盘输入 self.__logger.debug( 'Flow:flow2,StepNodeTag:2317224431612,Note:输入校验码') time.sleep(0.5) ikeyboard.key_send_cs(text='916383', waitfor=10) else: # 键盘输入 self.__logger.debug( 'Flow:flow2,StepNodeTag:2317224431615,Note:输入开具金额') time.sleep(0.5) ikeyboard.key_send_cs(text='937.34', waitfor=10) # While循环 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431611,Note:') while 1: # 鼠标点击 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431627,Note:') time.sleep(0.5) iie.do_click_pos( win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', url=r'https://inv-veri.chinatax.gov.cn/index.html', selector=r'#yzm_img', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', continue_on_error=r'break', waitfor=10) time.sleep(5) # 鼠标移动 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431628,Note:') iie.do_moveto_pos( win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', url=r'https://inv-veri.chinatax.gov.cn/index.html', selector= r'#content2 > TABLE:nth-of-type(1) > TBODY:nth-of-type(1) > TR:nth-of-type(6) > TD:nth-of-type(1)', curson=r'center', waitfor=10) time.sleep(5) # 截图 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431610,Note:') tishi = iimg.capture_image( win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', win_text=r'', left_indent=1253, top_indent=572, width=210, height=36, waitfor=30) time.sleep(0.8) # 截图 self.__logger.debug('Flow:flow2,StepNodeTag:231722443169,Note:') yzm_pic = iimg.capture_image( win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', win_text=r'', left_indent=992, top_indent=620, width=139, height=64, waitfor=30) time.sleep(0.8) # 自定义函数 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431625,Note:') tvar2317224431625 = GlobalFun.code_color(tishi, yzm_pic) #验证码 self.__logger.debug('Flow:flow2,StepNodeTag:231722443168,Note:') code = iocr.vcode_recognize( image_path=tvar2317224431625, code_type=8001, apiKey='8159a500cc9d4a69a71e6ac14263f029', secretKey='2d078aa8c13741239b3d00ced85832e3') time.sleep(1) # 鼠标点击 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431629,Note:') iie.do_click_pos( win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', url=r'https://inv-veri.chinatax.gov.cn/index.html', selector=r'#yzm', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', continue_on_error=r'break', waitfor=10) # 键盘输入 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431626,Note:') time.sleep(0.5) ikeyboard.key_send_cs(text=code, waitfor=10) # 鼠标点击 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431631,Note:') iie.do_click_pos( win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', url=r'https://inv-veri.chinatax.gov.cn/index.html', selector=r'#checkfp', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', continue_on_error=r'break', waitfor=10) time.sleep(3) # 图像检测 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431630,Note:') tvar2317224431630 = iimg.img_exists( win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', img_res_path=self.path, image=r'snapshot_20200623152556855.png', fuzzy=True, confidence=0.85, waitfor=5) # IF-N分支 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431632,Note:') if tvar2317224431630: # 鼠标点击 self.__logger.debug( 'Flow:flow2,StepNodeTag:2317224431634,Note:') iie.do_click_pos( win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', url=r'https://inv-veri.chinatax.gov.cn/index.html', selector=r'#popup_ok', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', continue_on_error=r'break', waitfor=10) time.sleep(0.8) # 鼠标点击 self.__logger.debug( 'Flow:flow2,StepNodeTag:2317224431635,Note:') iie.do_click_pos( win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', url=r'https://inv-veri.chinatax.gov.cn/index.html', selector=r'#yzm', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', continue_on_error=r'break', waitfor=10) time.sleep(0.8) # 热键输入 self.__logger.debug( 'Flow:flow2,StepNodeTag:2317224431636,Note:') ikeyboard.key_send_cs(text='^a', waitfor=10) # 键盘输入 self.__logger.debug( 'Flow:flow2,StepNodeTag:2317224431637,Note:') time.sleep(0.5) ikeyboard.key_send_cs(text='{BACKSPACE}', waitfor=10) else: # Break中断 self.__logger.debug( 'Flow:flow2,StepNodeTag:2317224431633,Note:') break # 图像检测 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431639,Note:') tvar2317224431639 = iimg.img_exists( win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', img_res_path=self.path, image=r'snapshot_20200623153842415.png', fuzzy=True, confidence=0.85, waitfor=5) # IF-N分支 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431638,Note:') if tvar2317224431639: # 代码块 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431745,Note:') list_1.append('否') #单元格写入 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431640,Note:') iexcel.write_cell(path='C:/Users/jky/Desktop/fapiao_info.xlsx', cell='A2', text=list_1, file_type='excel') # 鼠标点击 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431642,Note:') iie.do_click_pos( win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', url=r'https://inv-veri.chinatax.gov.cn/index.html', selector=r'#closebt', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', continue_on_error=r'break', waitfor=10) # 消息框 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431747,Note:') ibox.msgs_box('结束', timeout=0) else: # 代码块 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431746,Note:') list_1.append('是') #单元格写入 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431641,Note:') iexcel.write_cell(path='C:/Users/jky/Desktop/fapiao_info.xlsx', cell='A2', text=list_1, file_type='excel') # 鼠标点击 self.__logger.debug('Flow:flow2,StepNodeTag:23174311384140,Note:') iie.do_click_pos( win_title=r'国家税务总局全国增值税发票查验平台 - Internet Explorer', url=r'https://inv-veri.chinatax.gov.cn/index.html', selector=r'#closebt', button=r'left', curson=r'center', times=1, run_mode=r'unctrl', continue_on_error=r'break', waitfor=10) # 消息框 self.__logger.debug('Flow:flow2,StepNodeTag:2317224431743,Note:') ibox.msgs_box('结束', timeout=3) def Main(self): pass
from ctypes import * from ubpa.ilog import ILog import json import ubpa.encrypt as encrypt from ubpa.ierror import * import time from ubpa.iconstant import * import ubpa.iie as iie import ubpa.ics as ics import ubpa.iwin as iwin #dll = cdll.LoadLibrary("RpaAccessBridge.dll") dll = cdll.LoadLibrary("../Com.Isearch.Func.Java/RpaAccessBridge.dll") __logger = ILog(__file__) def set_element_val(program=None, title=None, className=None, selector=None, text=None, waitfor=WAIT_FOR): __logger.debug('[set_element_val] Set text start') try: text = encrypt.decrypt(str(text)) param = get_jsondata(program, title, className, selector, text=text) starttime = time.time() while True:
if __name__ == '__main__': robot_no = '' proc_no = '' job_no = '' input_arg = '' try: argv = sys.argv[1:] opts, args = getopt.getopt( argv, "hr:p:j:i:", ["robot = ", "proc = ", "job = ", "input = "]) except getopt.GetoptError: print('robot.py -r <robot> -p <proc> -j <job>') for opt, arg in opts: if opt == '-h': print('robot.py -r <robot> -p <proc> -j <job>') elif opt in ("-r", "--robot"): robot_no = arg elif opt in ("-p", "--proc"): proc_no = arg elif opt in ("-j", "--job"): job_no = arg elif opt in ("-i", "--input"): input_arg = arg pro = lanhe_fapiao(robot_no=robot_no, proc_no=proc_no, job_no=job_no, input_arg=input_arg) pro.flow2() ___logger = ILog(__file__) ___logger.debug('Class:Main,ProTag:Quit,Note:Exit')
class demo1: def __init__(self, **kwargs): self.__logger = ILog(__file__) self.path = set_img_res_path(__file__) self.robot_no = '' self.proc_no = '' self.job_no = '' self.input_arg = '' if ('robot_no' in kwargs.keys()): self.robot_no = kwargs['robot_no'] if ('proc_no' in kwargs.keys()): self.proc_no = kwargs['proc_no'] if ('job_no' in kwargs.keys()): self.job_no = kwargs['job_no'] ILog.JOB_NO, ILog.OLD_STDOUT = self.job_no, sys.stdout sys.stdout = StdOutHook(self.job_no, sys.stdout) ExceptionHandler.JOB_NO, ExceptionHandler.OLD_STDERR = self.job_no, sys.stderr sys.excepthook = ExceptionHandler.handle_exception if ('input_arg' in kwargs.keys()): self.input_arg = kwargs['input_arg'] if (len(self.input_arg) <= 0): self.input_arg = iinput.load_init(__file__) if self.input_arg is None: sys.exit(0) def Baidu_news(self): '''打开百度新闻\n''' lv_2 = 20 lv_1 = 10 #网站 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Baidu_news,StepNodeTag:2020091515062370615,Title:网站,Note:') iie.open_url( ie_path='C:/Program Files (x86)/Internet Explorer/iexplore.exe', url='www.baidu.com') #鼠标点击 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Baidu_news,StepNodeTag:2020091515075726216,Title:鼠标点击,Note:点击新闻' ) time.sleep(1) iie.do_click_pos(waitfor=10.000, run_mode='unctrl', button='left', curson='center', continue_on_error='break', win_title=r'百度一下,你就知道 - Internet Explorer', selector=r'#s-top-left > A:nth-of-type(1)', url=r'https://www.baidu.com/') time.sleep(1) def Baidu_search(self, pv_1=None): input = 'RPA' #网站 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Baidu_search,StepNodeTag:2020091702300252617,Title:网站,Note:') iie.open_url( ie_path='C:/Program Files (x86)/Internet Explorer/iexplore.exe', url='www.baidu.com') #鼠标点击 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Baidu_search,StepNodeTag:2020091702303042024,Title:鼠标点击,Note:' ) iie.do_click_pos(waitfor=10.000, run_mode='unctrl', button='left', curson='center', continue_on_error='break', win_title=r'百度一下,你就知道 - Internet Explorer', selector=r'#kw', url=r'https://www.baidu.com/') #模拟按键 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Baidu_search,StepNodeTag:2020091702310358326,Title:模拟按键,Note:' ) ikeyboard.key_send_cs(waitfor=10.000, text='{LShift}') #模拟按键 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Baidu_search,StepNodeTag:2020091702315568728,Title:模拟按键,Note:' ) ikeyboard.key_send_cs(waitfor=10.000, text=input) #鼠标点击 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Baidu_search,StepNodeTag:2020091702332197730,Title:鼠标点击,Note:' ) iie.do_click_pos(waitfor=10.000, run_mode='unctrl', button='left', curson='center', continue_on_error='break', win_title=r'百度一下,你就知道 - Internet Explorer', selector=r'#su', url=r'https://www.baidu.com/') def CSM_demo(self): product_code = 'i-search-20200917-0351' #网站 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:CSM_demo,StepNodeTag:2020091703094021399,Title:网站,Note:') iie.open_url( ie_path='C:/Program Files (x86)/Internet Explorer/iexplore.exe', url='http://122.112.200.222:9080/login.action') #设置文本 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:CSM_demo,StepNodeTag:20200917031229648101,Title:设置文本,Note:') iie.set_text( waitfor=10.000, text=r'ceshi001', selector= r'#loginWrap > UL:nth-of-type(1) > LI:nth-of-type(1) > INPUT:nth-of-type(1)', url=r'http://122.112.200.222:9080/login.action') #设置文本 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:CSM_demo,StepNodeTag:20200917031301891104,Title:设置文本,Note:') iie.set_text( waitfor=10.000, text=r'typSVU', selector= r'#loginWrap > UL:nth-of-type(1) > LI:nth-of-type(2) > INPUT:nth-of-type(1)', url=r'http://122.112.200.222:9080/login.action') #鼠标点击 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:CSM_demo,StepNodeTag:20200917031353836106,Title:鼠标点击,Note:') iie.do_click_pos( waitfor=10.000, run_mode='unctrl', button='left', curson='center', continue_on_error='break', win_title=r'双录系统-录音、录像、录屏 - Internet Explorer', selector= r'#loginWrap > UL:nth-of-type(1) > LI:nth-of-type(2) > INPUT:nth-of-type(2)', url=r'http://122.112.200.222:9080/login.action') #鼠标点击 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:CSM_demo,StepNodeTag:20200917031452058108,Title:鼠标点击,Note:') iie.do_click_pos(waitfor=10.000, run_mode='unctrl', button='left', curson='center', continue_on_error='break', win_title=r'双录系统-录音、录像、录屏 - Internet Explorer', selector=r'#popup_ok', url=r'http://122.112.200.222:9080/login.action') #鼠标点击 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:CSM_demo,StepNodeTag:20200917031802702110,Title:鼠标点击,Note:') iie.do_click_pos( waitfor=10.000, run_mode='unctrl', button='left', curson='center', continue_on_error='break', win_title=r'双录系统-录音、录像、录屏 - Internet Explorer', selector= r'#frame-nav > UL:nth-of-type(1) > LI:nth-of-type(1) > A:nth-of-type(1)', url=r'http://122.112.200.222:9080/login.action') #鼠标点击 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:CSM_demo,StepNodeTag:20200917031836401112,Title:鼠标点击,Note:') iie.do_click_pos( waitfor=10.000, run_mode='unctrl', button='left', curson='center', continue_on_error='break', win_title=r'双录系统-录音、录像、录屏 - Internet Explorer', selector= r'#MenuContext > TABLE:nth-of-type(1) > TBODY:nth-of-type(1) > TR:nth-of-type(1) > TD:nth-of-type(2) > LI:nth-of-type(5) > A:nth-of-type(1)', url=r'http://122.112.200.222:9080/login.action') #鼠标点击 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:CSM_demo,StepNodeTag:20200917031929670114,Title:鼠标点击,Note:') iie.do_click_pos( waitfor=10.000, run_mode='unctrl', button='left', curson='center', continue_on_error='break', win_title=r'双录系统-录音、录像、录屏 - Internet Explorer', selector= r'#ListForm > DIV:nth-of-type(2) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > A:nth-of-type(2)', title=r'理财管理') #设置文本 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:CSM_demo,StepNodeTag:20200917032133267116,Title:设置文本,Note:') iie.set_text( waitfor=10.000, text=product_code, selector= r'body > DIV:nth-of-type(1) > FORM:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(2) > UL:nth-of-type(1) > LI:nth-of-type(1) > INPUT:nth-of-type(1)', title=r'理财管理') #设置文本 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:CSM_demo,StepNodeTag:20200917032229059118,Title:设置文本,Note:') iie.set_text( waitfor=10.000, text=r'LL-demo', selector= r'body > DIV:nth-of-type(1) > FORM:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(2) > UL:nth-of-type(1) > LI:nth-of-type(2) > INPUT:nth-of-type(1)', title=r'理财管理') #设置文本 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:CSM_demo,StepNodeTag:20200917032304015120,Title:设置文本,Note:') iie.set_text(waitfor=10.000, text=r'S8', selector=r'#proType', title=r'理财管理') #设置文本 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:CSM_demo,StepNodeTag:20200917032344848122,Title:设置文本,Note:') iie.set_text(waitfor=10.000, text=r'5', selector=r'#proRiskLevel', title=r'理财管理') #设置文本 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:CSM_demo,StepNodeTag:20200917032410932124,Title:设置文本,Note:') iie.set_text(waitfor=10.000, text=r'3', selector=r'#videoDtaTime', title=r'理财管理') #设置文本 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:CSM_demo,StepNodeTag:20200917032513188130,Title:设置文本,Note:') iie.set_text(waitfor=10.000, text=r'刘浪测试', selector=r'#proDesc', title=r'理财管理') #鼠标点击 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:CSM_demo,StepNodeTag:20200917032903457132,Title:鼠标点击,Note:') iie.do_click_pos( waitfor=5.000, run_mode='unctrl', button='left', curson='center', continue_on_error='break', win_title=r'双录系统-录音、录像、录屏 - Internet Explorer', selector= r'#DetailForm > DIV:nth-of-type(1) > DIV:nth-of-type(3) > INPUT:nth-of-type(1)', title=r'理财管理') def Excel(self): text = None #获取文本 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:Excel,StepNodeTag:2020091703541846134,Title:获取文本,Note:' ) text = iie.get_text( waitfor=10.000, selector= r'#frame-nav > UL:nth-of-type(1) > LI:nth-of-type(1) > A:nth-of-type(1)', url=r'http://122.112.200.222:9080/login.action') print('[Excel] [获取文本] [2020091703541846134] 返回值:[' + str(type(text)) + ']' + str(text)) #输出 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:Excel,StepNodeTag:2020091703550173641,Title:输出,Note:') rpa_str.iprints(text) #单元格写入 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Excel,StepNodeTag:2020091703553501645,Title:单元格写入,Note:') tvar_2020091703553501646 = iexcel.write_cell( path='C:/Users/帅气可爱的小飞/Desktop/RPA_test1.xls', text=text) print('[Excel] [单元格写入] [2020091703553501645] 返回值:[' + str(type(tvar_2020091703553501646)) + ']' + str(tvar_2020091703553501646)) def text_input(self): password = None #网站 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:text_input,StepNodeTag:2020091702470364538,Title:网站,Note:') iie.open_url( ie_path='C:/Program Files (x86)/Internet Explorer/iexplore.exe', url='www.baidu.com') #设置文本 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:text_input,StepNodeTag:2020091702471776644,Title:设置文本,Note:') iie.set_text(waitfor=10.000, text=r'RPA', selector=r'.s_ipt', url=r'https://www.baidu.com/') #鼠标点击 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:text_input,StepNodeTag:2020091703023316894,Title:鼠标点击,Note:') iie.do_click_pos(waitfor=10.000, run_mode='unctrl', button='left', curson='center', continue_on_error='break', win_title=r'百度一下,你就知道 - Internet Explorer', selector=r'#su', url=r'https://www.baidu.com/') def Main(self): pass
def __init__(self): self.__logger = ILog(__file__) self.path = set_img_res_path(__file__)
class NewProject1: def __init__(self,**kwargs): self.__logger = ILog(__file__) self.path = set_img_res_path(__file__) self.robot_no = '' self.proc_no = '' self.job_no = '' self.input_arg = '' if('robot_no' in kwargs.keys()): self.robot_no = kwargs['robot_no'] if('proc_no' in kwargs.keys()): self.proc_no = kwargs['proc_no'] if('job_no' in kwargs.keys()): self.job_no = kwargs['job_no'] ILog.JOB_NO, ILog.OLD_STDOUT = self.job_no, sys.stdout sys.stdout = StdOutHook(self.job_no, sys.stdout) ExceptionHandler.JOB_NO, ExceptionHandler.OLD_STDERR = self.job_no, sys.stderr sys.excepthook = ExceptionHandler.handle_exception if('input_arg' in kwargs.keys()): self.input_arg = kwargs['input_arg'] if(len(self.input_arg) <= 0): self.input_arg = iinput.load_init(__file__) if self.input_arg is None: sys.exit(0) def flow1(self): #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:2020102811431669279,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',offsetX=100,times=2,image=r'snapshot_20201029102745076.png',image_size=r'107X19',win_title=r'银行日记账-条件查询',continue_on_error='break',img_res_path = self.path) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:2020102811443953682,Title:模拟按键,Note:') time.sleep(0.3) ikeyboard.key_send_cs(waitfor=10.000,text='2016') time.sleep(0.3) #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201029104525554947,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',offsetX=240,times=2,image=r'snapshot_20201029102745076.png',image_size=r'107X19',win_title=r'银行日记账-条件查询',continue_on_error='break',img_res_path = self.path) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201029104628537954,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text=11) #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201029103034188926,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',offsetX=100,times=2,image=r'snapshot_20201029103053436.png',image_size=r'94X18',win_title=r'银行日记账-条件查询',continue_on_error='break',img_res_path = self.path) time.sleep(0.3) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201029102936035924,Title:模拟按键,Note:') time.sleep(0.3) ikeyboard.key_send_cs(waitfor=10.000,text='2017') time.sleep(0.3) #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201029104712257957,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',offsetX=240,times=2,image=r'snapshot_20201029103053436.png',image_size=r'94X18',win_title=r'银行日记账-条件查询',continue_on_error='break',img_res_path = self.path) time.sleep(0.3) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201029104741631965,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='11') #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:2020102811454933884,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201028114606050.png',image_size=r'79X24',win_title=r'银行日记账-条件查询',continue_on_error='break',img_res_path = self.path) #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201028133001493128,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201028133026462.png',image_size=r'73X91',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201028133117833130,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='1102{Enter}{Enter}') #图片检测 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:20201029092629318884,Title:图片检测,Note:') tvar_20201029092629318885=iimg.img_exists(waitfor=30.000,win_title=r'金蝶EAS-IT_Test',image=r'snapshot_20201029092535882.png',img_res_path = self.path) print('[flow1] [图片检测] [20201029092629318884] 返回值:[' + str(type(tvar_20201029092629318885)) + ']' + str(tvar_20201029092629318885)) #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow1,StepNodeTag:2020102813020652490,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201029091730871.png',image_size=r'79X23',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path) def flow2(self,fangshi=None,leixing=None,initial=4,num=0,excel=0): #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201029100501969918,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',offsetX=10,image=r'snapshot_20201029100607886.png',image_size=r'14X24',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path) #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201029100714286921,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201029100801595.png',image_size=r'85X22',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path) #工作表行数获取 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028230910820504,Title:工作表行数获取,Note:') excel=iexcel.get_rows_count(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx') print('[flow2] [工作表行数获取] [20201028230910820504] 返回值:[' + str(type(excel)) + ']' + str(excel)) #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028143452321202,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201028143508572.png',image_size=r'77X29',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201029015023339827,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='{Tab}') # For循环 self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:20201028230954859509,Title:For循环,Note:') for num in range(excel-3): #单元格读取 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201029012445614787,Title:单元格读取,Note:') time.sleep(0.3) tvar_20201029012445614788=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='B'+str(initial),cell_type='time') print('[flow2] [单元格读取] [20201029012445614787] 返回值:[' + str(type(tvar_20201029012445614788)) + ']' + str(tvar_20201029012445614788)) time.sleep(0.3) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028143734693212,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text=tvar_20201029012445614788) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028150809975282,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='{Tab}') #单元格读取 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028144321938225,Title:单元格读取,Note:') time.sleep(0.3) tvar_20201028144321939226=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='C'+str(initial),cell_type='time') print('[flow2] [单元格读取] [20201028144321938225] 返回值:[' + str(type(tvar_20201028144321939226)) + ']' + str(tvar_20201028144321939226)) time.sleep(0.3) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028144335510228,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text=tvar_20201028144321939226) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028144459937234,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='{Tab}') #单元格读取 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028144459937236,Title:单元格读取,Note:') time.sleep(0.3) tvar_20201028144459937237=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='I'+str(initial),cell_type='string') print('[flow2] [单元格读取] [20201028144459937236] 返回值:[' + str(type(tvar_20201028144459937237)) + ']' + str(tvar_20201028144459937237)) time.sleep(0.3) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028144459937235,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text=tvar_20201028144459937237) time.sleep(0.5) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028151111503295,Title:模拟按键,Note:') time.sleep(0.5) ikeyboard.key_send_cs(waitfor=10.000,text='{Tab}') #单元格读取 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:202010291412063991055,Title:单元格读取,Note:') time.sleep(0.3) leixing=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='D'+str(initial),cell_type='string') print('[flow2] [单元格读取] [202010291412063991055] 返回值:[' + str(type(leixing)) + ']' + str(leixing)) time.sleep(0.3) # IF分支 self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:202010291416021701074,Title:IF分支,Note:') if leixing == '银收': #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:202010291416444871078,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='{Down 15}') elif leixing == '银付': #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:202010291417369811080,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='{Down 8}') else: pass #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028153949690307,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='{Enter}') #单元格读取 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154040326309,Title:单元格读取,Note:') time.sleep(0.3) tvar_20201028154040327310=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='E'+str(initial),cell_type=None) print('[flow2] [单元格读取] [20201028154040326309] 返回值:[' + str(type(tvar_20201028154040327310)) + ']' + str(tvar_20201028154040327310)) time.sleep(0.3) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154124182312,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text=tvar_20201028154040327310) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028173223637496,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='{Tab 4}') #单元格读取 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:202010291422234261086,Title:单元格读取,Note:') time.sleep(0.3) fangshi=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='J'+str(initial),cell_type='string') print('[flow2] [单元格读取] [202010291422234261086] 返回值:[' + str(type(fangshi)) + ']' + str(fangshi)) time.sleep(0.3) # IF分支 self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:202010291423319511100,Title:IF分支,Note:') if fangshi =='电汇': #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:202010291426471281103,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='{Down 8}') elif fangshi =='银行承兑汇票(收)': #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:202010291427017501104,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='{Down 3}') elif fangshi =='转帐': #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:202010291427022791107,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='{Down 17}') else: pass #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154301537329,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='{Enter}') #单元格读取 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154445770331,Title:单元格读取,Note:') time.sleep(0.3) tvar_20201028154445771332=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='K'+str(initial),cell_type='string') print('[flow2] [单元格读取] [20201028154445770331] 返回值:[' + str(type(tvar_20201028154445771332)) + ']' + str(tvar_20201028154445771332)) time.sleep(0.3) #replace self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028165150667415,Title:replace,Note:') tvar_20201028165150667416=rpa_str.replace(string=tvar_20201028154445771332,old='#',new='{#}') print('[flow2] [replace] [20201028165150667415] 返回值:[' + str(type(tvar_20201028165150667416)) + ']' + str(tvar_20201028165150667416)) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028165226010429,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text=tvar_20201028165150667416) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154630210337,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='{Tab}') #单元格读取 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154707544339,Title:单元格读取,Note:') time.sleep(0.3) tvar_20201028154707545340=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='L'+str(initial),cell_type=None) print('[flow2] [单元格读取] [20201028154707544339] 返回值:[' + str(type(tvar_20201028154707545340)) + ']' + str(tvar_20201028154707545340)) time.sleep(0.3) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154718140342,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text=tvar_20201028154707545340) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154748193347,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='{Tab}') #单元格读取 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154805912349,Title:单元格读取,Note:') time.sleep(0.3) tvar_20201028154805912350=iexcel.read_cell(path='C:/Users/Administrator/Desktop/银行日记账20201020112540会计录入收款信息.xlsx',cell='M'+str(initial),cell_type=None) print('[flow2] [单元格读取] [20201028154805912349] 返回值:[' + str(type(tvar_20201028154805912350)) + ']' + str(tvar_20201028154805912350)) time.sleep(0.3) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028154840804352,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text=tvar_20201028154805912350) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201028172525264494,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text='{Tab 4}') #相加 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201029015908212843,Title:相加,Note:') initial=rpa_fun.add(a=initial,b=1) print('[flow2] [相加] [20201029015908212843] 返回值:[' + str(type(initial)) + ']' + str(initial)) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:flow2,StepNodeTag:20201029100341149915,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000) def leixing(self): pass def login(self): #热键输入 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login,StepNodeTag:2020102716440633945,Title:热键输入,Note:') ikeyboard.key_send_cs(waitfor=10.000,text=r'#d') #鼠标双击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login,StepNodeTag:2020102716440633944,Title:鼠标双击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',times=2,image=r'snapshot_20201029103253721.png',image_size=r'38X29',img_res_path = self.path) #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login,StepNodeTag:2020102716440633942,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201027163736752.png',image_size=r'272X15',win_title=r'金蝶EAS系统登录',continue_on_error='break',img_res_path = self.path) #模拟按键 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login,StepNodeTag:2020102716440633941,Title:模拟按键,Note:') ikeyboard.key_send_cs(waitfor=10.000,text="123456") #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:login,StepNodeTag:2020102716440633943,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201027164204785.png',image_size=r'76X18',win_title=r'金蝶EAS系统登录',continue_on_error='break',img_res_path = self.path) def Main(self): #子流程 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102716441979756,Title:子流程,Note:') tvar20201027164419797561=self.login() print('[Main] [子流程] [2020102716441979756] 返回值:[' + str(type(tvar20201027164419797561)) + ']' + str(tvar20201027164419797561)) # Try异常 self.__logger.dlogs(job_no=self.job_no, logmsg='Flow:Main,StepNodeTag:2020102813042663292,Title:Try异常,Note:') try: #图片检测 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102813045662794,Title:图片检测,Note:') tvar_2020102813045662895=iimg.img_exists(waitfor=30.000,win_title=r'账号重复登录',image=r'snapshot_20201028130520424.png',img_res_path = self.path) print('[Main] [图片检测] [2020102813045662794] 返回值:[' + str(type(tvar_2020102813045662895)) + ']' + str(tvar_2020102813045662895)) #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102813052718697,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201028130553617.png',image_size=r'80X21',win_title=r'账号重复登录',continue_on_error='break',img_res_path = self.path) except Exception as e: pass finally: #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102716442586158,Title:鼠标点击,Note:') time.sleep(5) iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201029105623930.png',image_size=r'82X13',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path) #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102716463348960,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201027164652739.png',image_size=r'151X20',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path) #鼠标点击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102716465797562,Title:鼠标点击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',image=r'snapshot_20201027164724771.png',image_size=r'223X28',win_title=r'金蝶EAS-IT_Test',continue_on_error='break',img_res_path = self.path) #鼠标双击 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102716515656866,Title:鼠标双击,Note:') iimg.do_click_pos(waitfor=30.000,button='left',curson='Center',times=2,image=r'snapshot_20201027165408189.png',image_size=r'212X21',win_title=r'金蝶EAS-IT_Test',img_res_path = self.path) #子流程 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:2020102811290944859,Title:子流程,Note:') tvar20201028112909448591=self.flow1() print('[Main] [子流程] [2020102811290944859] 返回值:[' + str(type(tvar20201028112909448591)) + ']' + str(tvar20201028112909448591)) #图片检测 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:20201029092656397894,Title:图片检测,Note:') tvar_20201029092656397895=iimg.img_exists(waitfor=30.000,win_title=r'金蝶EAS-IT_Test',image=r'snapshot_20201029092735462.png',img_res_path = self.path) print('[Main] [图片检测] [20201029092656397894] 返回值:[' + str(type(tvar_20201029092656397895)) + ']' + str(tvar_20201029092656397895)) #子流程 self.__logger.dlogs(job_no=self.job_no,logmsg='Flow:Main,StepNodeTag:20201028173523203502,Title:子流程,Note:') tvar202010281735232035021=self.flow2() print('[Main] [子流程] [20201028173523203502] 返回值:[' + str(type(tvar202010281735232035021)) + ']' + str(tvar202010281735232035021))
class RPA_D3: def __init__(self, **kwargs): self.__logger = ILog(__file__) self.path = set_img_res_path(__file__) self.robot_no = '' self.proc_no = '' self.job_no = '' self.input_arg = '' if ('robot_no' in kwargs.keys()): self.robot_no = kwargs['robot_no'] if ('proc_no' in kwargs.keys()): self.proc_no = kwargs['proc_no'] if ('job_no' in kwargs.keys()): self.job_no = kwargs['job_no'] ILog.JOB_NO, ILog.OLD_STDOUT = self.job_no, sys.stdout sys.stdout = StdOutHook(self.job_no, sys.stdout) ExceptionHandler.JOB_NO, ExceptionHandler.OLD_STDERR = self.job_no, sys.stderr sys.excepthook = ExceptionHandler.handle_exception if ('input_arg' in kwargs.keys()): self.input_arg = kwargs['input_arg'] if (len(self.input_arg) <= 0): self.input_arg = iinput.load_init(__file__) if self.input_arg is None: sys.exit(0) def Dataframe_list(self): value_isearch03 = None #读取Excel self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Dataframe_list,StepNodeTag:2020091715025272589,Title:读取Excel,Note:' ) tvar_2020091715025272690 = pd.read_excel( io='D:/YiSaiQi/RPA_D3/mydata.xls') #表格过滤 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Dataframe_list,StepNodeTag:2020091714592597678,Title:表格过滤,Note:' ) value_isearch03 = tvar_2020091715025272690[( tvar_2020091715025272690['产品代码'].str.startswith('i-Search-03'))] #设置变量 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Dataframe_list,StepNodeTag:20200917150802293115,Title:设置变量,Note:' ) value_isearch03 = value_isearch03.values.tolist() # For循环 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Dataframe_list,StepNodeTag:20200917151128158119,Title:For循环,Note:' ) for tvar_20200917151128161120 in value_isearch03: #输出 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Dataframe_list,StepNodeTag:2020091715004175083,Title:输出,Note:' ) rpa_str.iprints(tvar_20200917151128161120) def Excel(self): sheet2_val = None sheet1_val = None #读取Excel self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Excel,StepNodeTag:20200917160132552143,Title:读取Excel,Note:') sheet1_val = pd.read_excel(io='D:/YiSaiQi/RPA_D3/mydata.xls') #读取Excel self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Excel,StepNodeTag:20200917160727776167,Title:读取Excel,Note:') sheet2_val = pd.read_excel(io='D:/YiSaiQi/RPA_D3/mydata.xls', sheet_name=1) #代码块 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:Excel,StepNodeTag:20200917161108141183,Title:代码块,Note:' ) sheet1_val = sheet1_val.append(sheet2_val) #输出 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:Excel,StepNodeTag:20200917161214523186,Title:输出,Note:' ) rpa_str.iprints(sheet1_val) # Try异常 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Excel,StepNodeTag:20200917162950407191,Title:Try异常,Note:') try: #创建excel self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Excel,StepNodeTag:20200917154223848138,Title:创建excel,Note:' ) iexcel.create_excel(path='D:/YiSaiQi/RPA_D3', file_name='Create_excel.xls') except Exception as e: #导出excel self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Excel,StepNodeTag:20200917163240519199,Title:导出excel,Note:' ) icsv.write_excel(path='D:/YiSaiQi/RPA_D3/Create_excel.xls', df=sheet1_val) finally: #导出excel self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Excel,StepNodeTag:20200917160944573180,Title:导出excel,Note:' ) icsv.write_excel(path='D:/YiSaiQi/RPA_D3/Create_excel.xls', df=sheet1_val) def flow1(self): #单元格读取 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:flow1,StepNodeTag:202009171430210059,Title:单元格读取,Note:' ) tvar_2020091714302100810 = iexcel.read_cell( path='D:/YiSaiQi/RPA_D3/D3_demo.xls', cell_type=None) # Return返回 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:flow1,StepNodeTag:2020091714434624064,Title:Return返回,Note:') return tvar_2020091714302100810 def flow2(self, excel=None): #消息框 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:flow2,StepNodeTag:2020091714340135526,Title:消息框,Note:' ) ibox.msgs_box('成功' + excel, timeout=0) def Main(self): #子流程 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:Main,StepNodeTag:2020091714405559957,Title:子流程,Note:') tvar20200917144055599571 = self.flow1() #子流程 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:Main,StepNodeTag:2020091714441293867,Title:子流程,Note:') tvar20200917144412938671 = self.flow2(excel=tvar20200917144055599571)
class DEMO2: def __init__(self, **kwargs): self.__logger = ILog(__file__) self.path = set_img_res_path(__file__) self.robot_no = '' self.proc_no = '' self.job_no = '' self.input_arg = '' if ('robot_no' in kwargs.keys()): self.robot_no = kwargs['robot_no'] if ('proc_no' in kwargs.keys()): self.proc_no = kwargs['proc_no'] if ('job_no' in kwargs.keys()): self.job_no = kwargs['job_no'] ILog.JOB_NO, ILog.OLD_STDOUT = self.job_no, sys.stdout sys.stdout = StdOutHook(self.job_no, sys.stdout) ExceptionHandler.JOB_NO, ExceptionHandler.OLD_STDERR = self.job_no, sys.stderr sys.excepthook = ExceptionHandler.handle_exception if ('input_arg' in kwargs.keys()): self.input_arg = kwargs['input_arg'] if (len(self.input_arg) <= 0): self.input_arg = iinput.load_init(__file__) if self.input_arg is None: sys.exit(0) def Excel_write(self): value1 = None #获取文本 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Excel_write,StepNodeTag:202009180744505107,Title:获取文本,Note:') value1 = iie.get_text( waitfor=10.000, selector= r'#page > NAV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(3) > UL:nth-of-type(1) > LI:nth-of-type(8) > A:nth-of-type(1)', url=r'https://www.i-search.com.cn/course.html') print('[Excel_write] [获取文本] [202009180744505107] 返回值:[' + str(type(value1)) + ']' + str(value1)) #单元格写入 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:Excel_write,StepNodeTag:2020091807473501913,Title:单元格写入,Note:' ) tvar_2020091807473502914 = iexcel.write_cell( path='D:/YiSaiQi/DEMO2/Day2.xls', text=value1) print('[Excel_write] [单元格写入] [2020091807473501913] 返回值:[' + str(type(tvar_2020091807473502914)) + ']' + str(tvar_2020091807473502914)) def OCR(self): YZM = None #截图 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:OCR,StepNodeTag:20200918084212118111,Title:截图,Note:') tvar_20200918084212118112 = iimg.capture_image( waitfor=30.000, win_title=r'中国工商银行企业网上银行 - Internet Explorer', left_indent=935, top_indent=458, width=90, height=34) print('[OCR] [截图] [20200918084212118111] 返回值:[' + str(type(tvar_20200918084212118112)) + ']' + str(tvar_20200918084212118112)) #获取OCR文本 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:OCR,StepNodeTag:2020091808312854183,Title:获取OCR文本,Note:') YZM = iocr.general_recognize( image_path=tvar_20200918084212118112, apiKey='c578a472e212448fb9f78b17a79fffc9', secretKey='5588921ccc2047fd87a2e54fabee90ed') print('[OCR] [获取OCR文本] [2020091808312854183] 返回值:[' + str(type(YZM)) + ']' + str(YZM)) #replace self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:OCR,StepNodeTag:2020091808351721592,Title:replace,Note:') tvar_2020091808351722593 = rpa_str.replace(string=YZM, old=' ', new='') print('[OCR] [replace] [2020091808351721592] 返回值:[' + str(type(tvar_2020091808351722593)) + ']' + str(tvar_2020091808351722593)) #输出 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:OCR,StepNodeTag:20200918083727282102,Title:输出,Note:') rpa_str.iprints(tvar_2020091808351722593) def for_demo(self): # For循环 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:for_demo,StepNodeTag:2020091808042353439,Title:For循环,Note:') for i in [1, 2, 3, 4, 5]: #输出 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:for_demo,StepNodeTag:2020091808050105143,Title:输出,Note:') rpa_str.iprints(i) def pic_JC(self): #元素截图 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:pic_JC,StepNodeTag:2020091808241867472,Title:元素截图,Note:') tvar_2020091808243847274 = iie.capture_element_img( waitfor=10.000, win_title=r'金融RPA_银行RPA机器人_RPA金融银行解决方案_艺赛旗 - Internet Explorer', selector= r'#fh5co-header > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(1) > DIV:nth-of-type(2) > IMG:nth-of-type(1)', in_img_path=r'C:/Users/帅气可爱的小飞/Desktop/图片素材', url=r'https://www.i-search.com.cn/finance.html') print('[pic_JC] [元素截图] [2020091808241867472] 返回值:[' + str(type(tvar_2020091808243847274)) + ']' + str(tvar_2020091808243847274)) #输出 self.__logger.dlogs( job_no=self.job_no, logmsg='Flow:pic_JC,StepNodeTag:2020091808252203975,Title:输出,Note:' ) rpa_str.iprints(tvar_2020091808243847274) def while_dmeo(self): carr = 0 # While循环 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:while_dmeo,StepNodeTag:2020091807503206120,Title:While循环,Note:' ) while carr <= 100: #相加 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:while_dmeo,StepNodeTag:2020091807551612223,Title:相加,Note:' ) carr = rpa_fun.add(a=carr, b=1) print('[while_dmeo] [相加] [2020091807551612223] 返回值:[' + str(type(carr)) + ']' + str(carr)) # IF分支 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:while_dmeo,StepNodeTag:2020091807565996529,Title:IF分支,Note:' ) if carr % 2 == 0: #输出 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:while_dmeo,StepNodeTag:2020091807574119732,Title:输出,Note:' ) rpa_str.iprints(carr) else: # Continue继续 self.__logger.dlogs( job_no=self.job_no, logmsg= 'Flow:while_dmeo,StepNodeTag:2020091807582317635,Title:Continue继续,Note:' ) continue def Main(self): pass