Suppenbiatch

CSGO Auto Accept V0.02

Mar 17th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.52 KB | None | 0 0
  1. from time import sleep, time
  2. from playsound import playsound
  3. import win32api
  4. import win32con
  5. import win32gui
  6. from PIL import Image, ImageChops, ImageGrab
  7.  
  8.  
  9. def Avg(lst):
  10.     return sum(lst) / len(lst)
  11.  
  12.  
  13. def enum_cb(hwnd, results):
  14.     winlist.append((hwnd, win32gui.GetWindowText(hwnd)))
  15.  
  16.  
  17. def click(x, y):
  18.     win32api.SetCursorPos((x, y))
  19.     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
  20.     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
  21.  
  22.  
  23. coordinate = x1, y1, x2, y2 = 1265, 760, 1295, 785
  24. test_for_color = [15, 30, 15]
  25. screen_width, screen_height = win32api.GetSystemMetrics(0), win32api.GetSystemMetrics(1)
  26. toplist, winlist = [], []
  27. hwnd = 0
  28. test_for_live_game, accept, debugging = False, False, False
  29. start_time = time()
  30. print("Ready")
  31.  
  32. while True:
  33.     if win32api.GetAsyncKeyState(0x78) & 1: #F9
  34.         test_for_live_game = not test_for_live_game
  35.         print("TESTING: ", test_for_live_game)
  36.         if test_for_live_game:
  37.             playsound('active.mp3')
  38.         else:
  39.             playsound('deactivated.mp3')
  40.  
  41.     if win32api.GetAsyncKeyState(0x77) & 1: #F8 (DEBUGGING)
  42.         try:
  43.             print("Avg: ", color_average)
  44.         except NameError:
  45.             continue
  46.         img_difference.show()
  47.         img_difference.save("dif.png")
  48.  
  49.     if win32api.GetAsyncKeyState(0x76) & 1: #F7 (DEBUGGING)
  50.         debugging = not debugging
  51.         print("debugging: ", debugging)
  52.  
  53.     if win32api.GetAsyncKeyState(0x24) & 1: #POS1/HOME Key
  54.         print("Exiting Script")
  55.         break
  56.  
  57.     if test_for_live_game:
  58.         winlist = []
  59.         win32gui.EnumWindows(enum_cb, toplist)
  60.         csgo = [(hwnd, title) for hwnd, title in winlist if 'counter-strike: global offensive' in title.lower()]
  61.         if not csgo:
  62.             continue
  63.         hwnd = csgo[0][0]
  64.         if time() - start_time < 4:
  65.             continue
  66.         start_time = time()
  67.         win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
  68.         try:
  69.             bbox = win32gui.GetWindowRect(hwnd)
  70.         except pywintypes.error:
  71.             continue
  72.         img = ImageGrab.grab(bbox)
  73.         i_width, i_height = img.size
  74.         if i_width != 2650 and i_height != 1440:
  75.             img = img.resize([2560, 1440])
  76.         img_acc = Image.open("accept.jpg")
  77.         img_difference = ImageChops.difference(img_acc, img)
  78.         img_data = img_difference.getdata()
  79.  
  80.         # img_difference.show()
  81.         # img_difference.save("dif.png")
  82.  
  83.         pix, color_average = [], []
  84.         r, g, b = [], [], []
  85.         for y in range(y1, y2 + 1):
  86.             for x in range(x1, x2 + 1):
  87.                 pix.append(img_data[y * 2560 + x])
  88.  
  89.         for i in pix:
  90.             r.append(i[0])
  91.             g.append(i[1])
  92.             b.append(i[2])
  93.  
  94.         color_average.append(Avg(r))
  95.         color_average.append(Avg(g))
  96.         color_average.append(Avg(b))
  97.         accept = True
  98.         for i, color in enumerate(color_average, start=0):
  99.             if color >= test_for_color[i]:
  100.                 accept = False
  101.         if debugging:
  102.             print("Avg: ", color_average)
  103.             img.save("img.png")
  104.             img_difference.save("img_dif.png")
  105.  
  106.     if accept:
  107.         img_difference.save("dif_acc.png")
  108.         img.save("img_acc.png")
  109.         print("Trying to Accept")
  110.         print(color_average)
  111.         # test_for_live_game = False
  112.         for _ in range(5):
  113.             click(int(screen_width / 2), int(screen_height / 1.78))
  114.             sleep(0.5)
  115.         accept = False
Add Comment
Please, Sign In to add comment