From f9455ade480f22425d1a77bee7f8cba6db11b30b Mon Sep 17 00:00:00 2001 From: Thaloria Date: Mon, 2 May 2022 19:54:29 +0200 Subject: [PATCH] refactor dig --- config_file.py | 22 +++++++++++++++++++++- utils.py | 29 +++++++++++++++++++++++++++++ window_capture.py | 4 ++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/config_file.py b/config_file.py index 4504095..219da36 100644 --- a/config_file.py +++ b/config_file.py @@ -17,7 +17,17 @@ class UserConfigs: elif user_from_env == self.EDDIEUSER: self.user = self.EDDIEUSER else: - self.user = self.ADWAUSER + self.user = self.THALOUSER + + def returnOKWindowPos(self): + if self.user == self.THALOUSER: + return [310, 200, 1120, 920] + elif self.user == self.ADWAUSER: + return [740, 450, 1625, 985] + elif self.user == self.EDDIEUSER: + return [740, 450, 1625, 985] + else: + pass def returnMagicWindowPos(self): if self.user == self.THALOUSER: @@ -49,6 +59,16 @@ class UserConfigs: else: pass + def returnDiggingWindowPos2(self): + if self.user == self.THALOUSER: + return [1440, 1150, 570, 22] + elif self.user == self.ADWAUSER: + return [740, 450, 1625, 985] + elif self.user == self.EDDIEUSER: + return [740, 450, 1625, 985] + else: + pass + def returnEquipmentWindowPos(self): if self.user == self.THALOUSER: return [1800, 1150, 0, 0] diff --git a/utils.py b/utils.py index 6d690d0..ef86cdf 100644 --- a/utils.py +++ b/utils.py @@ -2,6 +2,16 @@ import numpy as np import os import cv2 as cv from PIL import Image +import pydirectinput +import random +import random +from time import time + +import cv2 as cv + +import pydirectinput +import keyboard +from tresh_util import super_tresh_main, super_tresh_needle def mse(imageA, imageB): @@ -144,3 +154,22 @@ def update_screenshot_with_short_pic_list(short_pic_lst, lst_bl_items): # save_line_item_npy_jpg(r_short_pic_lst) return screenshot + + +def dig_point(point1, point2, dig_time): + pydirectinput.moveTo(point1, point2) + pydirectinput.mouseDown() + w = random.randint(1, 50) + cv.waitKey(dig_time + w) + pydirectinput.mouseUp() + + +def check_for_ok_button(cap_win, vis, conf): + screenshot = cap_win.get_screenshot() + rectangles = vis.find(screenshot, cv.imread("dig/ok_button.jpg", cv.IMREAD_UNCHANGED), 0.5, 1) + offset_left = conf.returnDiggingWindowPos2()[2] + offset_down = conf.returnDiggingWindowPos2()[3] + if len(rectangles) == 1: + pointis = vis.get_click_points(rectangles) + for pointi in pointis: + dig_point(pointi[0] + offset_left, pointi[1] + offset_down, 150) diff --git a/window_capture.py b/window_capture.py index 2386fae..4098637 100644 --- a/window_capture.py +++ b/window_capture.py @@ -31,8 +31,12 @@ class WindowCapture: val = config.returnDiggingWindowPos() elif area == "magic": val = config.returnMagicWindowPos() + elif area == "dig2": + val = config.returnDiggingWindowPos2() elif area == "equip": val = config.returnEquipmentWindowPos() + elif area == "screen_conf": + val = config.returnOKWindowPos() else: val = config.returnFullScreenWindowPos()