def run(self, win): """ Run the main loop """ while win.thread_running: # while the program is running time.sleep(self.DelayBox.value()) # wait if self.running: # if the clicker is on if self.output_selection == 'Keyboard': keyboard.send( self.text) # try to send the text in PressText elif self.output_selection == 'String': keyboard.write(self.text) # write out the text literally elif self.output_selection == 'Left Click': mouse.click() # click with the mouse elif self.output_selection == 'Right Click': mouse.right_click() # right click with the mouse elif self.output_selection == 'Middle Click': mouse.click(mouse.MIDDLE) # middle click elif self.output_selection == 'Mouse4': mouse.click(mouse.X) # press mouse4 elif self.output_selection == 'Mouse5': mouse.click(mouse.X2) # press mouse5 if not self.repeat_forever: # if it is not an infinite clicking loop self.count += 1 # increment count if self.count >= self.repetitions: # if the count is higher than max count self.count = 0 # reset count self.toggle_signal.emit( ) # emit signal causing self.running to toggle
def goto_enemy_base(cooldown): ''' Goto enemy base ''' if not cooldown.is_available('goto_enemy_base'): return print('moving to enemy base') mouse.move(*humanize((988, 605))) mouse.right_click() cooldown.start_timer('goto_enemy_base')
def poke(areas, object_, attack_speed): ''' Orb walk from a coordinate ''' keyboard.press('`') mouse.move(*object_['center']) mouse.right_click() time.sleep(.7 / attack_speed) evade_relative(CENTER, areas) keyboard.release('`') time.sleep(.3 / attack_speed)
def orb_walk(areas, object_, attack_speed): ''' Orb walk from a coordinate ''' keyboard.press('`') mouse.move(*object_['center']) mouse.right_click() time.sleep(.5 / attack_speed) move_forward_relative(object_['center'], areas, size=100) keyboard.release('`') time.sleep(.3 / attack_speed)
def kite(areas, object_, attack_speed): ''' Kite from a coordinate ''' keyboard.press('`') mouse.move(*object_['center']) mouse.right_click() time.sleep(.5 / attack_speed) evade_relative(object_['center'], areas) keyboard.release('`') time.sleep(.3 / attack_speed)
def goto_lane(cooldown, lane='bot'): ''' Goto a lane ''' if not cooldown.is_available('goto_lane'): return if lane == 'mid': mouse.move(*humanize((931, 663))) else: mouse.move(*humanize((993, 730))) mouse.right_click() cooldown.start_timer('goto_lane')
def buy_item(item): ''' Buys item ''' if isinstance(item, str): keyboard.press_and_release('ctrl+enter') time.sleep(1) keyboard.write(item) time.sleep(1) keyboard.press_and_release('enter') time.sleep(1) keyboard.press_and_release('enter') else: mouse.move(*ITEMS[item]) mouse.right_click() time.sleep(1)
def base(coor): ''' Moves to basing position ''' distances = [distance(coor[::-1], i) for i in BASING_COOR] min_distance = min(distances) if min_distance <= 5: keyboard.press_and_release('b') time.sleep(10) return True index = distances.index(min_distance) coor = get_minimap_relative(BASING_COOR[index]) mouse.move(*humanize(coor, 1)) mouse.right_click() time.sleep(1) return False
def get_data(args): """gets the key to repeat and trigger :args: argument 1 is the name of key to press and argument two is the name of the trigger :returns: key press function and trigger key """ # sys.argv[1] is the key to be repeated and # sys.argv[2] is the key that triggers it start_stop_key = 'ctrl+shift' if len(sys.argv) > 1: if sys.argv[1] == '-l': press = lambda: mouse.click() print(Fore.CYAN + "left click" + Fore.RESET + " selected") elif sys.argv[1] == '-r': press = lambda: mouse.right_click() print(Fore.CYAN + "right click" + Fore.RESET + " selected") else: press = lambda: keyboard.send(sys.argv[1]) print(Fore.CYAN + sys.argv[1] + Fore.RESET + " selected") if len(sys.argv) > 2: start_stop_key = sys.argv[2] else: press = lambda: mouse.click() print(Fore.CYAN + "left click" + Fore.RESET + " selected") print("Press " + Fore.CYAN + start_stop_key + Fore.RESET + " to toggle clicker") return press, start_stop_key
def test_buttons(self): mouse.press() self.assertEqual(self.flush_events(), [(DOWN, LEFT)]) mouse.release() self.assertEqual(self.flush_events(), [(UP, LEFT)]) mouse.click() self.assertEqual(self.flush_events(), [(DOWN, LEFT), (UP, LEFT)]) mouse.double_click() self.assertEqual(self.flush_events(), [(DOWN, LEFT), (UP, LEFT), (DOWN, LEFT), (UP, LEFT)]) mouse.right_click() self.assertEqual(self.flush_events(), [(DOWN, RIGHT), (UP, RIGHT)]) mouse.click(RIGHT) self.assertEqual(self.flush_events(), [(DOWN, RIGHT), (UP, RIGHT)]) mouse.press(X2) self.assertEqual(self.flush_events(), [(DOWN, X2)])
def right_click(self, where, duration): """Mouse right click. :param where: Location , image name or Pattern. :param duration: Speed of hovering from current location to target. :return: Call the right_click() method. """ return right_click(where, duration, self)
def evade_relative(coor, areas, size=150): ''' Evade forward relative to a coordinate ''' if areas.nearest_lane == 'mid': move = DOWN_LEFT if areas.nearest_lane == 'top': if areas.is_map_divide: move = DOWN_LEFT elif areas.is_order_side: move = DOWN else: move = LEFT if areas.nearest_lane == 'bot': if areas.is_map_divide: move = DOWN_LEFT elif areas.is_order_side: move = LEFT else: move = DOWN mouse.move(*humanize(move * size + coor, 5)) mouse.right_click()
def move_forward_relative(coor, areas, size=150): ''' Move forward relative to a coordinate ''' if areas.nearest_lane == 'mid': move = UP_RIGHT if areas.nearest_lane == 'top': if areas.is_map_divide: move = UP_RIGHT elif areas.is_order_side: move = UP else: move = RIGHT if areas.nearest_lane == 'bot': if areas.is_map_divide: move = UP_RIGHT elif areas.is_order_side: move = RIGHT else: move = UP mouse.move(*humanize(move * size + coor, 5)) mouse.right_click()
def pegarLoot(): mouse.right_click(546, 299) mouse.right_click(546, 255) mouse.right_click(591, 255) mouse.right_click(593, 346) mouse.right_click(637, 256) mouse.right_click(637, 298) mouse.right_click(635, 344) mouse.right_click(543, 345)
def craft(): FLAT_DMG_THRESH = 175 ENH_DMG_THRESH = 120 print('\n\nStarting crafting loop...\n\n') # Loop until we're done, each iteration is one character done = False while (not done): # Track best average damage per character best_avg_flat_dmg = 0 corr_enh_dmg = 0 # Restore character character = backrest.restore_recent(BACKUP_ALL_OVERWRITTEN_FILES) if (VERBOSE): print('Restored', character) # Create singleplayer game mouse.move(*median.get_coords('singleplayer')) mouse.click() keyboard.send('enter') if (VERBOSE): print('Entering new game...') median.wait_enter_game() if (VERBOSE): print('Entered game') # Open inventory keyboard.send('i') time.sleep(.1) # Loop through each shrine shrine_size = 1, 2 # width, height for i, coords in enumerate(median.inv_iter(*shrine_size)): if done: break # Skip first two "shrines", these are where the cube is if (i < 2): continue # Place shrine into cube # 1) Grab shrine mouse.move(*coords) mouse.click() sleep_ms(50) # 2) Place in cube mouse.move(*median.get_coords('cube')) sleep_ms(50) mouse.click() sleep_ms(50) # 3) Open cube only if first shrine if (i == 2): mouse.right_click() sleep_ms(50) # Loop through a shrine's 10 charges for charge in range(10): # Ensure that if the window loses focus, loop exits if (not util.check_active_window()): print('Game window lost focus, exiting crafting loop.') done = True break # Transmute mouse.move(*median.get_coords('transmute')) sleep_ms(10) mouse.click() sleep_ms(10) # Mouseover item mouse.move(*median.get_coords('cubetopleft')) sleep_ms(100) # Get text item_stats = median.get_item_text() enh_dmg = item_parser.get_enhanced_damage(item_stats) avg_flat_dmg = item_parser.get_flat_damage(item_stats) if (avg_flat_dmg > best_avg_flat_dmg): best_avg_flat_dmg = avg_flat_dmg corr_enh_dmg = enh_dmg # log_string = '=========================\n\n' + item_stats + '\n' # util.log(log_string, 'item_log.txt') sleep_ms(100) # Check if we are done if ( (enh_dmg >= ENH_DMG_THRESH) and (avg_flat_dmg >= FLAT_DMG_THRESH) ): done = True break # End of shrine charges loop # For testing, break early # if (i == 3): break # End of shrines loop # Print out best average damage for this character print('Finished this character') print(' best average flat damage: ', best_avg_flat_dmg, sep='') print(' corresponding enh damage: ', corr_enh_dmg, '%', sep='') print() # Exit game if (not done): keyboard.send('esc') sleep_ms(150) keyboard.send('esc') mouse.move(*median.get_coords('exit')) if (VERBOSE): print('Exiting game...') mouse.click() sleep_ms(100) median.wait_exit_game() if (VERBOSE): print('Exited game...') sleep_ms(100) # Ensure that if the window loses focus, loop exits if (not util.check_active_window()): print('Game window lost focus, exiting crafting loop.') break # End of while loop ## # Print out stats print('Best average flat damage:', best_avg_flat_dmg) return 'Completed crafting'
def open_cube(): mouse.move(*median.get_coords('cube')) sleep_ms(50) mouse.right_click() sleep_ms(50)
def right_click(transcript): mouse.right_click()
if msg[0][0][1] == q: keyboard.send('q') if msg[0][0][1] == w: keyboard.send('w') if msg[0][0][1] == e: keyboard.send('e') if msg[0][0][1] == r: keyboard.send('r') if msg[0][0][1] == d: keyboard.send('d') if msg[0][0][1] == f: keyboard.send('f') if msg[0][0][1] == leftclick: mouse.click(button='left') if msg[0][0][1] == rightclick: mouse.right_click() if msg[0][0][1] == mouseup: mouse.move(0, -sensitivity, absolute=False) if msg[0][0][1] == mousedown: mouse.move(0, sensitivity, absolute=False) if msg[0][0][1] == mouseright: mouse.move(sensitivity, 0, absolute=False) if msg[0][0][1] == mouseleft: mouse.move(-sensitivity, 0, absolute=False) print(msg) except KeyboardInterrupt: break pygame.midi.quit() print("Bye!!") try:
print("\nStarting script in " + str(startwait) + " seconds...\nPress CTRL+C in this window at any moment to Exit.") time.sleep(startwait) print("\nScript in progress...") if (usedoptions != int(1)): print("NOTE: You started the script with default settings.\nStart it with flag -h to see all the available options.") while (loopgen < maxblocks): lavasleep = float(loopweight * 0.05) # At every cycle sets the wait time for Lava. if (lavabtnis == "lmouse"): # Select Lava mouse.click(button='left') # elif (lavabtnis == "rmouse"): # mouse.right_click() # else: # keyboard.send(lavabtn) # if (clickbtnis == "lmouse"): # Place Lava mouse.click(button='left') # elif (clickbtnis == "rmouse"): # mouse.right_click() # else: # keyboard.send(clickbtn) # time.sleep(90 * 0.05) # Wait for Lava to start flowing if (clickbtnis == "lmouse"): # Unplace Lava mouse.click(button='left') # elif (clickbtnis == "rmouse"): #