Suppenbiatch

CSGO AUTO Accept V0.01

Mar 16th, 2020
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.62 KB | None | 0 0
  1. from time import sleep, time
  2.  
  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. screen_width, screen_height = win32api.GetSystemMetrics(0), win32api.GetSystemMetrics(1)
  25. toplist, winlist = [], []
  26. test_for_live_game, accept = False, False
  27. hwnd = 0
  28. start_time = time()
  29.  
  30. while True:
  31.     if win32api.GetAsyncKeyState(0x78) & 1:
  32.         test_for_live_game = not test_for_live_game
  33.         print("TESTING: ", test_for_live_game)
  34.  
  35.     if win32api.GetAsyncKeyState(0x2D) & 1:
  36.         break
  37.         print("Exiting Script")
  38.  
  39.     if test_for_live_game:
  40.         winlist = []
  41.         win32gui.EnumWindows(enum_cb, toplist)
  42.         csgo = [(hwnd, title) for hwnd, title in winlist if 'counter-strike: global offensive' in title.lower()]
  43.         if not csgo:
  44.             continue
  45.         hwnd = csgo[0][0]
  46.         if time() - start_time < 4:
  47.             continue
  48.         start_time = time()
  49.         win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
  50.         try:
  51.             bbox = win32gui.GetWindowRect(hwnd)
  52.         except pywintypes.error:
  53.             continue
  54.         img = ImageGrab.grab(bbox)
  55.         i_width, i_height = img.size
  56.         if i_width != 2650 and i_height != 1440:
  57.             img = img.resize([2560, 1440])
  58.         img_acc = Image.open("accept.jpg")
  59.         img_difference = ImageChops.difference(img_acc, img)
  60.         img_data = img_difference.getdata()
  61.  
  62.         # img_difference.show()
  63.         # img_difference.save("dif.png")
  64.         # img.save("img.png")
  65.  
  66.         pix, color_average = [], []
  67.         r, g, b = [], [], []
  68.         for y in range(y1, y2 + 1):
  69.             for x in range(x1, x2 + 1):
  70.                 pix.append(img_data[y * 2560 + x])
  71.  
  72.         for i in pix:
  73.             r.append(i[0])
  74.             g.append(i[1])
  75.             b.append(i[2])
  76.  
  77.         color_average.append(Avg(r))
  78.         color_average.append(Avg(g))
  79.         color_average.append(Avg(b))
  80.         for i in color_average:
  81.             accept = True
  82.             if i >= 3:
  83.                 accept = False
  84.     if accept:
  85.         # test_for_live_game = False
  86.         for _ in range(5):
  87.             click(int(screen_width / 2), int(screen_height / 1.78))
  88.             sleep(0.5)
  89.         accept = False
Add Comment
Please, Sign In to add comment