Repository navigation
Expand file tree
/
Copy pathactions.py
More file actions
62 lines (47 loc) · 1.48 KB
/
Copy pathactions.py
File metadata and controls
62 lines (47 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import time
import numpy as np
import pydirectinput as pdi
from PIL import Image, ImageGrab
import pytesseract as pt
class ScreenCoords:
def __init__(self, x, y):
self.x = x
self.y = y
def GetCoords(self):
return (self.x,self.y)
class ScreenBox:
def __init__(self, left, down, right, up):
self.left = left
self.down = down
self.right = right
self.up = up
def GetBox(self):
return (self.left, self.down, self.right, self.up)
def Capture(self):
img = ImageGrab.grab(bbox=(self.left, self.down, self.right, self.up))
#img.show()
return np.array(img)
def CaptureAndOpen(self):
img = ImageGrab.grab(bbox=(self.left, self.down, self.right, self.up))
img.show()
class StoreItem:
def __init__(self, screenBox, screenCoords):
self.box = screenBox
self.coords = screenCoords
self.name = None
def __str__(self):
return f"{self.name}"
def Update(self):
self.name = ReadCapture(self.box.Capture())
def Buy(self):
pdi.click(self.coords.x, self.coords.y, duration=0.25)
def ReadCapture(capture):
return pt.image_to_string(capture, config='--psm 7').rstrip()
def GetPixelColor(x, y):
return pdi.screenshot().getpixel((x,y))
def DoClick(coords):
pdi.click(coords[0], coords[1], duration=0.25)
def RefreshStore():
pdi.hotkey("d")
def LevelUp():
pdi.hotkey("f")