Created
September 26, 2022 08:10
-
-
Save WizzyGeek/42dff9f6aa54df1d22998f2e016e697c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyautogui import * | |
import pyautogui | |
import time | |
import keyboard | |
import pygetwindow as gw | |
import sys | |
import math | |
import win32api | |
screencenter = 1980 / 2, 1080 / 2 | |
mm_off = complex(18, 63) | |
mm_center = complex(70, 70) | |
radius = 5 | |
''' | |
accs = [ | |
#["p1",gw.getWindowsWithTitle('repo')[0]], | |
["p2",gw.getWindowsWithTitle('Mitos.is: The Game')], | |
#["p3",gw.getWindowsWithTitle('Tom79M')[0]], | |
#["p4",gw.getWindowsWithTitle('Concorde')[0]], | |
#["p5",gw.getWindowsWithTitle('tominho')[0]], | |
#["p6",gw.getWindowsWithTitle('daemon')[0]] | |
] | |
''' | |
accs = gw.getWindowsWithTitle('') | |
names = { | |
"repo", | |
"armour", | |
#"wear", | |
#"daemon", | |
#"tmac" | |
} | |
print(accs) | |
print(accs[0].__dict__) | |
def search_marker(s): | |
dots = [] | |
for x in range(s.width): | |
for y in range(s.height): | |
if s.getpixel((x, y)) == (255, 255, 255): | |
dots.append(complex(x, y)) | |
return sum(dots) / len(dots) | |
sc = complex(screencenter[0], screencenter[1]) | |
def movement_vector(c): | |
return mm_center - c | |
def sharp_step(m): | |
return radius * math.sqrt(max(m.real, 20) ** 2 + max(m.imag, 20) ** 2) / 20 | |
def click_transform(m): | |
return m * sharp_step(m) + sc | |
def change_window(): | |
pyautogui.keyDown('alt') | |
pyautogui.press('esc') | |
pyautogui.keyUp('alt') | |
#def click_transform(c): # c needs to wrt top left of minimap | |
#return cmath.rect(radius, cmath.phase(c - mm_center)) | |
while keyboard.is_pressed('q') == False: | |
clickx = screencenter[0] | |
clicky = screencenter[1] | |
for i in range(len(names)): | |
# window = accs[i] | |
# print(window) | |
change_window() | |
print(gw.getActiveWindowTitle()) | |
if gw.getActiveWindowTitle() not in names: | |
continue | |
''' | |
try: | |
window.activate() | |
except: | |
window.minimize() | |
window.maximize() | |
''' | |
try: | |
c = search_marker(pyautogui.screenshot(region=(18, 63, 140, 140))) | |
print(c) | |
except ZeroDivisionError: | |
print("marker not found, respawning/clicking center") | |
pyautogui.click(screencenter) | |
else: | |
try: | |
#Found the marker | |
print("I can see it") | |
m = movement_vector(c) | |
x,y = c.real, c.imag | |
ret = click_transform(m) | |
clickx, clicky = ret.real, ret.imag | |
# l_param = win32api.MAKELONG(round(clickx), round(clicky)) | |
print("clicking on"+str(clickx)+","+str(clicky)) | |
pyautogui.click(clickx,clicky) | |
#win32gui.SendMessage(window._hwnd, win32con.WM_MOUSEMOVE, 1, l_param) | |
print("Location: of cell on minimap"+str(x)+","+str(y)) | |
time.sleep(0.5) | |
if keyboard.is_pressed('q') != False: | |
sys.exit() | |
except: | |
pass | |
## 1980 * 1080 | |
# minimap top = 63 | |
# left = 18 | |
# minimap size 140, 140from pyautogui import * |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment