Skip to content

Instantly share code, notes, and snippets.

@math280h
Last active June 13, 2022 01:41
Show Gist options
  • Select an option

  • Save math280h/234e5caa89195749196830e60079b838 to your computer and use it in GitHub Desktop.

Select an option

Save math280h/234e5caa89195749196830e60079b838 to your computer and use it in GitHub Desktop.
More Ore weak spot auto-finder/clicker (https://syns.studio/more-ore/)
import cv2
import numpy as np
import pyautogui
import time
import keyboard
print("Started.... Waiting to take screenshot")
time.sleep(5)
while True:
if keyboard.is_pressed('q'):
exit(0)
myScreenshot = pyautogui.screenshot()
myScreenshot.save(r'./Capture.PNG')
print("Screenshot taken")
print("Checking screenshot for weakpoint")
# Opening image
img = cv2.imread("Capture.PNG")
lower_bound = np.array([114, 0, 0])
upper_bound = np.array([243, 0, 0])
mask_light = cv2.inRange(img, (243, 243, 243), (243, 243, 243))
mask_dark = cv2.inRange(img, (114, 114, 114), (114, 114, 114))
mask = cv2.bitwise_or(mask_light, mask_dark)
output = cv2.bitwise_and(img, img, mask=mask)
gray_image = cv2.cvtColor(output, cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(gray_image, 127, 255, 0)
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
cv2.drawContours(img, contours, -1, (0, 255, 0), 3)
found = []
for idx, i in enumerate(contours):
M = cv2.moments(i)
if M['m00'] != 0:
cx = int(M['m10'] / M['m00'])
cy = int(M['m01'] / M['m00'])
cv2.drawContours(img, [i], -1, (0, 255, 0), 2)
cv2.circle(img, (cx, cy), 7, (0, 0, 255), -1)
cv2.putText(img, "center", (cx - 20, cy - 20),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 2)
found.append([cx, cy])
print(f"x: {cx} y: {cy}")
if found:
print("Found weak spot, moving to it")
pyautogui.moveTo(found[0][0], found[0][1])
# Only enable if you trust my shitty ass code
# pyautogui.click(x=found[0][0], y=found[0][1])
else:
print("No weak spot found")
cv2.imshow('Original Image', img)
time.sleep(1)
cv2.waitKey(0)
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment