-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
36 lines (28 loc) · 808 Bytes
/
bot.py
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
from typing import Tuple
from PIL import ImageGrab, ImageOps
import pyautogui
import time
from numpy import *
class Cordinates():
replayBtn = (340,390)
dinosaur = (171, 395)
def restartGame():
pyautogui.click(Cordinates.replayBtn)
def pressSpace():
pyautogui.keyDown('space')
time.sleep(0.05)
print("Jump")
pyautogui.keyUp('space')
def imageGrab():
box = (Cordinates.dinosaur[0]+60, Cordinates.dinosaur[1], Cordinates.dinosaur[0]+150, Cordinates.dinosaur[1]+100)
image = ImageGrab.grab(box)
grayImage = ImageOps.grayscale(image)
a = array(grayImage.getcolors())
print(a.sum())
def main():
restartGame()
while True:
if(imageGrab() != 9338):
pressSpace()
time.sleep(0.1)
main()