Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.94 KB | None | 0 0
  1. from PIL import ImageGrab
  2. import time
  3. import numpy as np
  4. import cv2
  5. import pyautogui
  6. from pynput import keyboard
  7. from pynput.keyboard import Key, Controller
  8. import ctypes
  9. import sys
  10. global blackList, ammo, shouldExit
  11. #ZOOM 175%%%%
  12. #Old screen cords 653, 585, 1142, 803  AND 259, 700, 1114, 1008 HACKER -> 396, 748, 1306, 1028
  13. screenCords = [469, 715, 1251, 993]
  14. time.sleep(3)
  15. ammo = 0
  16. shouldExit = False
  17. Keyboard = Controller()
  18. pyautogui.PAUSE = 0
  19. def on_release(key):
  20.     if key == keyboard.Key.esc:
  21.         global shouldExit
  22.         shouldExit = True
  23.  
  24. listener = keyboard.Listener(on_release=on_release)
  25. listener.start()
  26.  
  27. def click(x, y):
  28.     # convert to ctypes pixels
  29.     # x = int(x * 0.666)
  30.     # y = int(y * 0.666)
  31.     ctypes.windll.user32.SetCursorPos(x, y)
  32.     ctypes.windll.user32.mouse_event(2, 0, 0, 0, 0)  # left down
  33.     ctypes.windll.user32.mouse_event(4, 0, 0, 0, 0)  # left up
  34.  
  35. def grayPixelDetect(screenCord):
  36.     img = cv2.imread('screenShotsGame/1.png')
  37.     indicesa = np.where(np.all((img == (62,62,62)) | (img == (61,61,61)), axis=-1))
  38.     print(indicesa)
  39.     try:
  40.         xCord = indicesa[1][0]
  41.         yCord = indicesa[0][0]
  42.         TrueXCorda = xCord + screenCords[0]
  43.         TrueYCorda = yCord + screenCords[1]
  44.         return TrueXCorda, TrueYCorda
  45.     except:
  46.         pass
  47. def screenGrab(screenCord):
  48.     global TrueXCord
  49.     global TrueYCord
  50.     im = ImageGrab.grab(bbox=screenCords)
  51.     im.save("ScreenShotsGame/1.png")
  52.     #time.sleep(15)
  53.     img = cv2.imread('screenShotsGame/1.png')
  54.     #print(img.shape)
  55.     indices = np.where(np.all(img == (255,255,255), axis=-1))
  56.     #print(indices)
  57.     #indices2 = np.where(np.all(img == (62,62,62), axis=-1))
  58.     try:
  59.         #print(indices)
  60.         xCord = indices[1][0]
  61.         yCord = indices[0][0]
  62.         TrueXCord = xCord + screenCords[0] + 5
  63.         TrueYCord = yCord + screenCords[1]
  64.         #print(indices)
  65.         #print("X : {}".format(xCord))
  66.         #print("Y : {}".format(yCord))
  67.         #print("True X : {}".format(TrueXCord))
  68.         #print("True Y : {}".format(TrueYCord))
  69.         return TrueXCord, TrueYCord
  70.     except:
  71.         pass
  72.  
  73. def shootNigger(screenCords):
  74.     global ammo
  75.     try:
  76.         #if ammo == 3:
  77.         ammo = 0
  78.             #print("DDD")
  79.             #Keyboard.press(Key.space)
  80.             #time.sleep(0.3)
  81.             #Keyboard.release(Key.space)
  82.         #else:
  83.         xCord, yCord = screenGrab(screenCords)
  84.         try:
  85.             xCord1, yCord1 = grayPixelDetect(screenCords)
  86.             click(int(xCord1),int(yCord1))
  87.         except:
  88.             pass
  89.         #print(blackList)
  90.         #print(xCord, yCord)
  91.         click(int(xCord),int(yCord))
  92.         #ammo += 1
  93.         #print(ammo)
  94.     except:
  95.         pass
  96.  
  97.  
  98.  
  99. while True:
  100.     try:
  101.         shootNigger(screenCords)
  102.         #print(shouldExit)
  103.         if shouldExit:
  104.             print("Pressed Escape!")
  105.             break
  106.     except:
  107.         pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement