Skip to content

Commit 8c15b98

Browse files
authored
Update ApexFarmer.py to v1.4.1
1 parent 216b049 commit 8c15b98

File tree

1 file changed

+112
-51
lines changed

1 file changed

+112
-51
lines changed

ApexFarmer.py

Lines changed: 112 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import configparser
2+
import ctypes
23
from pyautogui import *
34
import pyautogui
45
import time
@@ -15,8 +16,12 @@
1516
import datetime
1617
import pytesseract
1718
import cv2
18-
19+
import rainbowtext
1920
# instantiate
21+
22+
UP = '\033[1A'
23+
CLEAR = '\x1b[2K'
24+
ctypes.windll.kernel32.SetConsoleTitleW("APEX XP FARM BOT BY LETSMOKE")
2025
config = configparser.ConfigParser()
2126
if os.path.isfile('config.ini') is not True:
2227
config['CONFIG'] = {'Time': '9000',
@@ -36,27 +41,31 @@
3641
OCR_debug = int(config.get('CONFIG', 'OCR_debug'))
3742
show_exp = int(config.get('CONFIG', 'show_exp'))
3843

39-
print(r" _____ ________ __ ______ _____ __ __ ______ _____ ")
40-
print(r" /\ | __ \| ____\ \ / / | ____/\ | __ \| \/ | ____| __ \ ")
41-
print(r" / \ | |__) | |__ \ V / | |__ / \ | |__) | \ / | |__ | |__) | ")
42-
print(r" / /\ \ | ___/| __| > < | __/ /\ \ | _ /| |\/| | __| | _ / ")
43-
print(r" / ____ \| | | |____ / . \ | | / ____ \| | \ \| | | | |____| | \ \ ")
44-
print(r" /_/____\_\_|__ |______/_/_\_\ |_|/_/ ___\_\_| \_\_|__|_|______|_|__\_\ ")
45-
print(r" ____ _ _ _ ______ ________ ____ __ __ ____ _ __ _____ ")
46-
print(r" | _ \ \ / / | | | ____|__ __/ ____| \/ |/ __ \| |/ / ____| ")
47-
print(r" | |_) \ \_/ / | | | |__ | | | (___ | \ / | | | | ' /| |__ ")
48-
print(r" | _ < \ / | | | __| | | \___ \| |\/| | | | | < | __| ")
49-
print(r" | |_) | | | | |____| |____ | | ____) | | | | |__| | . \| |____ ")
50-
print(r" |____/ |_| |______|______| |_| |_____/|_| |_|\____/|_|\_\______| ")
44+
print(rainbowtext.text(r" _____ ________ __ ______ _____ __ __ ______ _____ "))
45+
print(rainbowtext.text(r" /\ | __ \| ____\ \ / / | ____/\ | __ \| \/ | ____| __ \ "))
46+
print(rainbowtext.text(r" / \ | |__) | |__ \ V / | |__ / \ | |__) | \ / | |__ | |__) | "))
47+
print(rainbowtext.text(r" / /\ \ | ___/| __| > < | __/ /\ \ | _ /| |\/| | __| | _ / "))
48+
print(rainbowtext.text(r" / ____ \| | | |____ / . \ | | / ____ \| | \ \| | | | |____| | \ \ "))
49+
print(rainbowtext.text(r" /_/____\_\_|__ |______/_/_\_\ |_|/_/ ___\_\_| \_\_|__|_|______|_|__\_\ "))
50+
print(rainbowtext.text(r" ____ _ _ _ ______ ________ ____ __ __ ____ _ __ _____ "))
51+
print(rainbowtext.text(r" | _ \ \ / / | | | ____|__ __/ ____| \/ |/ __ \| |/ / ____| "))
52+
print(rainbowtext.text(r" | |_) \ \_/ / | | | |__ | | | (___ | \ / | | | | ' /| |__ "))
53+
print(rainbowtext.text(r" | _ < \ / | | | __| | | \___ \| |\/| | | | | < | __| "))
54+
print(rainbowtext.text(r" | |_) | | | | |____| |____ | | ____) | | | | |__| | . \| |____ "))
55+
print(rainbowtext.text(r" |____/ |_| |______|______| |_| |_____/|_| |_|\____/|_|\_\______| "))
5156
print("")
5257
print(" ___________________ ")
53-
print("CONFIG: -> | Time for restart: | >>>", timp, "sec")
58+
print("CONFIG: -> | Time for restart: | >>> ", timp, "sec")
5459
print("CONFIG: -> | Apex Directory: | >>>", apexdir)
5560
print("CONFIG: -> | Show earned XP: | >>>", show_exp)
5661
print("CONFIG: -> | DEBUG MODE: | >>>", OCR_debug)
5762
print(" ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ ")
63+
print('')
64+
print('')
65+
print('')
5866
print("Press any key to continue if settings are correct")
5967
msvcrt.getch()
68+
print(UP, end=CLEAR)
6069
print("Continuing...")
6170

6271
def resource_path(relative_path):
@@ -77,6 +86,9 @@ def resource_path(relative_path):
7786
exp_new1=0
7887
exp_new2=0
7988
n = 1
89+
time_stuck=0
90+
time_stuck_start=0
91+
time_stuck_end=0
8092

8193
#checking if apex is running
8294
def process_exists(process_name):
@@ -91,26 +103,35 @@ def process_exists(process_name):
91103
if process_exists('r5apex.exe'):
92104
mod = 2
93105
start_time = time.time()
106+
time_stuck_start= time.time()
94107

95108
else:
96109
mod = 1
97-
#checking if apex is running
98-
110+
#checking if apex is running
99111
#program loop
100112
while True:
101-
#print ('Mod = ', mod)
102-
print ('----------Starting game and setting Apex window active-----------')
103113
#starting game, make apex window active, starting counting for game restart
104114
if mod == 1:
105-
subprocess.call([apexdir])
106-
time.sleep(10)
115+
if process_exists('r5apex.exe') is False:
116+
print(UP, end=CLEAR)
117+
print ("------------------------------------GAME NOT STARTED, STARTING-------------------------------------")
118+
subprocess.call([apexdir])
107119
start_time = time.time()
120+
time_stuck_start= time.time()
121+
time_stuck_end=0
122+
time.sleep(10)
108123
window_found = 0
109124
mod = 2
110125

111126
#checkking if game was opened and closing news or other in game windows
112127
while mod == 2:
113-
print ('----------Checking if game is opened and getting into main menu-------------')
128+
time_stuck_end=time.time()
129+
time.sleep(0.5)
130+
time_stuck=time_stuck_end-time_stuck_start
131+
if time_stuck>240:
132+
mod=4
133+
print(UP, end=CLEAR)
134+
print ('----------APEX LEGENDS FOUND, PROCEEDING SETTING ACTIVE WINDOW AND PREPARE FOR MATCHMAKING-------------')
114135
apex_hwnd = win32gui.FindWindow(None,'Apex Legends')
115136
time.sleep(0.5)
116137
if (apex_hwnd != 0) and (window_found == 0):
@@ -125,7 +146,8 @@ def process_exists(process_name):
125146
window_found = 1
126147

127148
if pyautogui.locateOnScreen(resource_path('ss\\InGame.png'), region=(87, 755, 379, 304), grayscale=True, confidence=0.5) is not None:
128-
print("-------------In game detected, moving to mode farming--------------")
149+
print(UP, end=CLEAR)
150+
print("------------------------------DETECTED IN MATCH, MOVING TO FARMING MODE-----------------------------")
129151
mod = 3
130152

131153
if pyautogui.locateOnScreen(resource_path('ss\\gameopen.png'), grayscale=True, confidence=0.7) != None:
@@ -134,20 +156,16 @@ def process_exists(process_name):
134156
pyautogui.click(956, 647)
135157

136158
if pyautogui.locateOnScreen(resource_path('ss\\news.png'), grayscale=True, confidence=0.6) != None:
137-
#print("news")
138159
keyboard.press_and_release('esc')
139160

140161
if pyautogui.locateOnScreen(resource_path('ss\\space2.png'), grayscale=True, confidence=0.6) != None:
141-
#print("continue2")
142162
keyboard.press_and_release('esc')
143163

144164
if pyautogui.locateOnScreen(resource_path('ss\\space2.png'), region=(676,777,619,304), grayscale=True, confidence=0.6) != None:
145-
#print("space2.png")
146165
keyboard.press_and_release('space')
147166
time.sleep(np.random.uniform(0.4,0.8))
148167

149168
if pyautogui.locateOnScreen(resource_path('ss\\back.png'), grayscale=True, confidence=0.6) != None:
150-
#print("back")
151169
time.sleep(np.random.uniform(0.3,0.8))
152170
keyboard.press_and_release('esc')
153171

@@ -164,15 +182,14 @@ def process_exists(process_name):
164182
pyautogui.moveTo(200,100)
165183
if (pyautogui.locateOnScreen(resource_path('ss\\team.png'), confidence=0.9) is None) and (pyautogui.locateOnScreen(resource_path('ss\\notready.png'), region=(0,538,447,528), grayscale=True, confidence=0.7) != None):
166184
time.sleep(1)
167-
print ('----------Apex window active and game started------------')
168-
if pyautogui.locateOnScreen(resource_path('ss\\team.png'), confidence=0.9) is None:
169-
print('------------------------------------------------')
170-
print('---------------Fill not checked-----------------')
171-
print('------------------------------------------------')
185+
print(UP, end=CLEAR)
186+
print ('-------------------------------------------READY TO FARM-------------------------------------------')
187+
if pyautogui.locateOnScreen(resource_path('ss\\team.png'), confidence=0.9) is None:
188+
#print('---------------Fill not checked-----------------')
189+
#print(UP, end=CLEAR)
190+
time.sleep(2)
172191
pyautogui.moveTo(200,100)
173192
mod = 3
174-
#print ('WHILE mod = ', mod)
175-
176193

177194
#program loop
178195
while mod == 3:
@@ -194,7 +211,9 @@ def process_exists(process_name):
194211
time.sleep(0.1)
195212

196213
elif (pyautogui.locateOnScreen(resource_path('ss\\matchmaking.png'), region=(0,538,447,528), confidence=0.8) != None) and (time_lapsed < timp-600):
197-
print ('----------MATCHMAKING STARTED------------')
214+
#print(UP, end=CLEAR)
215+
#print ('----------MATCHMAKING STARTED------------')
216+
time.sleep(2)
198217
else:
199218
pass
200219

@@ -225,15 +244,20 @@ def process_exists(process_name):
225244
pyautogui.click(850, 713)
226245
time.sleep(np.random.uniform(0.4,0.8))
227246
pyautogui.click(850, 713)
247+
time.sleep(4)
248+
if pyautogui.locateOnScreen(resource_path('ss\\battlepass.png'), region=(51,987,122,41), grayscale=True, confidence=0.8) != None:
249+
#print('space2')
250+
keyboard.press_and_release('space')
251+
time.sleep(0.5)
228252
if pyautogui.locateOnScreen(resource_path('ss\\matchsummary.png'), region=(564,18,814,115), grayscale=True, confidence=0.8) != None:
229253
#print('matchsummary')
230254
keyboard.press_and_release('space')
231-
time.sleep(2)
255+
time.sleep(0.5)
232256
if pyautogui.locateOnScreen(resource_path('ss\\matchsummary.png'), region=(564,18,814,115), grayscale=True, confidence=0.8) is None:
233257
while True:
234258
if pyautogui.locateOnScreen(resource_path('ss\\expscreen.png'), region=(657,0,603,97), confidence=0.8) != None:
235259
#print('exp screen')
236-
time.sleep(6)
260+
time.sleep(5)
237261
if show_exp==1:
238262
image1=pyautogui.screenshot(region=(457,231,61,38))
239263
imagenp1 = np.array(image1)
@@ -293,18 +317,28 @@ def process_exists(process_name):
293317
time.sleep(np.random.uniform(0.3,0.7))
294318
pyautogui.click(952, 717)
295319
if show_exp==1:
296-
print ('---------- Currently farming for ',datetime.timedelta(seconds=round(time_lapsed_absolute)),'TOTAL EXP:', exp, 'New EXP:',exp_new,'--------------')
297-
print ('---------- Time counted for restart: ',datetime.timedelta(seconds=round(time_lapsed)),'-----','ingame:' ,ingame, "--------------------")
320+
print(UP, end=CLEAR)
321+
print(UP, end=CLEAR)
322+
print(UP, end=CLEAR)
323+
print(UP, end=CLEAR)
324+
print(" ___________________ ")
325+
print (' | TOTAL TIME FARMED | -> |',' | TOTAL EXP:', exp," | ",datetime.timedelta(seconds=round(time_lapsed_absolute)),"| ",)
326+
print (' | RESTART TIME | -> |',' | NEW EXP:',exp_new," | ",datetime.timedelta(seconds=round(time_lapsed))," / ", datetime.timedelta(seconds=round(timp)),"| ")
327+
print(" ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ ")
298328
else:
299-
print ('---------- Currently farming for ',datetime.timedelta(seconds=round(time_lapsed_absolute)),'--------------')
300-
print ('---------- Time counted for restart: ',datetime.timedelta(seconds=round(time_lapsed)),'-----','ingame:' ,ingame, "--------------------")
301-
329+
print(UP, end=CLEAR)
330+
print(UP, end=CLEAR)
331+
print(" ___________________ ")
332+
print (' | TOTAL TIME FARMED | -> |'," | ",datetime.timedelta(seconds=round(time_lapsed_absolute)),"| ",)
333+
print (' | RESTART TIME | -> |'," | ",datetime.timedelta(seconds=round(time_lapsed))," / ", datetime.timedelta(seconds=round(timp)),"| ")
334+
print(" ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ ")
302335
#checking if time lapsed is more than set time and checking if it's in game
303336
if (time_lapsed > timp-600) and (ingame == 0):
304337
time.sleep (15)
305338
mod = 4
306339
if pyautogui.locateOnScreen(resource_path('ss\\afk.png'), region=(588,265,776,536), grayscale=True, confidence=0.8) != None:
307-
print ('---------- DETECTED AFK, PROCEEDING TO REINITIALIZE -------------')
340+
print(UP, end=CLEAR)
341+
#print ('---------- DETECTED AFK, PROCEEDING TO REINITIALIZE -------------')
308342
pyautogui.click(960, 719)
309343
time.sleep(np.random.uniform(0.3,0.7))
310344
pyautogui.click(960, 719)
@@ -314,36 +348,63 @@ def process_exists(process_name):
314348
if process_exists('r5apex.exe'):
315349
pass
316350
else:
351+
print(UP, end=CLEAR)
352+
print(UP, end=CLEAR)
353+
print(UP, end=CLEAR)
354+
print(UP, end=CLEAR)
317355
print ('---------- APEX IS NOT RUNNING, WHAT DO YOU WANT TO DO? -------------')
318-
print ('---------- STOP - TYPE 1 /// RESTART - TYPE 2 -------------')
356+
print ('--------------- STOP - TYPE 1 /// RESTART - TYPE 2 ------------------')
319357
while True:
320-
data_input = int(input('PICK WHAT TO DO NEXT: '))
358+
data_input = int(input('----------------------- PICK WHAT TO DO NEXT: -----------------------'))
321359
if data_input == 1:
322-
print ('---------- SESSION STATS -------------')
360+
print(UP, end=CLEAR)
361+
print(UP, end=CLEAR)
362+
print(UP, end=CLEAR)
363+
print(" ____________ ")
364+
print (' | FARM STATS |')
365+
print(" ‾‾‾‾‾‾‾‾‾‾‾‾ ")
323366
if show_exp==1:
324-
print ('---------- TIME: ',datetime.timedelta(seconds=round(time_lapsed_absolute)),' | TOTAL EXP EARNED:', exp,'--------------')
325-
print ('---------- EXIT IN 5 SEC --------------')
326-
time.sleep(5)
367+
print(" ___________________ ")
368+
print (' | TOTAL TIME FARMED | -> | ', exp)
369+
print (' | TOTAL XP GAINED | -> | ',datetime.timedelta(seconds=round(time_lapsed_absolute)))
370+
print(" ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ ")
371+
time.sleep(15)
327372
exit()
328373
else:
329-
print ('---------- TIME: ',datetime.timedelta(seconds=round(time_lapsed_absolute)),'--------------')
330-
print ('---------- EXIT IN 5 SEC --------------')
331-
time.sleep(5)
374+
print(" ___________________ ")
375+
print (' | TOTAL TIME FARMED | -> | N/A')
376+
print (' | TOTAL XP GAINED | -> | ',datetime.timedelta(seconds=round(time_lapsed_absolute)))
377+
print(" ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ ")
378+
time.sleep(15)
332379
exit()
333380
elif data_input == 2:
381+
print(UP, end=CLEAR)
382+
print(UP, end=CLEAR)
383+
print(UP, end=CLEAR)
334384
print ('---------- PROGRAM RESTART -------------')
385+
time.sleep(1)
386+
print(UP, end=CLEAR)
387+
print ('')
388+
print ('')
389+
print ('')
390+
print ('')
335391
mod = 1
336392
exp=0
337393
exp_new=0
338394
exp_new1=0
339395
exp_new2=0
340396
break
341397
else:
398+
print(UP, end=CLEAR)
342399
print ('You have made an invalid choice, try again.')
343400

344401
#checking if apex is running
345402

346403
if mod == 4:
404+
print(UP, end=CLEAR)
405+
print(UP, end=CLEAR)
406+
print(UP, end=CLEAR)
407+
print(UP, end=CLEAR)
347408
os.system('taskkill /f /im r5apex.exe')
348409
os.system('taskkill /f /im r5apex.exe')
349410
time.sleep(15)

0 commit comments

Comments
 (0)