Created
October 24, 2025 17:23
-
-
Save fellypsantos/d826c96fc39fd3458214a54a93ba0efc to your computer and use it in GitHub Desktop.
BPA Consolidado - Automação
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### SCRIPT PARA AUTOMATIZAR DIGITAÇÃO DE PROCEDIMENTOS | |
| ### EM QUE APENAS IDADE E QUANTIDADE SÃO ALTERADOS | |
| ### CONTÉM VALIDAÇÃO DO TOTAL ESPERADO NA SOMA FINAL | |
| import pyautogui as bot | |
| import time | |
| procedure = '0301010048' | |
| cbo = '223505' | |
| age_start = 1 | |
| age_end = 20 | |
| quantity_list = [90, 96, 89, 88, 95, 94, 93, 91, 99, 86, 87, 99, 98, 99, 86, 96, 97, 88, 87, 89] | |
| quantity_total = sum(quantity_list) | |
| should_continue = input('Total será: {}\nContinuar (S/N)? :: '.format(quantity_total)) | |
| if len(quantity_list) < (age_end - age_start) + 1: | |
| print('\n\nA quantidade de idades informadas é menor que a necessária\n') | |
| exit() | |
| if (should_continue.upper() != 'S'): | |
| print('\n\n..:: PROCESSAMENTO CANCELADO ::..') | |
| exit() | |
| age_list = range(age_start, age_end + 1) | |
| typing_delay = 0.0002 | |
| def type_age(age): | |
| bot.write(str(age), interval=typing_delay) | |
| bot.press('tab') | |
| def type_quantity(quantity): | |
| bot.write(str(quantity), interval=typing_delay) | |
| bot.press('tab') | |
| print('Iniciando em 3 segundos...') | |
| time.sleep(3) | |
| for index, age in enumerate( age_list ): | |
| print('Digitando Idade: {} | Quantidade: {}'.format(age, quantity_list[index])) | |
| if (index == 0): | |
| # type in first line | |
| bot.write(procedure, interval=typing_delay) | |
| bot.write(cbo, interval=typing_delay) | |
| type_age(age) | |
| type_quantity(quantity_list[index]) | |
| else: | |
| # repeat in next lines | |
| bot.press('f8') | |
| type_age(age) | |
| type_quantity(quantity_list[index]) | |
| bot.press('enter') | |
| bot.press('enter') | |
| print('Total: {}'.format(sum(quantity_list))) | |
| time.sleep(1) | |
| bot.press('enter') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment