Пример #1
0
def start_bpm():
    driver.get(url)

    login_form = pythonRPA.bySelector([{
        "title": "Sign in",
        "class_name": "Chrome_WidgetWin_1",
        "backend": "uia"
    }, {
        "title": "Sign in",
        "control_type": "Custom"
    }])
    login_form.wait_appear(30)
    pythonRPA.keyboard.write(username)

    sleep(1)

    x, y = pyautogui.locateCenterOnScreen(
        r"..\Utils\password_field_title_bpm.png")
    pythonRPA.mouse.click(x + 100, y)
    # password_field_title = pythonRPA.byImage(r"..\Utils\password_field_title_bpm.png")
    # password_field_title.wait_appear(5)
    sleep(1)
    pythonRPA.keyboard.write(password)
    sleep(1)
    pythonRPA.keyboard.press("enter")
    pythonRPA.sleep(3)

    main_window = pythonRPA.bySelector([{
        "title":
        "Система управления кредитными заявками - Отчет - Google Chrome",
        "class_name": "Chrome_WidgetWin_1",
        "backend": "uia"
    }])
    main_window.wait_appear(15)
    main_window.maximize()
Пример #2
0
def ColvirAdmin_block(names, log_table):
    n = 2
    for i in range(n):
        # open ColvirAdmin
        login_cbs_adm = "arnurt"
        password_cbs_adm = "arnur_010203"
        pythonRPA.application("C:\CBS_T_новый\CBSADM.exe").start()

        #Введение данных для входа
        log_in = pythonRPA.bySelector([{
            "title": "Вход в систему",
            "class_name": "TfrmLoginDlg",
            "backend": "uia"
        }])
        log_in.wait_appear(30)
        log_in.click()
        log_in.set_focus()
        pythonRPA.keyboard.write(login_cbs_adm)
        pythonRPA.keyboard.press("Enter")
        pythonRPA.keyboard.write(password_cbs_adm)
        pythonRPA.keyboard.press('Enter')

        cbs_adm_main_window = pythonRPA.bySelector([{
            "class_name": "TfrmCssApplAdm",
            "backend": "uia"
        }])
        cbs_adm_main_window.wait_appear(10)
        cbs_adm_main_window.set_focus()

        #Сохранение селекторов Колвир Админ
        filter = pythonRPA.bySelector([{
            "title": "Фильтр",
            "class_name": "TfrmFilterParams",
            "backend": "uia"
        }])
        filter_name_line = pythonRPA.bySelector([{
            "title": "Фильтр",
            "class_name": "TfrmFilterParams",
            "backend": "uia"
        }, {
            "ctrl_index": 0
        }, {
            "ctrl_index": 0
        }, {
            "ctrl_index": 0
        }])

        filter_cbs_ok = pythonRPA.bySelector([{
            "title": "Фильтр",
            "class_name": "TfrmFilterParams",
            "backend": "uia"
        }, {
            "ctrl_index": 1
        }, {
            "ctrl_index": 0
        }, {
            "ctrl_index": 2
        }])
        for name in names:

            # openning the filter by cliking the Пользователи
            try:
                blocked_codes = []
                unblocked_codes = []
                for iterr in range(50):
                    try:
                        x, y = pyautogui.locateCenterOnScreen(
                            r'.\Utils\users.png')
                        pyautogui.doubleClick(x, y)
                        print('Пользователи pressed')
                        break
                    except Exception as e:
                        print(e)
                        pythonRPA.sleep(1)
                pythonRPA.sleep(2)
                filter.set_focus()

                # Clearing the FILTER
                for iterr in range(50):
                    try:
                        x, y = pyautogui.locateCenterOnScreen(
                            r'.\Utils\clear_filter_button.png')
                        pyautogui.doubleClick(x, y)
                        print('clear_filter_button pressed')
                        break
                    except Exception as e:
                        print(e)
                        pythonRPA.sleep(1)
                filter_name_line.click()
                # fill name_line
                pythonRPA.keyboard.write(name)

                # clicking OK to search
                filter_cbs_ok.click()
                pythonRPA.sleep(3)
                code = "npos"
                #Проверка на результат
                warming = pythonRPA.bySelector([{
                    "title": "Подтверждение",
                    "class_name": "TMessageForm",
                    "backend": "uia"
                }])
                warming.wait_appear(1)
                unfound = warming.is_exists()
                if unfound:
                    if i:
                        for row in log_table:
                            if row[0] == name and row[1] == 'CBSADM':
                                change_row(log_table, row, name, "CBSADM",
                                           "Не заблокирован",
                                           "Сотрудник не найден в системе",
                                           datetime.now().strftime("%H:%M:%S"))
                    else:
                        log_table.append([
                            name, "CBSADM", "Не заблокирован",
                            "Сотрудник не найден в системе",
                            datetime.now().strftime("%H:%M:%S")
                        ])
                    print("Not found in system")
                    pythonRPA.keyboard.press('enter')
                    continue
                else:
                    used = False
                    while 1:
                        # Getting the CODE of the user
                        # i = 1
                        if (used):
                            pythonRPA.keyboard.press('down')
                        pythonRPA.keyboard.press('Enter')
                        used = True
                        user_detail_window = pythonRPA.bySelector([{
                            "class_name":
                            "TfrmAdmUsrDetail",
                            "backend":
                            "uia"
                        }])
                        user_detail_window.wait_appear(2)
                        CODE_line = pythonRPA.bySelector([{
                            "class_name": "TfrmAdmUsrDetail",
                            "backend": "uia"
                        }, {
                            "ctrl_index": 0
                        }, {
                            "ctrl_index": 0
                        }, {
                            "ctrl_index": 0
                        }, {
                            "ctrl_index": 2
                        }, {
                            "ctrl_index": 0
                        }])

                        # check do we blocked this account in past itteration??
                        if (CODE_line.get_value() == code):
                            break

                        code = CODE_line.get_value()
                        # Флаг проеверки должна ли программа нажать кнопку архив, изначально думаем что должна
                        archive_сlick = True

                        # Флаг проеверки должна ли программа нажать кнопку блокировки, изначально думаем что должна
                        block_click = True

                        try:
                            x, y = pyautogui.locateCenterOnScreen(
                                r'.\Utils\archive.png')
                            archive_сlick = False
                            # Флаг проеверки становится ложной если он и так нажат
                        except Exception as e:
                            print(e)
                            n += 1
                            print('archive ', archive_сlick)

                        try:
                            x, y = pyautogui.locateCenterOnScreen(
                                r'.\Utils\blocked.png')
                            block_click = False
                            print('block_click ', block_click)
                            # Флаг проеверки становится ложной если он и так нажат
                        except Exception as e:
                            print(e)
                            print('block_click ', block_click)
                        # Кнопка "Пользователь"
                        user_button = pythonRPA.bySelector([{
                            "class_name": "TfrmAdmUsrDetail",
                            "backend": "uia"
                        }, {
                            "ctrl_index": 4
                        }, {
                            "ctrl_index": 0
                        }])
                        # В сулачае если галочки нету или же кнопка блокировки не нажата мы должны ввести изминения
                        if (archive_сlick):
                            # Нажимаем кнопку корректировки
                            user_button.wait_appear(2)
                            user_button.click()
                            for i in range(3):
                                pythonRPA.keyboard.press('down')
                            pythonRPA.keyboard.press('Enter')

                            # making enable the checkbox of the archive
                            try:
                                x, y = pyautogui.locateCenterOnScreen(
                                    r'.\Utils\arxiv.png')
                                pyautogui.click(x + (x / 2), y)
                                print('Архив нажат')
                            except Exception as e:
                                print(e)
                            # Saving the changes
                            user_button.wait_appear(2)
                            user_button.click()
                            for i in range(2):
                                pythonRPA.keyboard.press('down')
                            pythonRPA.keyboard.press('Enter')
                        # Blocking the user
                        if block_click:
                            user_button.wait_appear(2)
                            user_button.click()
                            for i in range(9):
                                pythonRPA.keyboard.press('down')
                            for i in range(3):
                                pythonRPA.sleep(0.5)
                                pythonRPA.keyboard.press('Enter')
                        user_detail_window.close()
                        print(code, "sucsessfully blocked in CBS/ADM.exe")
                if not i:
                    log_table.append([
                        name, "CBSADM", "Заблокирован", "",
                        datetime.now().strftime("%H:%M:%S")
                    ])
                else:
                    for row in log_table:
                        if row[0] == name and row[1] == 'CBSADM':
                            change_row(log_table, row, name, "CBSADM",
                                       "Заблокирован", "",
                                       datetime.now().strftime("%H:%M:%S"))
            except:
                if i:
                    for row in log_table:
                        if row[0] == name and row[1] == 'CBSADM':
                            change_row(log_table, row, name, "CBSADM",
                                       "Не заблокирован", "Техническая ошибка",
                                       datetime.now().strftime("%H:%M:%S"))
                else:
                    log_table.append([
                        name, "CBSADM", "Не заблокирован",
                        "Техническая ошибка",
                        datetime.now().strftime("%H:%M:%S")
                    ])
Пример #3
0
def Block_in_Colvir(names, nums, log_table):
    error = False
    while (1):
        try:
            # запуск Colvirtest (40TP)
            pythonRPA.application("C:\CBS_T/COLVIR.EXE").start()
            break
        except Exception as e:
            print('COLVIR CAN NOT BE STARTED   ' + e)

    unblocked_names = []
    # Выполнение входа
    log_in = pythonRPA.bySelector([{
        "title": "Вход в систему",
        "class_name": "TfrmLoginDlg",
        "backend": "uia"
    }])
    log_in.wait_appear(30)
    log_in.click()
    log_in.set_focus()
    pythonRPA.keyboard.write("colvir")
    pythonRPA.keyboard.press("Enter")
    pythonRPA.keyboard.write("test_2722")
    pythonRPA.keyboard.press('Enter')
    # ert_1908
    # konakayev_t
    # Перенаправление факуса на выбора режима
    mode_choosing = pythonRPA.bySelector([{
        "title": "Выбор режима",
        "class_name": "TfrmCssMenu",
        "backend": "win32"
    }])
    mode_choosing.wait_appear(20)
    mode_choosing.set_focus()
    mode_s = pythonRPA.bySelector([{
        "title": "Выбор режима",
        "class_name": "TfrmCssMenu",
        "backend": "win32"
    }, {
        "ctrl_index": 3
    }, {
        "ctrl_index": 0
    }, {
        "ctrl_index": 0
    }, {
        "ctrl_index": 0
    }])
    mode_s.wait_appear(5)
    mode_s.click()

    # Очистка фильтра задач
    pythonRPA.keyboard.press('SHIFT+CTRL+A')
    pythonRPA.keyboard.press('Delete')
    pythonRPA.keyboard.write('USRGRANT')
    pythonRPA.keyboard.press('Enter')

    # флаг того что мы должны скипнуть аккаунт и перейти на следющиего пользоватлея, изначально думаем то что этот аккаунт ункальный и проверяем его
    skip = False
    for name in names:
        try:
            if (not skip):
                while name != names[0]:
                    try:
                        x, y = pyautogui.locateCenterOnScreen(
                            r'.\Utils\filter_of_report.png')
                        pyautogui.click(x, y)
                        break
                    except:
                        continue

            # Перенаправление фокус экрана на фильтр
            search_filter = pythonRPA.bySelector([{
                "title": "Фильтр",
                "class_name": "TfrmFilterParams",
                "backend": "uia"
            }])
            search_filter.wait_appear(2)
            search_filter.set_focus()

            # Очистка фильтра поиска
            while 1:
                try:
                    x, y = pyautogui.locateCenterOnScreen(
                        r'.\Utils\clear_filter_button.png')
                    pyautogui.doubleClick(x, y)
                    break
                except Exception as e:
                    print(e)

            # Заполнение наеменования
            name_line = pythonRPA.bySelector([{
                "title": "Фильтр",
                "class_name": "TfrmFilterParams",
                "backend": "uia"
            }, {
                "ctrl_index": 1
            }, {
                "ctrl_index": 0
            }, {
                "ctrl_index": 0
            }])
            name_line.click()
            pythonRPA.keyboard.write(name)
            #Проверка на то что мы должны скипнутть или нет
            if (skip):
                pythonRPA.sleep(2)
            filter_ok = pythonRPA.bySelector([{
                "title": "Фильтр",
                "class_name": "TfrmFilterParams",
                "backend": "uia"
            }, {
                "ctrl_index": 2
            }, {
                "ctrl_index": 0
            }, {
                "ctrl_index": 2
            }])
            if (skip):
                filter_ok.wait_appear(3)
            while 1:
                try:
                    filter_ok.click()
                    break
                except:
                    continue
            try:
                warning = pythonRPA.bySelector([{
                    "title": "Подтверждение",
                    "class_name": "TMessageForm",
                    "backend": "win32"
                }])
                skip = warning.is_exists()
            except Exception as e:
                print(e)
            if (skip):
                pythonRPA.keyboard.press('right')
                pythonRPA.keyboard.press('Enter')
                log_table.append([
                    name, "Colvir", "Не заблокирован",
                    "Сотрудник не найден в системе",
                    datetime.now().strftime("%H:%M:%S")
                ])
                continue

            #Если мы не должны скипать то мы заходим на этот аккаунт и введем изминения
            else:
                # Вход на корректировку
                results_window = pythonRPA.bySelector([{
                    "title": "Назначение профилей и полномочий позиций",
                    "class_name": "TfrmUsrGrantList",
                    "backend": "uia"
                }])
                results_window.wait_appear(3)
                results_window.maximize()
                results_window.set_focus()
                code = "npos"
                while 1:
                    #Проверка на то что мы здесь выпервые или мы тут уже были
                    if (code != "npos"):
                        #Если мы тут впервые то нажимаем down
                        pythonRPA.keyboard.press('down')
                    pythonRPA.keyboard.press('Enter')
                    while 1:
                        try:
                            code_line = pythonRPA.bySelector([{
                                "class_name":
                                "TfrmUsrGrantGrpDetail",
                                "backend":
                                "win32"
                            }, {
                                "ctrl_index": 0
                            }, {
                                "ctrl_index": 0
                            }, {
                                "ctrl_index": 0
                            }, {
                                "ctrl_index": 10
                            }, {
                                "ctrl_index": 0
                            }])
                            code_line.wait_appear(1)
                            break
                        except:
                            continue
                    if (code == code_line.texts()[0]):
                        # Мы заканчиваем эту иттерацию если мы впредыдущей итерации были здесь(Последняя учетная запись)
                        break
                    else:
                        code = code_line.texts()[0]

                    code = code_line.texts()[0]

                    # ФЛАГИ на проверку мы должны нажимать на эти кнопки или нет, изначально думаем что должны
                    archive_click = True
                    zapret_click = True

                    for i in range(2):
                        try:
                            # Здесь проверяем на галочку архива
                            x, y = pyautogui.locateCenterOnScreen(
                                r'.\Utils\archive_true.png')
                            archive_click = False
                            break
                        except Exception as e:
                            print(e)

                    for i in range(2):
                        try:
                            x, y = pyautogui.locateCenterOnScreen(
                                r'.\Utils\zapret_true.png')
                            # Здесь проверяем на галочку архива
                            zapret_click = False
                            break
                        except Exception as e:
                            print(e)
                    # Кнопка Пользователя
                    position = pythonRPA.bySelector([{
                        "class_name": "TfrmUsrGrantGrpDetail",
                        "backend": "uia"
                    }])
                    position1 = pythonRPA.bySelector([{
                        "class_name": "TfrmUsrGrantGrpDetail",
                        "backend": "uia"
                    }, {
                        "ctrl_index": 4
                    }, {
                        "ctrl_index": 0
                    }])
                    work_place = pythonRPA.bySelector([{
                        "class_name": "TfrmUsrGrantGrpDetail",
                        "backend": "uia"
                    }, {
                        "ctrl_index": 0
                    }, {
                        "ctrl_index": 0
                    }, {
                        "ctrl_index": 0
                    }, {
                        "ctrl_index": 3
                    }, {
                        "ctrl_index": 0
                    }])
                    change_work_place = bool(
                        work_place.get_value() != '!!!!!!АРМ Пустой!'
                        and work_place.is_exists())
                    if (archive_click or zapret_click or change_work_place):
                        # Нажатие на кнопку коррекции
                        # Перенаправление фокус экрана на окошку редактирование
                        position.wait_appear(3)
                        position.set_focus()
                        position1.click()
                        pythonRPA.keyboard.press('down', 3)
                        pythonRPA.keyboard.press('enter')
                        if (change_work_place):
                            work_place.wait_appear(1)
                            work_place.click()
                            pythonRPA.keyboard.press('ctrl+A')
                            pythonRPA.keyboard.press('delete')
                            pythonRPA.keyboard.write("!!!!!!АРМ Пустой!")
                        # АРХИВ ЗАПРЕТ галочки и СОХРАНИТЬ
                        print(archive_click, zapret_click)
                        if (archive_click):
                            archive = pythonRPA.bySelector([{
                                "class_name": "TfrmUsrGrantGrpDetail",
                                "backend": "uia"
                            }, {
                                "ctrl_index": 0
                            }, {
                                "ctrl_index": 0
                            }, {
                                "ctrl_index": 2
                            }, {
                                "ctrl_index": 5
                            }])
                            archive.wait_appear(1)
                            archive.click()
                        if (zapret_click):
                            zapret = pythonRPA.bySelector([{
                                "class_name": "TfrmUsrGrantGrpDetail",
                                "backend": "uia"
                            }, {
                                "ctrl_index": 0
                            }, {
                                "ctrl_index": 0
                            }, {
                                "ctrl_index": 2
                            }, {
                                "ctrl_index": 4
                            }])
                            zapret.wait_appear(1)
                            zapret.click()
                        save = pythonRPA.bySelector([{
                            "class_name": "TfrmUsrGrantGrpDetail",
                            "backend": "uia"
                        }, {
                            "ctrl_index": 4
                        }, {
                            "ctrl_index": 0
                        }])
                        save.wait_appear(2)
                        save.click()
                        pythonRPA.keyboard.press('down', 2)
                        pythonRPA.keyboard.press('enter')
                        pythonRPA.sleep(3)
                    # Закрытие Позиции пользователя(Окошка коррекции учетной записи)
                    position.close()

                    #Дальше переходим к следующему шагу (Настройка полномочии)
                    while 1:
                        try:
                            x, y = pyautogui.locateCenterOnScreen(
                                r'.\Utils\polnom.png')
                            pyautogui.doubleClick(x, y)
                            break
                        except Exception as e:
                            print(e)

                    dependence_window = pythonRPA.bySelector([{
                        "class_name": "TfrmHieFrmOrg",
                        "backend": "uia"
                    }])
                    dependence_window.wait_appear(2)
                    dependence_window.set_focus()
                    dependence_window.maximize()
                    while (1):
                        try:
                            #нажимаем на кнопку двойной стрелки для того что бы мы голи нажатием пробелв удалять полномочии
                            x, y = pyautogui.locateCenterOnScreen(
                                r'.\Utils\left_button.png')
                            pyautogui.click(x, y)
                            break
                        except:
                            continue

                    for i in range(2):
                        pythonRPA.keyboard.press('down')
                    pythonRPA.keyboard.press('right')
                    pythonRPA.keyboard.press('down')

                    pythonRPA.keyboard.press('space', 20)
                    pythonRPA.sleep(2)  # в бою изменить период задержки

                    pythonRPA.keyboard.press('up', 5)
                    for i in range(3):
                        pythonRPA.keyboard.press('down')
                    pythonRPA.keyboard.press('right')
                    pythonRPA.keyboard.press('down')

                    pythonRPA.keyboard.press('space', 20)
                    pythonRPA.sleep(2)  # в бою изменить период задержки

                    dependence_window.close()
                    pythonRPA.sleep(3)
                    warning = pythonRPA.bySelector([{
                        "title": "Подтверждение",
                        "class_name": "TMessageForm",
                        "backend": "uia"
                    }])
                    try:
                        if warning.is_exists():
                            pythonRPA.keyboard.press('Enter')
                            pythonRPA.sleep(1)
                            pythonRPA.keyboard.press('Enter')
                    except:
                        print('no changes made')
                    pythonRPA.sleep(3)
            # Если мы дошли до этой строки значит робот не сломался и заблокиравал аккаунта удачно !
            # Ввод в действие полномочии пользователей
            while 1:
                try:
                    x, y = pyautogui.locateCenterOnScreen(r'.\Utils\red.png')
                    pyautogui.doubleClick(x, y)
                    print('red button pressed')
                    break
                except Exception as e:
                    print(e)
            pythonRPA.sleep(3)
            pythonRPA.keyboard.press('Enter')
            pythonRPA.sleep(2)
            pythonRPA.keyboard.press('Enter')
            pythonRPA.sleep(2)
            log_table.append([
                name, "Colvir", "Заблокирован", "",
                datetime.now().strftime("%H:%M:%S")
            ])
        except Exception as e:
            if not error:
                error = True
                Block_in_Colvir(names=[name], nums=nums, log_table=log_table)
                print(e)
            else:
                log_table.append([
                    name, "Colvir", "Не заблокирован", "Техническая ошибка",
                    datetime.now().strftime("%H:%M:%S")
                ])
                print('bacccccc')
                continue
    #
    # for num in nums:
    try:
        os.system("taskkill /f /im COLVIR.EXE")
    except Exception as e:
        print(e)
    print('THE END')
Пример #4
0
def download_report():
    # while (1):
    #     print('start')
    #     if datetime.datetime.now().strftime("%H:%M") == "19:00" or 1:
    #         try:
    #             # запуск Colvirtest (40TP)
    #             pythonRPA.application("C:\CBS_T/COLVIR.EXE").start()
    #         except Exception as e:
    #             print('colvir error ' + e)
    #     break

    try:
        # запуск Colvirtest (40TP)
        pythonRPA.application("C:\CBS_T/COLVIR.EXE").start()
    except Exception as e:
        print('colvir error ' + e)
    # Выполнение входа
    log_in = pythonRPA.bySelector([{
        "title": "Вход в систему",
        "class_name": "TfrmLoginDlg",
        "backend": "uia"
    }])
    log_in.wait_appear(30)
    log_in.click()
    log_in.set_focus()
    pythonRPA.keyboard.write("colvir")
    pythonRPA.keyboard.press("Enter")
    pythonRPA.keyboard.write("test_2722")
    pythonRPA.keyboard.press('Enter')
    # ert_1908
    # konakayev_t

    # Перенаправление фокус экрана на выбор режима
    mode_choosing = pythonRPA.bySelector([{
        "title": "Выбор режима",
        "class_name": "TfrmCssMenu",
        "backend": "win32"
    }])
    mode_choosing.wait_appear(10)
    mode_choosing.set_focus()
    time.sleep(2)
    mode_s = pythonRPA.bySelector([{
        "title": "Выбор режима",
        "class_name": "TfrmCssMenu",
        "backend": "win32"
    }, {
        "ctrl_index": 3
    }, {
        "ctrl_index": 0
    }, {
        "ctrl_index": 0
    }, {
        "ctrl_index": 0
    }])
    mode_s.click()

    # Очистка фильтра задач
    pythonRPA.keyboard.press('SHIFT+CTRL+A')
    pythonRPA.keyboard.press('Delete')
    pythonRPA.keyboard.write('PRS')
    pythonRPA.keyboard.press('Enter')

    # очистка фильтра
    pythonRPA.sleep(4)
    for iterr in range(50):
        try:
            x, y = pyautogui.locateCenterOnScreen(
                r'.\Utils\clear_filter_button.png')
            pyautogui.doubleClick(x, y)
            break
        except Exception as e:
            print(e)
            pythonRPA.sleep(1)

    # Заполнение Табельного номера
    tab_nomer = pythonRPA.bySelector([{
        "title": "PRS_GR4",
        "class_name": "TfrmFilterParams",
        "backend": "win32"
    }, {
        "ctrl_index": 1
    }, {
        "ctrl_index": 4
    }, {
        "ctrl_index": 0
    }])
    tab_nomer.wait_appear(2)
    tab_nomer.click()
    pythonRPA.keyboard.write("002509")
    # Нажатие кнопки ОК
    ok = pythonRPA.bySelector([{
        "title": "PRS_GR4",
        "class_name": "TfrmFilterParams",
        "backend": "uia"
    }, {
        "ctrl_index": 2
    }, {
        "ctrl_index": 0
    }, {
        "ctrl_index": 3
    }])
    ok.wait_appear(1)
    ok.click()

    # Выгрузка отчета
    for iterr in range(50):
        try:
            x, y = pyautogui.locateCenterOnScreen(r'.\Utils\report.png')
            pyautogui.doubleClick(x, y)
            break
        except Exception as e:
            print(e)
            pythonRPA.sleep(1)
    pythonRPA.sleep(5)

    for iterr in range(50):
        try:
            focus_on_report = pythonRPA.bySelector([{
                "title": "Выбор отчета",
                "class_name": "TfrmRptLstRefer",
                "backend": "uia"
            }])
            focus_on_report.wait_appear(2)
            focus_on_report.maximize()
            x, y = pyautogui.locateCenterOnScreen(
                r'.\Utils\filter_of_report.png')
            pyautogui.doubleClick(x, y)
            break
        except Exception as e:
            print(e)
            pythonRPA.sleep(1)

    # Set focus on Filter app
    filter_s = pythonRPA.bySelector([{
        "title": "Фильтр",
        "class_name": "TfrmFilterParams",
        "backend": "uia"
    }])
    filter_s.wait_appear(15)
    filter_s.set_focus()

    filtering_by_name = pythonRPA.bySelector([{
        "title": "Фильтр",
        "class_name": "TfrmFilterParams",
        "backend": "uia"
    }, {
        "ctrl_index": 0
    }, {
        "ctrl_index": 0
    }, {
        "ctrl_index": 0
    }])
    filtering_by_name.click()
    pythonRPA.keyboard.write("увол")

    filtering_by_code = pythonRPA.bySelector([{
        "title": "Фильтр",
        "class_name": "TfrmFilterParams",
        "backend": "uia"
    }, {
        "ctrl_index": 0
    }, {
        "ctrl_index": 1
    }, {
        "ctrl_index": 0
    }])
    filtering_by_code.click()
    pythonRPA.keyboard.write('Z_160_PRIKAZI_UVOLENNIH')

    filter_ok = pythonRPA.bySelector([{
        "title": "Фильтр",
        "class_name": "TfrmFilterParams",
        "backend": "uia"
    }, {
        "ctrl_index": 1
    }, {
        "ctrl_index": 0
    }, {
        "ctrl_index": 2
    }])
    filter_ok.click()

    # openning the parametrs of the filter
    time.sleep(2)
    pythonRPA.keyboard.press('Enter')
    parametrs_of_filter = pythonRPA.bySelector([{
        "title": "Параметры отчета ",
        "class_name": "TfrmRptPrmDialog",
        "backend": "uia"
    }])
    parametrs_of_filter.wait_appear(15)
    parametrs_of_filter.set_focus()
    pythonRPA.keyboard.press('Enter')

    parametr_filial = pythonRPA.bySelector([{
        "title": "Параметры отчета ",
        "class_name": "TfrmRptPrmDialog",
        "backend": "uia"
    }, {
        "ctrl_index": 0
    }, {
        "ctrl_index": 0
    }, {
        "ctrl_index": 0
    }])
    parametr_filial.click()
    pythonRPA.keyboard.write('00')
    pythonRPA.keyboard.press('Enter')
    # from_date = pythonRPA.bySelector([{"title":"Параметры отчета ","class_name":"TfrmRptPrmDialog","backend":"win32"},{"ctrl_index":0},{"ctrl_index":2},{"ctrl_index":0}])
    # to_date = pythonRPA.bySelector([{"title":"Параметры отчета ","class_name":"TfrmRptPrmDialog","backend":"win32"},{"ctrl_index":0},{"ctrl_index":4},{"ctrl_index":0}])

    today = date.today()
    today = today.strftime("%d%m%y")
    # from_date.click()
    pythonRPA.sleep(1)
    pythonRPA.keyboard.write("010120")
    pythonRPA.keyboard.press('Enter')
    # to_date.click()
    pythonRPA.sleep(1)
    pythonRPA.keyboard.write(today)
    parametr_ok = pythonRPA.bySelector([{
        "title": "Параметры отчета ",
        "class_name": "TfrmRptPrmDialog",
        "backend": "uia"
    }, {
        "ctrl_index": 1
    }, {
        "ctrl_index": 0
    }, {
        "ctrl_index": 1
    }])
    parametr_ok.click()
    pythonRPA.sleep(30)
    print("The report has been donwloaded sucsessfully !")
Пример #5
0
def block(names,log_table):
    # start Active  Directory
    pythonRPA.keyboard.press('win + R')
    Run = pythonRPA.bySelector([{"title": "Run", "backend": "win32"}])
    Run.wait_appear(2)
    pythonRPA.keyboard.write('dsa.msc')
    pythonRPA.keyboard.press('Enter')

    # clicking the SEARCH button to open the search window
    AD_main = pythonRPA.bySelector(
        [{"title": "Active Directory Users and Computers", "class_name": "MMCMainFrame", "backend": "win32"}])
    AD_main.wait_appear(5)
    AD_main.set_focus()
    AD_main.maximize()
    print("Active Directory opened well!")

    #Action click
    pyautogui.click(62, 36)
    #change_domain click
    while 1:
        try:
            x, y = pyautogui.locateCenterOnScreen(r'.\Utils\change_domain.png')
            pyautogui.click(x, y)
            print('change domain clickd !')
            pythonRPA.sleep(2)
            break
        except Exception as e:
            print(e)
    pythonRPA.keyboard.press('Enter')
    pythonRPA.sleep(2)
    # # click hcsbk
    # pythonRPA.keyboard.press('down')
    # pythonRPA.sleep(2)
    # pythonRPA.keyboard.press('Enter')
    while 1:
        try:
            x, y = pyautogui.locateCenterOnScreen(r'.\Utils\hcsbk.png')
            pyautogui.doubleClick(x, y)
            pythonRPA.sleep(2)
            print('clicked hcsbk well !')
            break
        except Exception as e:
            print(e)

    while 1:
        try:
            x, y = pyautogui.locateCenterOnScreen(r'.\Utils\SEARCH.png')
            pyautogui.doubleClick(x, y)
            break
        except Exception as e:
            print(e)
    find_users = pythonRPA.bySelector(
        [{"title": "Find Users, Contacts, and Groups", "class_name": "#32770", "backend": "win32"}])
    find_users.wait_appear(2)
    find_users.set_focus()
    find_users.maximize()

    for name in names:
        try:
            # log_ad_status = "Success"
            # log_ad_comment = ""
            success = 0
            # searching the accounts by full names
            if name != None and name == 'test test test':
                search_by_name = pythonRPA.bySelector(
                    [{"title": "Find Users, Contacts, and Groups", "class_name": "#32770", "backend": "win32"},
                     {"ctrl_index": 152},{"ctrl_index": 7}])
                clear_button = pythonRPA.bySelector(
                    [{"title": "Find Users, Contacts, and Groups", "class_name": "#32770", "backend": "win32"},
                     {"ctrl_index": 14}])
                clear_button.click()
                pythonRPA.keyboard.press('Enter')
                search_by_name.wait_appear(1)
                search_by_name.click()
                pythonRPA.keyboard.write(name)
                pythonRPA.sleep(1)
                search_ok = pythonRPA.bySelector(
                    [{"title": "Find Users, Contacts, and Groups", "class_name": "#32770", "backend": "win32"},
                     {"ctrl_index": 12}])
                search_ok.click()
                pythonRPA.sleep(3)
                # clicking the result
                found = False
                for i in range(5):
                    try:
                        x,y = pyautogui.locateCenterOnScreen(r'.\Utils\found.PNG')
                        found = True
                        break
                    except Exception as e:
                        print(e)

                if found:
                    x = 178
                    y = 340
                    pyautogui.rightClick(x, y)

                    # make an account disable
                    for i in range(5):
                        try:
                            a,b = pyautogui.locateCenterOnScreen(r'.\Utils\enable_condition.png')
                            for i in range(4):
                                pythonRPA.keyboard.press('down')
                                print(a,b)
                            pythonRPA.keyboard.press('Enter')
                            pythonRPA.sleep(1)
                            pythonRPA.keyboard.press('Enter')
                            is_enable =  True
                            break
                        except: continue

                    #
                    success += 1
                    print(success)

                    # Удаляем члены групп
                    # открытие свойств
                    pyautogui.rightClick(x, y)
                    pythonRPA.keyboard.press('up arrow')
                    pythonRPA.sleep(1)
                    pythonRPA.keyboard.press('Enter')
                    pythonRPA.sleep(3)

                    name_variants = get_profile_name(name)
                    for i in range(len(name_variants)):
                        try:
                            user_profile = pythonRPA.bySelector(
                                [{"title":name_variants[i] + " Properties", "class_name": "#32770", "backend": "win32"}])
                            user_profile.set_focus()
                            name = name_variants[i]
                            break
                        except Exception as e:
                            print(e)

                    while 1:
                        try:
                            x, y = pyautogui.locateCenterOnScreen(r'.\Utils\member_of.png')
                            pyautogui.doubleClick(x, y)
                            break
                        except Exception as e:
                            print(e)
                    domain_sub_group = pythonRPA.byImage(r'.\Utils\domain_users.png')

                    n = 0

                    try:
                        sub_group = pythonRPA.bySelector(
                            [{"title": name + " Properties", "class_name": "#32770", "backend": "win32"},
                             {"ctrl_index": 17}, {"ctrl_index": 2}])
                        sub_group.wait_appear(1)
                        sub_group.click()
                        pythonRPA.keyboard.press('up')
                        press_key("shift", 5)
                        pythonRPA.keyboard.press("Shift")
                        remove_button = pythonRPA.bySelector(
                            [{"title": name + " Properties", "class_name": "#32770", "backend": "win32"},
                             {"ctrl_index": 0},
                             {"ctrl_index": 4}])
                        remove_button.click()
                        pythonRPA.keyboard.press('left')
                        pythonRPA.sleep(1)
                        pythonRPA.keyboard.press('Enter')
                        warning = pythonRPA.bySelector(
                            [{"title": "Active Directory Domain Services", "class_name": "#32770", "backend": "win32"}])
                        if (warning.is_exists()):
                            pythonRPA.keyboard.press('Enter')
                        ok = pythonRPA.bySelector([{"title":name+" Properties","class_name":"#32770","backend":"win32"},{"ctrl_index":12}])
                        ok.click()
                        pythonRPA.keyboard.press('Enter')
                    except Exception as e:
                        pythonRPA.keyboard.press('Enter')
                        break
                    success += 1
                    print(success)

                    # move this account to th blocked accounts
                    find_users.set_focus()
                    find_users.maximize()
                    clear_button = pythonRPA.bySelector(
                        [{"title": "Find Users, Contacts, and Groups", "class_name": "#32770", "backend": "win32"},
                         {"ctrl_index": 14}])
                    clear_button.click()
                    pythonRPA.keyboard.press('Enter')
                    search_by_name.wait_appear(1)
                    search_by_name.click()
                    pythonRPA.keyboard.write(name)
                    pythonRPA.sleep(1)
                    search_ok = pythonRPA.bySelector(
                        [{"title": "Find Users, Contacts, and Groups", "class_name": "#32770", "backend": "win32"},
                         {"ctrl_index": 12}])
                    search_ok.click()
                    pythonRPA.sleep(3)

                    # clicking the result
                    x = 178
                    y = 340
                    pyautogui.rightClick(x, y)
                    search_by_name.wait_appear(1)
                    search_by_name.click()
                    pyautogui.rightClick(x, y)
                    for i in range(6):
                        pythonRPA.keyboard.press('down arrow')
                    pythonRPA.keyboard.press('Enter')
                    pythonRPA.sleep(1)
                    move_to_block = pythonRPA.bySelector([{"title": "Move ", "class_name": "#32770", "backend": "win32"}])
                    move_to_block.wait_appear(1)
                    move_to_block.set_focus()
                    for i in range(10):
                        pythonRPA.keyboard.press('down arrow')
                    pythonRPA.keyboard.press('Enter')
                    print(name, 'Account added to BLOCK sucsessfully !')
                    pythonRPA.sleep(1)
                    success += 1
                    print(success)
                    if success == 3:
                        log_table.append([name, "Active Directory", "Заблокирован", "", datetime.now().strftime("%H:%M:%S")])
                    else:
                        log_table.append([name, "Active Directory", "Не заблокирован", "Сотрудник не найден в системе", datetime.now().strftime("%H:%M:%S")])
        except Exception as e:
            log_table.append([name, "Active Directory", "Не заблокирован", "Техническая ошибка", datetime.now().strftime("%H:%M:%S")])
    try:
        f = wmi.WMI()
        for p in f.Win32_Process():
         if p.name == 'mmc.exe':
             p.Terminate()
    except Exception as e:
        print(e)