Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from PIL import ImageGrab
- import cv2
- from directKeys import click, queryMousePosition
- # import pyautogui
- import keyboard
- import time
- game_coords = [1610, 1165, 2680, 1570]
- pyautogui.PAUSE = 0
- def shoot_some_fuckers (screen) :
- global game_coords
- # print("shooot", screen)
- for y in range (5, len(screen) -5):
- for x in range (5, len(screen[y]) -5):
- # print(">>>>>>>>>>> ", screen[y][x])
- if screen[y][x] < 10:
- actual_x = x + (int(game_coords[0])/2)
- actual_y = y + (int(game_coords[1])/2)
- # click(actual_x, actual_y)
- pyautogui.click(x=actual_x, y=actual_y)
- # click(actual_x, actual_y)
- # pyautogui.click(actual_x, actual_y)
- print("shooot <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< [",x, actual_x, " - ",y, actual_y)
- return
- # only start the program after the mouse is on the left screen
- while True:
- # mouse_pos = queryMousePosition()
- mouse_pos = pyautogui.position()
- # print("init 1", mouse_pos[0], mouse_pos[1])
- if mouse_pos[0] == 0:
- break
- test = 0
- while True:
- # mouse_pos = queryMousePosition()
- # print("start 2")
- mouse_pos = pyautogui.position()
- # try: # used try so that if user pressed other than the given key error will not be shown
- # if keyboard.is_pressed('q'): # if key 'q' is pressed
- # print('You Pressed A Key!')
- # break # finishing the loop
- # else:
- # pass
- # except:
- # break # if user pressed a key other than the given key the loop will break
- if (game_coords[0]/2) < mouse_pos[0] < (game_coords[2]/2) and (game_coords[1]/2) < mouse_pos[1] < (game_coords[3]/2):
- # print("run 3")
- start_time = time.time()
- # ImageGrab.grab(bbox = game_coords).save("test.png")
- screen = ImageGrab.grab(bbox = game_coords)
- screen = np.array(screen)
- screen = cv2.resize(screen, (0,0), fx=0.5, fy=0.5)
- screen = cv2.cvtColor(screen, cv2.COLOR_BGR2GRAY)
- shoot_some_fuckers(screen)
- print("Frame took {} seconds".format((time.time() - start_time)))
- if test == 20:
- print("TIME BREAK")
- break
- else:
- test = test + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement