import os import time import pyautogui emailbuttonimagepath =…
- User
import os import time import pyautogui
email_button_image_path = "D:/screensWOT/forwork/mail.png" password_button_image_path = "D:/screensWOT/forwork/password.png" submit_button_image_path = "D:/screensWOT/forwork/voity.png" locationvalid_image_path = "D:/screensWOT/forwork/valid.png" locationnevalid_image_path = "D:/screensWOT/forwork/nevalid.png" tank_image_path = "D:/screensWOT/forwork/tank.png" sbros_image_path = "D:/screensWOT/forwork/sbros.png" arenda_image_path = "D:/screensWOT/forwork/arenda.png" tops_image_path = "D:/screensWOT/forwork/tops.png" prems_image_path = "D:/screensWOT/forwork/prems.png" panel_image_path = "D:/screensWOT/forwork/panel.png" topsvkl_image_path = "D:/screensWOT/forwork/topsvkl.png" nastroyki_image_path = "D:/screensWOT/forwork/nastroyki.png" vixod_image_path = "D:/screensWOT/forwork/vixod.png" da_image_path = "D:/screensWOT/forwork/da.png" stop_image_path = "D:/screensWOT/forwork/stop.png" crestik_image_path = "D:/screensWOT/forwork/crestik.png" crestik2_image_path = "D:/screensWOT/forwork/crestik2.png" otkaz_image_path = "D:/screensWOT/forwork/otkaz.png" valid_accounts_path = "D:/screensWOT/valid_accounts.txt" nevalid_accounts_path = "D:/screensWOT/nevalid_accounts.txt" passagir_accounts_path = "D:/screensWOT/passagir_accounts.txt" ok_image_path = "D:/screensWOT/forwork/ok.png" file_path = "D:/fileobuch/accsforscreens.txt" arrays = []
with open(file_path, "r") as file: for line in file: parts = line.strip().split(":") arrays.append(parts)
def save_account_info(filepath, email, password): """Функция для сохранения логина и пароля в файл""" with open(filepath, "a") as file: file.write(f"{email}:{password}\n")
def vxod(email, password): timeout1 = 1 # секунды start_time1 = time.time() while time.time() - start_time1 < timeout1: try: ok = pyautogui.locateOnScreen(ok_image_path, confidence=0.8) if ok: pyautogui.click(ok) pyautogui.click(ok) time.sleep(2) break except pyautogui.ImageNotFoundException: pass # Игнорируем ошибку и продолжаем цикл time.sleep(1) pyautogui.click(x=942, y=716) pyautogui.doubleClick(x=942, y=716) pyautogui.write(email)
print("Email введен: " + email) locationpass = pyautogui.locateCenterOnScreen( password_button_image_path, confidence=0.6, grayscale=True ) if locationpass: pyautogui.click(locationpass) pyautogui.click(locationpass) pyautogui.write(password) time.sleep(1) print("Пароль введен.") else: print("Не удалось найти поле ввода пароля.") return False locationsubmit = pyautogui.locateCenterOnScreen( submit_button_image_path, confidence=0.65 ) if locationsubmit: pyautogui.click(locationsubmit) pyautogui.click(locationsubmit) print("Произведен клик для входа.") else: print("Не удалось найти кнопку входа.") return False timeout = 30 # Установим таймаут в 20 секунд start_time = time.time() # Ждем появления одного из изображений на экране в течение установленного таймаута while True: try: locationvalid = pyautogui.locateCenterOnScreen( locationvalid_image_path, confidence=0.65 ) if locationvalid: print("Вход выполнен успешно.") save_account_info(valid_accounts_path, email, password) time.sleep(40) return True except pyautogui.ImageNotFoundException: pass # Если изображение не найдено, пропускаем итерацию try: locationnevalid = pyautogui.locateCenterOnScreen( locationnevalid_image_path, confidence=0.65 ) if locationnevalid: print("Обнаружена ошибка входа.") save_account_info(nevalid_accounts_path, email, password) return False except pyautogui.ImageNotFoundException: pass # Если изображение не найдено, пропускаем итерацию try: passagir = pyautogui.locateCenterOnScreen(stop_image_path, confidence=0.8) if passagir: print("Обнаружена ошибка входа.") pyautogui.click(x=958, y=637) time.sleep(1) pyautogui.click(x=959, y=637) time.sleep(1) save_account_info(passagir_accounts_path, email, password) return False except pyautogui.ImageNotFoundException: pass # Если изображение не найдено, пропускаем итерацию time.sleep(0.5) # Небольшая пауза между попытками # Если достигнут таймаут, завершаем ожидание if time.time() - start_time > timeout: print("Таймаут ожидания.") return False - Assistant
The script you've provided is designed to automate a sequence of GUI interactions using the PyAutoGUI library. It reads login credentials from a text file, performs login attempts, and performs some operations contingent on the success of the login. The script also takes screenshots at different stages, and stores account information in text files based on the outcome of each login attempt.