-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGTA-SpeedType-Bot.py
More file actions
executable file
·64 lines (52 loc) · 1.77 KB
/
GTA-SpeedType-Bot.py
File metadata and controls
executable file
·64 lines (52 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# GTA SAMP SpeedType bot made by Camille Rakotoarisoa (https://camillerakoto.fr)
"""
Instructions :
- pip install pynput
- pip install pytesseract
- pip install opencv-python
- Install Tesseract setup for Windows or brew install Tesseract for mac (and save the path)
- pip install tesseract
"""
# cv2.cvtColor takes a numpy ndarray as an argument
import numpy as nm
#pip install pytesseract et télécharger Tesseract
import pytesseract
# importing OpenCV : pip install opencv-python
import cv2
from PIL import ImageGrab
import re
import platform
#pip install pynput
from pynput.keyboard import Key, Controller
keyboard = Controller()
class Bot:
def __init__(self, kbrd_keys, coords, tesseract_path):
self.kbrd_keys = kbrd_keys
self.coords = coords
self.tesseract_path = tesseract_path
def recordScreen(self):
pytesseract.pytesseract.tesseract_cmd = self.tesseract_path
cap = ImageGrab.grab(bbox =(self.coords['top'], self.coords['left'], self.coords['height'], self.coords['width']))
tesstr = pytesseract.image_to_string(
cv2.cvtColor(nm.array(cap), cv2.COLOR_BGR2GRAY),
lang ='eng')
return tesstr
def getTheCode(self, screen):
all_strings_on_screen = screen.split(' ')
for string in all_strings_on_screen:
if code_begin in string:
return string
def enterTheCodeInChat(self, code):
keyboard.press(self.kbrd_keys['tchat_key'])
keyboard.release(self.kbrd_keys['tchat_key'])
for char in code:
keyboard.press(char)
keyboard.release(char)
#Keyboard keys, Screen Resolution, Tesseract path
bot = Bot({ 'tchat_key': 't' }, {'top':0, 'left':0, 'height':1366, 'width':768}, r'C:\Program Files\Tesseract-OCR\tesseract.exe')
code_begin = 'N/A'
while True:
screen = bot.recordScreen()
code = bot.getTheCode(screen)
if code != None:
bot.enterTheCodeInChat(code)