automatiza-mg / automatizacoes

Repositório dedicado a página do Automatiza.MG.
https://www.planejamento.mg.gov.br/automatizamg
9 stars 0 forks source link

Incluir robô SEE no portfólio de robôs #29

Open gabrielbdornas opened 1 year ago

gabrielbdornas commented 1 year ago

Em e-mail enviado por Lucas Fainblat dia 24/10/2023:

Pessoal, beleza?

Encaminho script de robozinho da SEE. Parece que é um bem completo. Acho > que esse robô já foi inscrito no nosso "formulário de novos robôs", então já dá > pra fazer a página de github dele. Não fiz a checagem prévia porque estou em > vias de pegar o ônibus aqui em Caratinga, mas esta semana a gente confirma > isso!

Acho legal utilizarmos este como piloto pra lidarmos com uma unidade > externa. Desde o ajuste do script até o termo de anuência para a publicação.

Robô Descentralização Financeira

Subfluxos:
Main: Principal
Inicializadores: Inicialização do processo e atribuição de variáveis
StatusProcesso: Qualquer questão de impeça a execução inicial já manda email avisando
Registro: Fluxo completo, com confirmação do registro 
Exceção: Qualquer erro que impeça o registro
GMIPF: Descentralização por GMIFP
Fonte: Descentralização por fonte de recurso.

O processo é contruído para não parar de forma alguma, sempre registrando o log caso 
ocorra erro, apontanto o tipo de erro e onde o erro foi encontrado.

Além disso criei um único fluxo de validação SIAFI, qte de enters, etc. Sempre chamo esse
fluxo no inicializadores.

Segue o txt.

Main:
SET Usuario TO $'''xxxxxxx'''
SET Senha TO $'''xxxxxx'''
SET AuxLogErro TO 1
LABEL Inicio
CALL Sf_Inicializadores
LOOP FOREACH CurrentItem IN DadosExcel
    IF IsEmpty(CurrentItem['Log']) THEN
        SET Fonte TO CurrentItem['Fonte']
        IF (Fonte = 21 OR Fonte = 23 OR Fonte = 36) = True THEN
            CALL Sf_Fonte21_23_36
        ELSE
            CALL Sf_GMIFP
        END
        Variables.IncreaseVariable Value: LoopIndex IncrementValue: 1
    END
    IF ResetSIAFI >= 50 THEN
        Excel.CloseExcel.CloseAndSave Instance: ExcelInstance
        System.TerminateProcess.TerminateProcessByName ProcessName: $'''pw3270'''
        GOTO Inicio
    END
END
Excel.CloseExcel.CloseAndSave Instance: ExcelInstance
System.TerminateProcess.TerminateProcessByName ProcessName: $'''pw3270'''
SET ProcessoConcluido TO True
CALL Sf_StatusProcesso
Display.ShowMessageDialog.ShowMessage Title: $'''Aviso!''' Message: $'''Processo de descentralização concluído!
%LogErro%''' Icon: Display.Icon.Warning Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True
LABEL Fim

Sf_Inicializadores:
DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateOnly CurrentDateTime=> Data
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: Data CustomFormat: $'''dd-MM-yyyy''' Result=> Data
BLOCK ErroIniciarExcel
ON BLOCK ERROR
    SET LogErro TO $'''Erro ao iniciar o Excel...'''
    CALL Sf_StatusProcesso
    THROW ERROR
END
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''G:\\Meu Drive\\RPA_descentralizacao\\Descentralizados\\descentralizado_%Data%.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
END
Excel.GetFirstFreeRowOnColumn Instance: ExcelInstance Column: $'''L''' FirstFreeRowOnColumn=> LoopIndex
Excel.ReadFromExcel.ReadAllCells Instance: ExcelInstance ReadAsText: False FirstLineIsHeader: True RangeValue=> DadosExcel
SET TelaSIAFI TO $'''pw3270:A - Bhmvsb.prodemge.gov.br'''
SET Aguardar TO 1
SET ResetSIAFI TO 1
SET ProcessoConcluido TO False
SET BancoAgenciaConta13 TO 9010999960000002004630
SET BancoAgenciaConta21 TO $'''0010161520000000059420'''
SET BancoAgenciaConta23 TO $'''0010161520000000071129'''
SET AuxReinicializar TO 0
SET MsgExcecao TO $'''%''%'''
SET AuxExcecao TO $'''null'''
SET MaspRT TO $'''m752780'''
SET Var_un_exec TO 1260160
SET Var_aplic_user TO $'''simg    m1147833'''
@@flowname: 'Validacao_App_SIAFI'
External.RunFlow FlowId: '6512fca6-3d42-40d7-b346-a2939e9dc685' @Usuario: Usuario @Senha: Senha
MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: $'''pw3270:A - Bhmvsb.prodemge.gov.br''' Class: $'''''' TextToSend: $'''SIMG{Return}{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
WAIT Aguardar
MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: $'''pw3270:A - Bhmvsb.prodemge.gov.br''' Class: $'''''' TextToSend: $'''1260160{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
WAIT 10
MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''6{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
WAIT Aguardar
MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''2{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
WAIT Aguardar

Sf_StatusProcesso:
Outlook.Launch Instance=> Email
IF (ProcessoConcluido AND LogErro.IsEmpty) = True THEN
    SET AssuntoEmail TO $'''Processo de Descentralização \"CONCLUIDO SEM FALHAS\"'''
    SET CorpoEmail TO $'''Processo Concluído Sem Falhas!'''
ELSE IF (ProcessoConcluido AND LogErro <> '') = True THEN
    SET AssuntoEmail TO $'''Processo de Descentralização Concluído \"COM FALHAS\"'''
    SET CorpoEmail TO $'''Processo Concluído Com Falhas!
Log de erro:
%LogErro%'''
ELSE
    SET AssuntoEmail TO $'''Processo de Descentralização \"INTERROMPIDO\"
'''
    SET CorpoEmail TO $'''Processo de Descentralização INTERROMPIDO!
Log de erro: 
%LogErro%'''
END
Outlook.SendEmailThroughOutlook.SendEmail Instance: Email Account: $'''robo_financeiro@outlook.com''' SendTo: $'''adilson.silva@educacao.mg.gov.br; antonio.domingues@educacao.mg.gov.br''' Subject: AssuntoEmail Body: CorpoEmail IsBodyHtml: False Attachments: $'''G:\\Meu Drive\\RPA_descentralizacao\\Descentralizados\\descentralizado_%Data%.xlsx'''
WAIT 10
Outlook.Close Instance: Email

Sf_Registro:
BLOCK 'Erro Registro'
ON BLOCK ERROR
    SET LogErro TO LogErro
    SET MsgExcecao TO $'''Registro não foi efetuado!'''
    SET AuxReinicializar TO AuxReinicializar + 1
    CALL Sf_Excecao
END
    WAIT (OCR.WaitForTextOnScreen.TextOnScreenToAppearWithWindowsOcr TextToFind: $'''EFETUADO''' IsRegex: False WindowsOcrLanguage: OCR.WindowsOcrLanguage.Portuguese SearchForTextOn: OCR.SearchTarget.ForegroundWindow ImageWidthMultiplier: 1 ImageHeightMultiplier: 1) FOR 10
    **REGION Recuperar número da descentralização
    DISABLE MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''{Down}{Down}{Down}{Down}{Down}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Shift}({Right}{Right}{Right}{Right}{Right}{Right})''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    DISABLE WAIT 1
    DISABLE MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''{Control}(c)''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    DISABLE WAIT 1
    DISABLE Clipboard.GetText Text=> NumRegistro
    **ENDREGION
    SET AuxReinicializar TO 0
    Excel.WriteToExcel.WriteCell Instance: ExcelInstance Value: $'''Sucesso''' Column: $'''L''' Row: LoopIndex
    WAIT Aguardar
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''{F3}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    WAIT Aguardar
    Variables.IncreaseVariable Value: ResetSIAFI IncrementValue: 1
END

Sf_Excecao:
Excel.WriteToExcel.WriteCell Instance: ExcelInstance Value: $'''ERRO - %MsgExcecao%''' Column: $'''L''' Row: LoopIndex
IF IsEmpty(LogErro) THEN
    SET LogErro TO $'''Erro %AuxLogErro%: %MsgExcecao% - Linha: %LoopIndex% da planilha do Excel.'''
ELSE
    SET LogErro TO $'''%LogErro% Erro %AuxLogErro%: %MsgExcecao% - Linha: %LoopIndex% da planilha do Excel.'''
END
Variables.IncreaseVariable Value: AuxLogErro IncrementValue: 1
MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''{F3}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
IF AuxReinicializar = 3 THEN
    SET ResetSIAFI TO 50
END

Sf_GMIFP:
SET UE TO CurrentItem['UE']
SET Ano TO CurrentItem['Ano Empenho']
SET GMIFP TO CurrentItem['Categoria']
SET Valor TO CurrentItem['Valor Formatado']
SET ElementoItem TO CurrentItem['Elemento Item']
IF Fonte <> 13 THEN
    **REGION Execução Fonte 10, 71 e 95
    IF CurrentItem['Lib-Recolhimento'] = $'''RECOLHIMENTO''' THEN
        SET AuxExcecao TO $'''ANULAR'''
        MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''021{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    ELSE
        SET AuxExcecao TO $'''LIBERADA'''
        MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''011{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    END
    WAIT Aguardar
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''x{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    WAIT Aguardar
    IF (ElementoItem = 9401 OR ElementoItem = 9202) = True THEN
        **REGION Execução Item Preso
        MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''%Ano%%MaspRT%{Tab}{Tab}x%GMIFP%%ElementoItem%%UE%{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
        **ENDREGION
    ELSE
        MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''%Ano%%MaspRT%{Tab}x{Tab}%GMIFP%{Down}%UE%{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    END
    WAIT Aguardar
    IF (OCR.IfTextOnScreen.TextOnScreenExistsWithWindowsOcr TextToFind: $'''INEXISTENTE''' IsRegex: False WindowsOcrLanguage: OCR.WindowsOcrLanguage.Portuguese SearchForTextOn: OCR.SearchTarget.ForegroundWindow ImageWidthMultiplier: 1 ImageHeightMultiplier: 1) THEN
        SET MsgExcecao TO $'''Saldo Cota Inexistente!'''
        CALL Sf_Excecao
        EXIT FUNCTION
    END
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''%Valor%{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    WAIT Aguardar
    IF (OCR.IfTextOnScreen.TextOnScreenExistsWithWindowsOcr TextToFind: AuxExcecao IsRegex: False WindowsOcrLanguage: OCR.WindowsOcrLanguage.Portuguese SearchForTextOn: OCR.SearchTarget.ForegroundWindow ImageWidthMultiplier: 1 ImageHeightMultiplier: 1) THEN
        SET MsgExcecao TO $'''Valor maior que saldo a Descentralizar/Recolher!'''
        CALL Sf_Excecao
        EXIT FUNCTION
    END
    IF (ElementoItem = 9401 OR ElementoItem = 9202) = True THEN
        **REGION Execução Item Preso
        MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''{Down}x{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
        **ENDREGION
    ELSE
        MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''x{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    END
    WAIT Aguardar
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''{F5}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    WAIT Aguardar
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''{F5}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    CALL Sf_Registro
    **ENDREGION
ELSE
    **REGION Execução Fonte 13
    IF CurrentItem['Lib-Recolhimento'] = $'''RECOLHIMENTO''' THEN
        SET AuxExcecao TO $'''ANULAR'''
        MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''041{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    ELSE
        SET AuxExcecao TO $'''LIBERADA'''
        MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''031{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    END
    WAIT Aguardar
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}x{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    WAIT Aguardar
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''%MaspRT%{Tab}%BancoAgenciaConta13%x%Ano%%GMIFP%{Tab}%UE%{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    WAIT Aguardar
    IF (OCR.IfTextOnScreen.TextOnScreenExistsWithWindowsOcr TextToFind: $'''INEXISTENTE''' IsRegex: False WindowsOcrLanguage: OCR.WindowsOcrLanguage.Portuguese SearchForTextOn: OCR.SearchTarget.ForegroundWindow ImageWidthMultiplier: 1 ImageHeightMultiplier: 1) THEN
        SET MsgExcecao TO $'''Saldo Cota Inexistente!'''
        CALL Sf_Excecao
        EXIT FUNCTION
    END
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''%Valor%{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    IF (OCR.IfTextOnScreen.TextOnScreenExistsWithWindowsOcr TextToFind: AuxExcecao IsRegex: False WindowsOcrLanguage: OCR.WindowsOcrLanguage.Portuguese SearchForTextOn: OCR.SearchTarget.ForegroundWindow ImageWidthMultiplier: 1 ImageHeightMultiplier: 1) THEN
        SET MsgExcecao TO $'''Valor maior que saldo a Descentralizar/Recolher!'''
        CALL Sf_Excecao
        EXIT FUNCTION
    END
    WAIT Aguardar
    IF CurrentItem['Lib-Recolhimento'] <> $'''RECOLHIMENTO''' THEN
        MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''x{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
        MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''{F5}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
        WAIT Aguardar
    END
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''.{F5}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    WAIT Aguardar
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''{F5}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    CALL Sf_Registro
    **ENDREGION
END

Sf_Fonte21_23_36:
SET UE TO CurrentItem['UE']
SET Ano TO CurrentItem['Ano Empenho']
SET Valor TO CurrentItem['Valor Formatado']
SET BancoAgenciaConta36 TO $'''001016152%CurrentItem['Categoria']%'''
SET ValidacaoAno36 TO CurrentItem['Validacao Ano F36']
**REGION Regiao de Retorno F21, 23, 36
IF CurrentItem['Lib-Recolhimento'] = $'''RECOLHIMENTO''' THEN
    SET AuxExcecao TO $'''ANULAR'''
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''041{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
ELSE
    SET AuxExcecao TO $'''LIBERADA'''
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''031{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
END
WAIT Aguardar
MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''{F8}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
WAIT Aguardar
MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''x{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
WAIT Aguardar
IF Fonte = 21 THEN
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''%MaspRT%{Tab}%BancoAgenciaConta21%%UE%{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
ELSE IF Fonte = 23 THEN
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''%MaspRT%{Tab}%BancoAgenciaConta23%%UE%{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
ELSE
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''%MaspRT%{Tab}%BancoAgenciaConta36%%UE%{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    IF ValidacaoAno36 = 1 THEN
        IF CurrentItem['Categoria'] = $'''0000000105910''' THEN
            IF Ano = 2023 THEN
                MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''{Down}x{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
            ELSE
                MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''x{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
            END
        ELSE
            SET MsgExcecao TO $'''Verificar Nivel Auxiliar - Descentralizacao Manual'''
            CALL Sf_Excecao
            EXIT FUNCTION
        END
    END
END
WAIT Aguardar
MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''%Valor%{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
WAIT Aguardar
IF (OCR.IfTextOnScreen.TextOnScreenExistsWithWindowsOcr TextToFind: AuxExcecao IsRegex: False WindowsOcrLanguage: OCR.WindowsOcrLanguage.Portuguese SearchForTextOn: OCR.SearchTarget.ForegroundWindow ImageWidthMultiplier: 1 ImageHeightMultiplier: 1) THEN
    SET MsgExcecao TO $'''Valor maior que saldo a Descentralizar/Recolher!'''
    CALL Sf_Excecao
    EXIT FUNCTION
END
IF CurrentItem['Lib-Recolhimento'] <> $'''RECOLHIMENTO''' THEN
    IF Fonte = 36 THEN
        MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''{Down}x{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    ELSE
        MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''x{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    END
    WAIT Aguardar
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''{F5}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    WAIT Aguardar
END
MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''.{F5}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
WAIT Aguardar
MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: TelaSIAFI Class: $'''''' TextToSend: $'''{F5}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
CALL Sf_Registro
**ENDREGION

Validacao_App_SIAFI (Fluxo):
Display.ShowMessageDialog.ShowMessageWithTimeout Title: $'''Alerta!''' Message: $'''Validação SIAFI, Aguarde...''' Icon: Display.Icon.Warning Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True Timeout: 3 ButtonPressed=> ButtonPressed
LABEL Inicio
SET Var_App TO 0
SET LoopIndex TO 0
**REGION Validação tela inicial
LOOP WHILE (Var_App) <> (1)
    IF (System.IfProcess.ProcessIsRunning ProcessName: $'''pw3270''') THEN
        System.TerminateProcess.TerminateProcessByName ProcessName: $'''pw3270'''
        WAIT 5
    END
    System.RunApplication.RunApplication ApplicationPath: $'''C:\\Program Files\\pw3270\\pw3270.exe''' WindowStyle: System.ProcessWindowStyle.Normal ProcessId=> Var_SIAFI
    WAIT 2
    IF (OCR.IfTextOnScreen.TextOnScreenExistsWithWindowsOcr TextToFind: $'''APLICACAO''' IsRegex: False WindowsOcrLanguage: OCR.WindowsOcrLanguage.Portuguese SearchForTextOn: OCR.SearchTarget.ForegroundWindow ImageWidthMultiplier: 1 ImageHeightMultiplier: 1) THEN
        SET Var_App TO 1
    END
END
**ENDREGION
MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: $'''pw3270:A - bhmvsb.prodemge.gov.br''' Class: $'''''' TextToSend: $'''simg{Tab}%Usuario%%Senha%''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
SET Var_App TO 0
**REGION Validação quantidade ENTER
LOOP WHILE (Var_App) <> (1)
    Variables.IncreaseVariable Value: LoopIndex IncrementValue: 1
    IF LoopIndex = 10 THEN
        GOTO Inicio
    END
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByTitleClass Title: $'''pw3270:A - *''' Class: $'''''' TextToSend: $'''{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: True
    WAIT 0.5
    IF (OCR.IfTextOnScreen.TextOnScreenExistsWithWindowsOcr TextToFind: $'''SUCESSO''' IsRegex: False WindowsOcrLanguage: OCR.WindowsOcrLanguage.Portuguese SearchForTextOn: OCR.SearchTarget.ForegroundWindow ImageWidthMultiplier: 2 ImageHeightMultiplier: 2) THEN
        SET Var_App TO 1
    END
END
**ENDREGION
LABEL Fim
gabrielbdornas commented 1 year ago

descentralização_financeira e validacao_SIAFI.txt

Andrelamor commented 1 year ago

quando recebemos um código de um robô completo (sofisticado) como este, fica mais evidente a necessidade de descrição sucinta do fluxo dele em caixinhas, como @gabrielbdornas relatou aqui