def paste_cmd_current(one_cmd): try: setText(one_cmd) key.toggle(key.K_CONTROL,True) key.tap("v") key.toggle(key.K_CONTROL,False) return True except Exception: return False
def enterCode(): click(int(.3806734992*GetSystemMetrics (0)),int(.85286458333*GetSystemMetrics (1))) time.sleep(1) key.toggle( key.K_CONTROL, True) time.sleep(.1) key.tap( 'v' ) key.toggle( key.K_CONTROL, False) time.sleep(1) click(int(.68008784773*GetSystemMetrics (0)),int(.571614583*GetSystemMetrics (1)))
def goFight(): print ("goFight") ###move back and forth # x = width/2 # y = height/2 # mouse.smooth_move(x-randint(100,300)*direction, y-randint(0,100)) #ahead # mouse.click(mouse.RIGHT_BUTTON) # time.sleep(5) # mouse.smooth_move(x+randint(50,100)*direction, y-randint(0,100)) # back # mouse.click(mouse.RIGHT_BUTTON) ###use mini map x = width-((230+250)/2) # mid btw all maps and HM y = height+50-((155+235)/2) # mid btw all maps and HM #unmount key.tap('z') direction = 1 for i in range(3): chooseTalent() direction = direction * (-1) # toggle directions x1 = x - 70 * direction y1 = y - randint(-10,10) # surely within maps #y = y - randint(0,1)*(235-155) # haunted mines offset mouse.smooth_move(x1, y1) # pos on minimap #ALT callout key.toggle(key.K_ALT, True) mouse.click() key.toggle(key.K_ALT, False) #mount key.tap('z') time.sleep(1.5) key.tap('a') # attack move mouse.click() time.sleep(18) # time to cross half the map useTalents()
def goFight(): print("goFight") ###move back and forth # x = width/2 # y = height/2 # mouse.smooth_move(x-randint(100,300)*direction, y-randint(0,100)) #ahead # mouse.click(mouse.RIGHT_BUTTON) # time.sleep(5) # mouse.smooth_move(x+randint(50,100)*direction, y-randint(0,100)) # back # mouse.click(mouse.RIGHT_BUTTON) ###use mini map x = width - ((230 + 250) / 2) # mid btw all maps and HM y = height + 50 - ((155 + 235) / 2) # mid btw all maps and HM #unmount key.tap('z') direction = 1 for i in range(3): chooseTalent() direction = direction * (-1) # toggle directions x1 = x - 70 * direction y1 = y - randint(-10, 10) # surely within maps #y = y - randint(0,1)*(235-155) # haunted mines offset mouse.smooth_move(x1, y1) # pos on minimap #ALT callout key.toggle(key.K_ALT, True) mouse.click() key.toggle(key.K_ALT, False) #mount key.tap('z') time.sleep(1.5) key.tap('a') # attack move mouse.click() time.sleep(18) # time to cross half the map useTalents()
def toggle_key(self, key_id, state, player): try: key.toggle(libi2dx.config.get('keymap_player%s' % player, key_id), state) except ConfigParser.NoOptionError: print "key map not found for %s, player %s" % (key_id, player)
def dataReceived(self, data): #print "datareceived", data while data: try: decode, index = json_decode(data) except ValueError: # something went wrong.. FIXME return data = data[index:] if not isinstance(decode, dict): # something went wrong, gtfo for now, FIXME return command = decode.get('command') if command == 'mouse': pos = mouse.get_pos() action = decode.get('action') if action == 'click': for i in range(decode.get('n') or 1): mouse.click(BUTTONS[decode.get('b') - 1]) elif action == 'move': try: mouse.move(pos[0] + decode.get('dx'), pos[1] + decode.get('dy')) except ValueError: pass elif action == 'press': mouse.toggle(True, BUTTONS[decode.get('b') - 1]) elif action == 'release': mouse.toggle(False, BUTTONS[decode.get('b') - 1]) elif command == 'type': key.type_string(decode['string']) elif command == 'press_key': key.toggle(getattr(key, 'K_' + decode['key'].upper()), True) elif command == 'release_key': key.toggle(getattr(key, 'K_' + decode['key'].upper()), False) elif command == 'kill': self.kill_app(decode['uid']) elif command == 'capture': pos = mouse.get_pos() size = decode.get('size') maxx, maxy = screen.get_size() rect = (( max(0, min((pos[0] - size[0] / 2), maxx - size[0])), max(0, min((pos[1] - size[1] / 2), maxy - size[1])) ), (size[0], size[1])) try: bitmap.capture_screen(rect).save('tmp.png') except ValueError: return self.send(mouse_pos=(pos[0] - rect[0][0], pos[1] - rect[0][1])) #print "sending capture" self.send_image('tmp.png') elif decode.get('run') in zip(*self.commands)[0]: self.execute(decode.get('run'), decode.get('arguments'))
def on_release(self, key, modifiers=None, msg=None): key = self._get_key(key) modifiers = self._get_modifiers(modifiers) K.toggle(key, False, modifiers)
def on_press(self, key, modifiers=None, msg=None): key = self._get_key(key) modifiers = self._get_modifiers(modifiers) K.toggle(key, True, modifiers)
def _press_keys(cls, keys): map(lambda key: toggle(key, True), keys) map(lambda key: toggle(key, False), keys)