def Encerrar(qtde, flag): for i in range(qtde): ClickOn("./AutoCTE/Buttons/OK2.bmp") ClickOn("./AutoCTE/Buttons/SIM.bmp") ClickOn("./AutoCTE/Buttons/SALVAR.bmp") ClickOn("./AutoCTE/Buttons/OK2.bmp")
def Alterar(qtde, flag): for i in range(qtde): CheckFor('./AutoCTE/Buttons/X.bmp') Sleep(1) pyautogui.keyDown('altleft') WriteOn('a') pyautogui.keyUp('altleft') ClickOn("./AutoCTE/Buttons/SIM.bmp", 80, 0.8) ClickOn("./AutoCTE/Buttons/OK.bmp") CheckFor("./AutoCTE/Buttons/CHECKLupa.bmp") ClickOn("./AutoCTE/Buttons/OutrasAcoes.bmp", precision=0.98) ClickOn("./AutoCTE/Buttons/CompVia.bmp") ClickOn("./AutoCTE/Buttons/OperFrotas.bmp") WriteOn('01') ClickOn("./AutoCTE/Buttons/CodVeiculo.bmp") PressKey('enter') Sleep(1) PressKey('enter') ClickOn("./AutoCTE/Buttons/SIM.bmp", 80, 0.8) Sleep(1) while CheckFor('./AutoCTE/Buttons/CHECKValidando.bmp', 1, 0.95): Sleep() ClickOn("./AutoCTE/Buttons/SALVAR.bmp") CheckFor("./AutoCTE/Buttons/CHECKLupa.bmp") ClickOn("./AutoCTE/Buttons/SALVAR.bmp") Sleep(4) PressKey('down')
def Calcular(viag, flag): for i in range(viag): ClickOn("./AutoCTE/Buttons/CALCULAR.bmp") ClickOn("./AutoCTE/Buttons/CALCULAR.bmp") ClickOn("./AutoCTE/Buttons/OK2.bmp") if CheckFor("./AutoCTE/Buttons/CONFIRMAR3.bmp"): Sleep(2) ClickOn("./AutoCTE/Buttons/CONFIRMAR3.bmp") if CheckFor("./AutoCTE/Buttons/CHECKManifesto.bmp"): Sleep(1) ClickOn('./AutoCTE/Buttons/CHECKDigitado.bmp') PressKey('down')
def Confirmar (qtde, cod, flag): ClickOn("./AutoCTE/Buttons/CHECKAgendamento.bmp") PressKey("2") ClickOn("./AutoCTE/Buttons/CONFIRMAR5.bmp") for i in range(int(qtde)): #ClickOn("./AutoCTE/Buttons/SALVAR2.bmp") ClickOn("./AutoCTE/Buttons/FECHAR2.bmp") ClickOn("./AutoCTE/Buttons/FILTRAR.bmp") ClickOn() CheckFor("./AutoCTE/Buttons/OK3.bmp") PressKey("tab") WriteOn(str(cod)) ClickOn("./AutoCTE/Buttons/OK3.bmp") ClickOn() Sleep() ClickOn("./AutoCTE/Buttons/OK4.bmp") ClickOn()
def AutoAgendamento(flag): workbook = xw.Book('./AutoCTE/MODELO.xlsm') sheet = workbook.sheets['Agendamento'] total = sheet.range('A1').current_region.last_cell.row isFirstLine = True for i in range(total): if sheet.range('A' + str(2 + i)).value != 'ABERTO': continue solicitante = str(sheet.range('B' + str(2 + i)).value) remetente = str(sheet.range('D' + str(2 + i)).value) seqEnd = str(sheet.range('F' + str(2 + i)).value) destinatario = str(sheet.range('G' + str(2 + i)).value) consignatario = str(sheet.range('I' + str(2 + i)).value) codConj = str(sheet.range('K' + str(2 + i)).value) cntr = str(sheet.range('M' + str(2 + i)).value) peso = str(sheet.range('N' + str(2 + i)).value) valor = str(sheet.range('O' + str(2 + i)).value) codMot = None codCav = None codCar = None sheetAux = workbook.sheets['BancoConjunto'] totalAux = sheetAux.range('A1').current_region.last_cell.row for j in range(totalAux): if codConj == sheetAux.range('F' + str(2 + j)).value: print( str(j) + ' = ' + codConj + ' - ' + sheetAux.range('F' + str(2 + j)).value) codMot = str(sheetAux.range('C' + str(2 + j)).value) codCav = str(sheetAux.range('D' + str(2 + j)).value) codCar = str(sheetAux.range('E' + str(2 + j)).value) if isFirstLine: CheckFor('./AutoCTE/Buttons/CHECKCodSolicitante.bmp', 1000) WriteOn(solicitante) if seqEnd == 'X': PressKey('f3') ClickOn('./AutoCTE/Buttons/CONFIRMAR4.bmp') PressKey('enter') ClickOn('./AutoCTE/Buttons/REPETIR.bmp') ClickOn('./AutoCTE/Buttons/ITEM1.bmp') PressKey('right', 5) WriteOn(remetente) Sleep(0.3) PressKey('right', 2) if seqEnd == 'X': PressKey('f3') ClickOn('./AutoCTE/Buttons/CONFIRMAR4.bmp') PressKey('enter') else: PressKey('right') PressKey('right', 5) PressKey('1') PressKey('right', 9) WriteOn(destinatario) PressKey('right', 11) PressKey('2') WriteOn(consignatario) PressKey('right', 35) else: PressKey('right', 73) WriteOn(codCav) PressKey('enter') ClickOn('./AutoCTE/Buttons/SIM.bmp', 80, 0.8) PressKey('right') WriteOn(codCar) PressKey('enter') ClickOn('./AutoCTE/Buttons/SIM.bmp', 80, 0.8) PressKey('right', 3) WriteOn(codMot) if len(codMot) != 6: PressKey('enter') ClickOn('./AutoCTE/Buttons/SIM.bmp', 80, 0.8) PressKey('right') WriteOn(cntr) PressKey('enter') PressKey('f4') looking = True while looking: if ((CheckFor('./AutoCTE/Buttons/CHECKTerceiros.bmp', 10, 0.9)) or (CheckFor('./AutoCTE/Buttons/CHECKTerceirosCinza.bmp', 10, 0.9))): looking = False PressKey('right', 4) PressKey('1') PressKey('enter') PressKey('right') WriteOn(peso) PressKey('enter') PressKey('right') WriteOn(valor) PressKey('right', 6) WriteOn(cntr) Sleep(0.5) ClickOn('./AutoCTE/Buttons/SALVAR4.bmp') elif CheckFor('./AutoCTE/Buttons/CHECKBlankProduto.bmp', 10, 0.9): looking = False WriteOn('TERCEIROS0006OF') PressKey('right') WriteOn('h40') PressKey('right') PressKey('1') PressKey('enter') PressKey('right') WriteOn(peso) PressKey('enter') PressKey('right') WriteOn(valor) PressKey('right', 6) WriteOn(cntr) Sleep(0.5) ClickOn('./AutoCTE/Buttons/SALVAR4.bmp') else: PressKey('delete') PressKey('down') print(solicitante + ' - ' + str(sheet.range('B' + str(3 + i)).value)) if solicitante == str(sheet.range('B' + str(3 + i)).value): sheet.range('A' + str(2 + i)).value = 'LANÇADO' PressKey('down') isFirstLine = False else: sheet.range('A' + str(2 + i)).value = 'LANÇADO' #workbook.save("U:/AutoCTE/LISTA.xlsx") ClickOn('./AutoCTE/Buttons/SALVAR.bmp') Sleep(5.0) ClickOn('./AutoCTE/Buttons/INCLUIR2.bmp') isFirstLine = True
def CTEauto(CTEs, tipo, flag): for CTE in CTEs: ClickOn('./AutoCTE/Buttons/LUPA.bmp') ClickOn('./AutoCTE/Buttons/INCLUIR.bmp') WriteOn(str(len(CTE.notas))) PressKey('tab', 3) PressKey('3') ClickOn('./AutoCTE/Buttons/SALVAR.bmp') Sleep(0.3) ClickOn('./AutoCTE/Buttons/OK.bmp') PressKey('tab', 2) WriteOn(CTE.coleta) PressKey('tab') if CheckFor('./AutoCTE/Buttons/CHECKLojaRem.bmp', 20) == False: WarningMSG('Erro loja remetente') WriteOn('01') Sleep(0.3) if tipo != "Global": if CTE.notas[0].cnpj == 'EXTERIOR': WriteOn(str(FindDest(CTE.notas[0].destinatario))) CTE.tipoCTE = str(4) else: WriteOn(str(FindDest(CTE.notas[0].cnpj, ext=False))) CTE.tipoCTE = str(0) else: PressKey('tab') WriteOn('01') Sleep(0.3) PressKey('delete') PressKey('tab') PressKey('delete') PressKey('tab', 3) Sleep(0.5) PressKey('1') ClickOn('./AutoCTE/Buttons/SERV_TRANSP.bmp', precision=0.98) PressKey('3') PressKey('tab') PressKey('1') Sleep(0.5) if CheckFor('./AutoCTE/Buttons/CHECKescSer.bmp', 20): WriteOn(CTE.servico) PressKey('enter', 2) if (tipo == "Global"): PressKey('tab') else: PressKey('2') WriteOn(AutoOBS(CTE)) PressKey('tab', 2) if CTE.seqEnd != None: WriteOn(str(CTE.seqEnd)) if (len(str(CTE.seqEnd)) != 9): PressKey('tab') else: PressKey('tab') if tipo != "Global": WriteOn(str(CTE.tipoCTE)) PressKey('tab', 3) else: WriteOn(str(CTE.tipoCTE)) PressKey('tab', 3) PressKey('n') for i in range(len(CTE.notas)): if i == 0: ClickOn('./AutoCTE/Buttons/DOCTO_ENTRADA.bmp') PressKey('enter') WriteOn(str(CTE.notas[i].numeroNFE)) PressKey('enter') PressKey('1') PressKey('enter') if CheckFor('./AutoCTE/Buttons/ERRO_SerieNFE.bmp', 20): WarningMSG('NFE já cadastrada') PressKey('enter') today = date.today() day = today.strftime("%d%m%y") WriteOn(str(day)) PressKey('enter') if tipo == "Global": WriteOn('TERCEIROS0006OF') else: WriteOn('8000002000008') PressKey('enter') Sleep(0.3) PressKey('right') PressKey('enter') WriteOn(CTE.cntr) PressKey('right', 3) PressKey('enter') WriteOn(str(CTE.notas[i].pesoBruto)) PressKey('enter') Sleep(0.3) PressKey('right') PressKey('enter') WriteOn(str(CTE.notas[i].valor)) Sleep(0.3) if i == 0: PressKey('right', 5) else: PressKey('right') PressKey('0') PressKey('enter') PressKey('right', 3) PressKey('enter') if tipo == "Global": WriteOn('EXPO') else: WriteOn('CONHECIMENTO 000' + str(CTE.espelho)) PressKey('enter') PressKey('enter') WriteOn(str(CTE.notas[i].qtde)) PressKey('enter') PressKey('right', 23) PressKey('enter') WriteOn(str(CTE.notas[i].codigoXML)) if i != len(CTE.notas) - 1: PressKey('down') if tipo == "Global": ClickOn('./AutoCTE/Buttons/SALVAR.bmp') ClickOn('./AutoCTE/Buttons/SALVAR3.bmp') else: ClickOn('./AutoCTE/Buttons/SALVAR.bmp') ClickOn('./AutoCTE/Buttons/Cancelar3.bmp')
def EncerrarKlabin(qtde, flag): for i in range(qtde): ClickOn("./AutoCTE/Buttons/CHECKEncViag.bmp") Sleep(1) pyautogui.keyDown('altleft') WriteOn('on') pyautogui.keyUp('altleft') PressKey('down', 5) PressKey('right') PressKey('enter') ClickOn("./AutoCTE/Buttons/OK2.bmp") CheckFor('./AutoCTE/Buttons/CHECKFechada.bmp', precision=0.95) pyautogui.keyDown('altleft') WriteOn('on') pyautogui.keyUp('altleft') PressKey('down', 4) PressKey('enter') Sleep(1) WriteOn('a') Sleep(1) today = date.today() now = datetime.now() day = today.strftime("%d%m%y") WriteOn(str(day)) WriteOn(now.strftime("%H%M")) WriteOn(str(day)) WriteOn(now.strftime("%H%M")) ClickOn("./AutoCTE/Buttons/CONFIRMAR5.bmp") PressKey('down') WriteOn('a') WriteOn(str(day)) WriteOn(now.strftime("%H%M")) WriteOn(str(day)) WriteOn(now.strftime("%H%M")) ClickOn("./AutoCTE/Buttons/CONFIRMAR5.bmp") WriteOn('s') Sleep(3) pyautogui.keyDown('altleft') WriteOn('on') pyautogui.keyUp('altleft') PressKey('down', 6) PressKey('enter') WriteOn('a') CheckFor('./AutoCTE/Buttons/CHECKRegOcorr.bmp', precision=0.95) PressKey('right') PressKey('enter') WriteOn(str(day)) PressKey('enter') WriteOn(now.strftime("%H%M")) PressKey('enter') WriteOn('0002') ClickOn("./AutoCTE/Buttons/SALVAR.bmp") Sleep(2) WriteOn('s') Sleep(1) pyautogui.keyDown('altleft') WriteOn('on') pyautogui.keyUp('altleft') PressKey('down', 7) PressKey('right') PressKey('enter') ClickOn("./AutoCTE/Buttons/OK2.bmp") PressKey('down')