Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. import numpy as np
  2. from PIL import ImageGrab
  3. import cv2
  4. from directKeys import click, queryMousePosition
  5. # import pyautogui
  6. import keyboard
  7. import time
  8.  
  9. game_coords = [1610, 1165, 2680, 1570]
  10. pyautogui.PAUSE = 0
  11.  
  12. def shoot_some_fuckers (screen) :
  13. global game_coords
  14. # print("shooot", screen)
  15.  
  16.  
  17. for y in range (5, len(screen) -5):
  18. for x in range (5, len(screen[y]) -5):
  19.  
  20. # print(">>>>>>>>>>> ", screen[y][x])
  21.  
  22. if screen[y][x] < 10:
  23. actual_x = x + (int(game_coords[0])/2)
  24. actual_y = y + (int(game_coords[1])/2)
  25. # click(actual_x, actual_y)
  26. pyautogui.click(x=actual_x, y=actual_y)
  27. # click(actual_x, actual_y)
  28. # pyautogui.click(actual_x, actual_y)
  29. print("shooot <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< [",x, actual_x, " - ",y, actual_y)
  30. return
  31.  
  32.  
  33. # only start the program after the mouse is on the left screen
  34. while True:
  35. # mouse_pos = queryMousePosition()
  36. mouse_pos = pyautogui.position()
  37. # print("init 1", mouse_pos[0], mouse_pos[1])
  38. if mouse_pos[0] == 0:
  39. break
  40.  
  41. test = 0
  42.  
  43. while True:
  44. # mouse_pos = queryMousePosition()
  45. # print("start 2")
  46. mouse_pos = pyautogui.position()
  47.  
  48. # try: # used try so that if user pressed other than the given key error will not be shown
  49. # if keyboard.is_pressed('q'): # if key 'q' is pressed
  50. # print('You Pressed A Key!')
  51. # break # finishing the loop
  52. # else:
  53. # pass
  54. # except:
  55. # break # if user pressed a key other than the given key the loop will break
  56.  
  57. if (game_coords[0]/2) < mouse_pos[0] < (game_coords[2]/2) and (game_coords[1]/2) < mouse_pos[1] < (game_coords[3]/2):
  58. # print("run 3")
  59. start_time = time.time()
  60. # ImageGrab.grab(bbox = game_coords).save("test.png")
  61.  
  62. screen = ImageGrab.grab(bbox = game_coords)
  63. screen = np.array(screen)
  64. screen = cv2.resize(screen, (0,0), fx=0.5, fy=0.5)
  65. screen = cv2.cvtColor(screen, cv2.COLOR_BGR2GRAY)
  66. shoot_some_fuckers(screen)
  67. print("Frame took {} seconds".format((time.time() - start_time)))
  68.  
  69. if test == 20:
  70. print("TIME BREAK")
  71. break
  72. else:
  73. test = test + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement