def auto_clicker(): mouse = Mouse() random_event = random.randint(1, 100) choices = ["left", "right", "up", "down"] if random_event > 98: choice = random.choice(choices) # Left Camera Movement if choice == "left": print("Left Movement") PressKey(A) time.sleep(0.1) ReleaseKey(A) PressKey(D) time.sleep(0.1) ReleaseKey(D) time.sleep(1) elif choice == "right": # Right Camera Movement print("Right Movement") PressKey(D) time.sleep(0.1) ReleaseKey(D) PressKey(A) time.sleep(0.1) ReleaseKey(A) time.sleep(1) elif choice == "up": # Right Camera Movement random_movement = random.randint(0, 10) Move(0, -random_movement) time.sleep(2) Move(0, random_movement) time.sleep(2) elif choice == "down": # Right Camera Movement random_movement = random.randint(0, 10) Move(0, random_movement) time.sleep(2) Move(0, -random_movement) time.sleep(2) mouse.click(Button.right) # Clicks the left mouse button once time.sleep(random.uniform(0.2, 0.3))
def game_reset(self): mouse = Controller() # Exiting Game for i in list(range(4))[::-1]: print(i + 1) time.sleep(1) # Exiting Game PressKey(BACK) time.sleep(0.2) ReleaseKey(BACK) time.sleep(1) PressKey(O) time.sleep(0.2) PressKey(P) time.sleep(0.2) PressKey(BACK) time.sleep(0.2) time.sleep(2) ReleaseKey(O) ReleaseKey(P) ReleaseKey(BACK) time.sleep(6) mouse.position = (737, 227) mouse.click(Button.left, 1) time.sleep(0.5) PressKey(SPACE) ReleaseKey(SPACE) time.sleep(0.5) mouse.position = (338, 401) mouse.click(Button.left, 1) time.sleep(4) print('Reset done!')
def move(self, direction=None, keypress_num=None): PressKey(direction) if keypress_num > 1: for i in range(0, keypress_num): time.sleep(0.1) ReleaseKey(direction) time.sleep(0.1) PressKey(direction) if direction == W: ReleaseKey(direction) time.sleep(0.5) ReleaseKey(direction) else: time.sleep(1) ReleaseKey(direction) return
def attack_actions(self, choice=None, choice_num=None): dir_num = len(choice[0]) if dir_num > 1: for i in range(0, dir_num): PressKey(choice[0][i]) if choice[2][i] == True: continue count = 0 press_s = False if choice[1][i] > 1: for k in range(0, choice[1][i]): try: if count == 2 and choice[0][2] == S: PressKey(S) press_s = True except: None time.sleep(0.05) ReleaseKey(choice[0][i]) time.sleep(0.05) PressKey(choice[0][i]) count += 1 if press_s == True: ReleaseKey(S) if 12 <= choice_num <= 15: time.sleep(0.6) else: time.sleep(0.5) ReleaseKey(choice[0][i]) else: ReleaseKey(choice[0][i]) ReleaseKey(choice[0][0]) else: PressKey(choice[0][0]) time.sleep(0.05) ReleaseKey(choice[0][0]) return
def GetPlayerHand(): print("Getting Players Hand") PressKey(YourKey) im = ImageGrab.grab(bbox=(X1, Y1, X22, Y2)) # X1,Y1,X2,Y2 im.save("Player.jpg") time.sleep(2) ReleaseKey(YourKey) FlipColor("Player.jpg") Hand = pytesseract.image_to_string(Image.open('Player.jpg'),config = '--psm 7 ') print("Extracted: " + Hand) s = Hand Handvalue = ''.join(i for i in s if i.isdigit()) return(Handvalue)
def KeyPress(hexKeyCode): PressKey(hexKeyCode) time.sleep(.5) ReleaseKey(hexKeyCode)
def right(): PressKey(D) PressKey(W) ReleaseKey(A) ReleaseKey(W) ReleaseKey(D)
def left(): PressKey(A) PressKey(W) ReleaseKey(W) ReleaseKey(D) ReleaseKey(A)
def straight(): PressKey(W) ReleaseKey(A) ReleaseKey(D)
if len(cnts_left) > 0: c = max(cnts_left, key=cv2.contourArea) ((x, y), radius) = cv2.minEnclosingCircle(c) M = cv2.moments(c) center_left = (int(M["m10"] / (M["m00"] + 0.000001)), int(M["m01"] / (M["m00"] + 0.000001))) if (radius > circle_radius): cv2.circle(frame, (int(x), int(y)), int(radius), (0, 255, 255), 2) cv2.circle(frame, center_left, 5, (0, 0, 255), -1) if (center_left[1] < (height / 2 - windowSize // 2)): cv2.putText(frame, 'LEFT', (20, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255)) PressKey(A) current_key_pressed.add(A) keyPressed = True keyPressed_lr = True elif (center_left[1] > (height / 2 + windowSize // 2)): cv2.putText(frame, 'RIGHT', (20, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255)) PressKey(D) current_key_pressed.add(D) keyPressed = True keyPressed_lr = True if (len(cnts_right) > 0): c2 = max(cnts_right, key=cv2.contourArea) ((x2, y2), radius2) = cv2.minEnclosingCircle(c2) M2 = cv2.moments(c2)
def main(): ############ ##Settings## ############ inputOn = True screenOn = False noteType = 'bar' #options: bar | arrow ############### ##Calibration## ############### #Current settings for ~30 fps #c500:30 | c200:15 | c150:10 threshold = 30 #how early notes can be hit minThreshold = 15 #how late notes can be hit base = 52 #exactly where receptors are ##delay lays somewhere between (0.02,0.5) ##idk tbh #delay = 0.04 delay = 0.002 #minimum time between arrow presses ############# ##Constants## ############# #mark middle of note from top #lrHeight is left,right notes and udHeight is up,down notes if noteType == 'arrow': lrHeight = 30 udHeight = 30 if noteType == 'bar': lrHeight = 13 udHeight = 13 #Define lower and upper range of what is considered that color #lower,upper BGR format red = ([0, 0, 150], [130, 130, 255], 'red') yellow = ([0, 160, 160], [50, 255, 255], 'yellow') blue = ([100, 0, 0], [250, 56, 50], 'blue') colors = [red] #which colors will be looked for video = [ ] #if screenOn=True, stores each frame of screen, clears at 5000 frames count = 0 avgFPS = 0 tUP = 0 tLEFT = 0 tRIGHT = 0 tDOWN = 0 ##Print settings print '[Notetype]:', noteType print '[Colors]: ', colors print '[Threshold]:', threshold print '[Min-Threshold]:', minThreshold while (True): tInitial = time.time() ##Input format: (width,height),(cornerX,cornerY) screen = CaptureScreen((300, 150), (1340, 94)) screen = cv2.cvtColor(screen, cv2.COLOR_RGBA2RGB) #remove alpha channel contours = [] ##mask the screen over the selected colors to find arrows of said colors ##and store each contour(arrow) in a list for color in colors: #masked_data = ColorMask(screen,color[0],color[1]) frameDelta = ColorMask(screen, color[0], color[1]) #cv2.imshow('%s' %(color[2]),masked_data) #cv2.waitKey(1) #frameDelta = cv2.absdiff(background, masked_data) #was masked_data #cv2.imshow('diff',frameDelta) #frameDelta = cv2.cvtColor(frameDelta, cv2.COLOR_BGR2GRAY) (c1, contoursTemp, c2) = cv2.findContours(frameDelta, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) contours.extend(contoursTemp) ##Hitbox drawing cv2.line(screen, (0, base), (300, base), (255, 0, 0), 2) #receptor hitbox #min-threshold lines cv2.line(screen, (0, base - 29 - minThreshold), (500, base - 29 - minThreshold), (0, 0, 255), 1) cv2.line(screen, (0, base - 13 - minThreshold), (500, base - 13 - minThreshold), (0, 0, 255), 1) #max-threshold line cv2.line(screen, (0, base + threshold), (300, base + threshold), (125, 125, 0), 1) #receptor hitbox #Lane lines cv2.line(screen, (47, 0), (47, 200), (255, 0, 0), 1) cv2.line(screen, (111, 0), (111, 200), (255, 0, 0), 1) cv2.line(screen, (175, 0), (175, 200), (255, 0, 0), 1) cv2.line(screen, (240, 0), (240, 200), (255, 0, 0), 1) ################# ##Hit Detection## ################# for cnt in contours: ##make sure we're not picking up some random contour if cv2.contourArea(cnt) > 20: ##bounding rectangle: rectangle that encompasses contour ##x,y is top left coord, w,h is width and height x, y, w, h = cv2.boundingRect(cnt) ##calculate X position of arrow moments = cv2.moments(cnt) cx = int(moments['m10'] / moments['m00']) ##calculate y position of arrow cy = y + 30 if (cx < 47 + 31 and cx > 47 - 31) or (cx < 240 + 31 and cx > 240 - 31): cy = y + lrHeight #determine note's hitbox if y <= base - lrHeight - minThreshold: #check not too far up continue elif (cx < 111 + 31 and cx > 111 - 31) or (cx < 175 + 31 and cx > 175 - 31): if y < base - udHeight - minThreshold: continue cy = y + udHeight ##outlines arrow and draws boxes around them ##just for visual purposes cv2.rectangle(screen, (x, y), (x + w, y + h), (0, 255, 0), 1) #cv2.drawContours(screen, [cnt],-1, (0, 255, 0), 1) ##draw arrow's "hitline" in light blue cv2.line(screen, (x, cy), (x + w, cy), (255, 255, 0), 2) ##if the arrow is within threshold pixels of the target ##then press the appropriate key if cy < base + threshold and cy > base - threshold - 5 and inputOn: if cx < 47 + 31 and cx > 47 - 31: #notes cannot be pressed twice within "delay" seconds if tInitial - tLEFT < delay: continue tLEFT = time.time() #reset input timer PressKey(LEFT) cv2.line(screen, (x, cy), (x + w, cy), (0, 255, 255), 2) ReleaseKey(LEFT) if cx < 111 + 31 and cx > 111 - 31: if tInitial - tDOWN < delay: continue tDOWN = time.time() PressKey(DOWN) cv2.line(screen, (x, cy), (x + w, cy), (0, 255, 255), 2) ReleaseKey(DOWN) if cx < 175 + 31 and cx > 175 - 31: if tInitial - tUP < delay: continue tUP = time.time() PressKey(UP) cv2.line(screen, (x, cy), (x + w, cy), (0, 255, 255), 2) ReleaseKey(UP) if cx < 240 + 31 and cx > 240 - 31: if tInitial - tRIGHT < delay: continue tRIGHT = time.time() PressKey(RIGHT) cv2.line(screen, (x, cy), (x + w, cy), (0, 255, 255), 2) ReleaseKey(RIGHT) ############### ##Scren Stuff## ############### if screenOn: cv2.imshow('temp', screen) if len(video) > 5000: #clear buffer if contents are too large video = [] video.append(cv2.cvtColor(screen, cv2.COLOR_RGB2GRAY)) #save some space key = cv2.waitKey(1) if key & 0xFF == ord('p'): print 'paused' while True: key = cv2.waitKey(0) if key & 0xFF == ord('r'): print 'resume' break if key & 0xFF == ord('v'): VideoPlayer(video) tFinal = time.time() ##prints fps every 20 cycles if count == 20: print '[average fps]', 1 / (avgFPS / 20) count = 0 avgFPS = 0 count += 1 avgFPS += tFinal - tInitial
def right(): PressKey(W) PressKey(D) ReleaseKey(A) time.sleep(t_time) ReleaseKey(D)
def left(): PressKey(A) PressKey(W) ReleaseKey(D) time.sleep(t_time) ReleaseKey(A)
'RGB') # Capture part of screen img_np = np.array(img) # Convert the pic to array pixel = img_np[ 35, 455] # Get Pixel RGB Value in this case pixel at (x,y) ==> (35,455) except: print("ERROR CANNOT CAPTURE") print("RETRYING") if pixel[0] >= 210 and pixel[1] >= 210 and pixel[2] >= 212 and pixel[ 2] < 235: # Checks for white color at that pixel. If found that means fish catch. fishfound = True fishcatched = fishcatched + 1 PressKey(K) # Press key K to reel in fish time.sleep(0.1) ReleaseKey(K) # winsound.Beep(frequency, duration + 1000) time.sleep(9.9 + 1.5) # Wait for reeling in fish. # Move from right to left and vise versa after every 3 fish catched #######################################AFK KILLER ################################## if fishcatched == 3 and rhs is True: fishcatched = 0 PressKey(S) time.sleep(2.5) ReleaseKey(S)
def game_reset(self): mouse = Controller() # Exiting Game for i in list(range(4))[::-1]: print(i+1) time.sleep(1) try: WindowCapture('League of Legends (TM) Client') PressKey(ESC) ReleaseKey(ESC) time.sleep(1) mouse.position = (606, 841) mouse.click(Button.left, 2) time.sleep(1) mouse.position = (842, 537) mouse.click(Button.left, 1) time.sleep(1) time.sleep(20) except: None full_check = True while full_check: subprocess.call("taskkill /f /im \"LeagueClient.exe\"", shell=True) time.sleep(5) client_check = True while client_check: try: WindowCapture('League of Legends') client_check = False except: mouse.position = (21, 1062) time.sleep(0.01) mouse.click(Button.left, 1) mouse.position = (385, 643) time.sleep(1) mouse.click(Button.left, 1) mouse.scroll(0,-100) time.sleep(1.5) mouse.position = (319, 832) time.sleep(0.01) mouse.click(Button.left, 1) time.sleep(8) check = True while check: try: WindowCapture('League of Legends') check = False except: None time.sleep(25) check = True while check: try: WindowCapture('League of Legends (TM) Client') subprocess.call("taskkill /f /im \"League of Legends.exe\"", shell=True) check = False full_check = True except: full_check = False check = False mouse.position = (549, 269) time.sleep(0.01) mouse.click(Button.left, 1) time.sleep(1) mouse.position = (773, 310) time.sleep(0.01) mouse.click(Button.left, 1) time.sleep(1) mouse.position = (898, 721) mouse.click(Button.left, 1) time.sleep(1) mouse.position = (872, 778) time.sleep(0.01) mouse.click(Button.left, 1) time.sleep(1) # Adding Ally Bots mouse.position = (810, 460) time.sleep(0.01) mouse.click(Button.left, 1) time.sleep(1) mouse.position = (809, 499) time.sleep(0.01) mouse.click(Button.left, 1) time.sleep(1) mouse.position = (814, 546) time.sleep(0.01) mouse.click(Button.left, 1) time.sleep(1) mouse.position = (805, 579) time.sleep(0.01) mouse.click(Button.left, 1) time.sleep(1) # Adding Enemy Bots mouse.position = (1205, 425) time.sleep(0.01) mouse.click(Button.left, 1) time.sleep(1) mouse.position = (1200, 463) time.sleep(0.01) mouse.click(Button.left, 1) time.sleep(1) mouse.position = (1201, 501) time.sleep(0.01) mouse.click(Button.left, 1) time.sleep(1) mouse.position = (1196, 540) time.sleep(0.01) mouse.click(Button.left, 1) time.sleep(1) mouse.position = (1198, 579) time.sleep(0.01) mouse.click(Button.left, 1) time.sleep(1) # Awaiting Game Start mouse.position = (874, 776) mouse.click(Button.left, 1) time.sleep(3) # Champion select mouse.position = (837, 363) mouse.click(Button.left, 1) time.sleep(1) mouse.position = (964, 719) mouse.click(Button.left, 1) time.sleep(40) # Getting start items mouse.position = (964, 719) mouse.click(Button.left, 1) time.sleep(2) mouse.position = (837, 363) mouse.click(Button.left, 1) time.sleep(2) mouse.position = (768, 282) mouse.click(Button.left, 2) time.sleep(1) mouse.position = (526, 247) mouse.click(Button.left, 1) mouse.click(Button.right, 1) time.sleep(1) mouse.position = (580, 247) mouse.click(Button.left, 1) mouse.click(Button.right, 1) time.sleep(1) mouse.click(Button.right, 1) time.sleep(1) mouse.position = (626, 247) mouse.click(Button.left, 1) mouse.click(Button.right, 1) time.sleep(1) PressKey(ESC) ReleaseKey(ESC) time.sleep(1) PressKey(Y) ReleaseKey(Y) time.sleep(1) print('Done!')