Базовое человекоподобное передвижение мыши

This commit is contained in:
2023-03-11 18:40:11 +03:00
parent 234ed9c931
commit 0b0a923daf
2 changed files with 22 additions and 4 deletions

23
main.py
View File

@@ -1,10 +1,12 @@
import time import time
import random
import logging import logging
import numpy as np import numpy as np
import pygetwindow as gw
import pyautogui
import cv2 import cv2
import pygetwindow as gw
import pyautogui as pg
from pyclick import HumanClicker
import easyocr import easyocr
import pandas as pd import pandas as pd
@@ -24,6 +26,15 @@ logging.info("Бот: запущен")
reader = easyocr.Reader(["en"], gpu=True) reader = easyocr.Reader(["en"], gpu=True)
logging.info("Бот: модели загружены") logging.info("Бот: модели загружены")
hc = HumanClicker()
def move_mouse(x, y):
hc.move(
(x, y),
random.uniform(0.1, 0.4),
)
def get_screenshot(): def get_screenshot():
eve_window = gw.getWindowsWithTitle(win_name)[0] eve_window = gw.getWindowsWithTitle(win_name)[0]
@@ -41,7 +52,7 @@ def get_screenshot():
filepath = None filepath = None
time.sleep(0.5) time.sleep(0.5)
screenshot = pyautogui.screenshot( screenshot = pg.screenshot(
filepath, filepath,
region=( region=(
eve_window.box.left + 10, eve_window.box.left + 10,
@@ -168,5 +179,9 @@ def get_targets(boxes_frame, name=False):
while True: while True:
screenshot = get_screenshot() screenshot = get_screenshot()
boxes_frame = get_boxes(screenshot) boxes_frame = get_boxes(screenshot)
get_targets(boxes_frame, "(veldspar)") targets = get_targets(boxes_frame, "(veldspar)")
move_mouse(targets.iloc[0].cent_x, targets.iloc[0].cent_y)
move_mouse(30, 30)
input("Следущий скриншот - enter") input("Следущий скриншот - enter")

View File

@@ -15,6 +15,7 @@ packaging==23.0
pandas==1.5.3 pandas==1.5.3
Pillow==9.4.0 Pillow==9.4.0
PyAutoGUI==0.9.53 PyAutoGUI==0.9.53
pyclick==0.0.2
pyclipper==1.3.0.post4 pyclipper==1.3.0.post4
PyGetWindow==0.0.9 PyGetWindow==0.0.9
PyMsgBox==1.0.9 PyMsgBox==1.0.9
@@ -23,6 +24,7 @@ PyRect==0.2.0
PyScreeze==0.1.28 PyScreeze==0.1.28
python-bidi==0.4.2 python-bidi==0.4.2
python-dateutil==2.8.2 python-dateutil==2.8.2
python3-xlib==0.15
pytweening==1.0.4 pytweening==1.0.4
pytz==2022.7.1 pytz==2022.7.1
PyWavelets==1.4.1 PyWavelets==1.4.1
@@ -37,3 +39,4 @@ torch==1.13.1+cu116
torchvision==0.14.1+cu116 torchvision==0.14.1+cu116
typing_extensions==4.5.0 typing_extensions==4.5.0
urllib3==1.26.14 urllib3==1.26.14
xlib==0.21