-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathropes_bot.py
64 lines (50 loc) · 1.38 KB
/
ropes_bot.py
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
from pyautogui import *
from datetime import datetime
import pygetwindow as gw
import pyautogui
import time
import random
import keyboard
import win32api, win32con
# Controller button maper, change to fit yours
A = "space"
X = "k"
L_UP = "w"
L_DOWN = "s"
R_UP = "t"
R_DOWN = "g"
def get_time_stamp():
dateTimeObj = datetime.now()
return dateTimeObj.strftime("(%H:%M:%S)")
def press_button(button):
keyboard.press(button)
time.sleep(0.2)
keyboard.release(button)
def press_buttons(button1, button2):
keyboard.press(button1)
keyboard.press(button2)
time.sleep(0.1)
keyboard.release(button1)
keyboard.release(button2)
print(get_time_stamp(), "Starting battle ropes bot in 3 seconds. Make sure you are next to the battle ropes.")
time.sleep(1)
print(get_time_stamp(), "Starting battle ropes bot in 2 seconds.")
time.sleep(1)
print(get_time_stamp(), "Starting battle ropes bot in 1 second.")
time.sleep(1)
print(get_time_stamp(), "Starting bot.")
win = gw.getWindowsWithTitle('NBA 2K21')
if len(win) > 0:
win[0].activate();
else:
print(get_time_stamp(), "NBA 2K21 is not running. Exiting.");
exit()
press_button(A)
time.sleep(5)
press_button(A) # change to X for debug
for i in range(150):
press_buttons(L_UP, R_DOWN)
time.sleep(0.08)
press_buttons(R_UP, L_DOWN)
time.sleep(0.1)
print(get_time_stamp(), "The bot finished! Goodbye");