def delete_events( self, frequency=2, repetitions=5, image_file="delete_events.png" ): ##Frequency is how many seconds to erase every time. Repetitions is how many times to erase """Constructor""" self._windowMgr.retake_screenshot() try: self._windowMgr.find_button_coordinates( os.path.join(self.image_directory, image_file)) #path to the image except IOError: logging.warning('Image file Delete Events not found. Quitting..') return if self._windowMgr._pos == None: logging.warning( 'Could not delete events. Button not found on screen') else: time.sleep(15) for i in range(repetitions): time.sleep(frequency) position = (self._windowMgr._pos[0] + 32, self._windowMgr._pos[1] + 15) #add position offset mouse.move(position[0], position[1]) time.sleep(0.1) mouse.click() time.sleep(0.4) key.tap(key.K_RETURN)
def click(self, x, y, button=LEFT_BUTTON, clicks=1, interval=0): """Perform a number of clicks after human mouse movement :param button: Mouse button to use on the click. Valid types: (1, 2, 3, 'left', 'right', 'middle') (optional, default == 1) :type button: int/str :param clicks: Number of clicks (optional, default == 1) :type clicks: int :param interval: Time for sleep between clicks (optional, default == 0) :type interval: int/float """ self.move(x, y) for c in range(clicks): click(button) if clicks > 1 and interval > 0: sleep(interval)
def run(self, sample_number=0, image_file="run_button_ready.png"): """Constructor""" self._windowMgr.retake_screenshot() try: self._windowMgr.find_button_coordinates(os.path.join(self.image_directory, image_file)) # path to the image except IOError: logging.warning("Image file Run Button not found. Quitting..") return if self._windowMgr._pos == None: logging.warning("CFlow not ready to take measurements") if not self.button_not_found(image_file): return position = (self._windowMgr._pos[0] + 73, self._windowMgr._pos[1] + 22) mouse.move(position[0], position[1]) mouse.click() self.time_counter = self.time_counter + 1 self.sample_counter = self.sample_counter + 1 self.delete_events() # delete every 2 seconds, 5 times. Delete the first 10 seconds of measurement. if self.checking_end_of_measurements() == 1: logging.info("measurement %d done", self.time_counter) self.add_sample_well_description(sample_number) self.save() else: self.pause_cytometer() self.add_sample_well_description(sample_number) self.save() logging.info( "Running cytometer measurements took too long (more 5 minutes). Measurements were paused and proceeding to next step", self.time_counter, ) return
def process_chunk(chunk, out_chunk, time_info, status): left_signal = chunk[:, 0] left_signal[left_signal == 0] = 0.00000001 max_db = np.max(np.abs(left_signal)) max_db = DB_MUL * np.log10(max_db) if max_db > 5: mouse.click() x_pct = np.interp(max_db, [SCREEN_LEFT_DB, SCREEN_RIGHT_DB], [0, 0.999999]) hz = determine_pitch(left_signal) y_pct = np.interp(hz, [SCREEN_TOP_HZ, SCREEN_BOT_HZ], [0, 0.999999]) MOUSE_TARGET[0] = int(screen_size[0] * x_pct) MOUSE_TARGET[1] = int(screen_size[1] * y_pct) c_x, c_y = mouse.get_pos() t_x, t_y = MOUSE_TARGET new_pos = np.array([ new_mouse_position(c_x, t_x, MOUSE_SPEED), new_mouse_position(c_y, t_y, MOUSE_SPEED) ]) mouse.move( max(0, min(new_pos[0], screen_size[0] - 1)), max(0, min(new_pos[1], screen_size[1] - 1)) ) out_chunk[:] = np.zeros_like(chunk) return continue_flag
def run(self, sample_number=0, image_file="run_button_ready.png"): """Constructor""" self._windowMgr.retake_screenshot() try: self._windowMgr.find_button_coordinates( os.path.join(self.image_directory, image_file)) #path to the image except IOError: logging.warning('Image file Run Button not found. Quitting..') return if self._windowMgr._pos == None: logging.warning('CFlow not ready to take measurements') if not self.button_not_found(image_file): return position = (self._windowMgr._pos[0] + 73, self._windowMgr._pos[1] + 22) mouse.move(position[0], position[1]) mouse.click() self.time_counter = self.time_counter + 1 self.sample_counter = self.sample_counter + 1 self.delete_events( ) #delete every 2 seconds, 5 times. Delete the first 10 seconds of measurement. if self.checking_end_of_measurements() == 1: logging.info('measurement %d done', self.time_counter) self.add_sample_well_description(sample_number) self.save() else: self.pause_cytometer() self.add_sample_well_description(sample_number) self.save() logging.info( 'Running cytometer measurements took too long (more 5 minutes). Measurements were paused and proceeding to next step', self.time_counter) return
def add_sample_well_description(self, sample_number=0, image_file="sample_well_description.png"): """Constructor""" self._windowMgr.retake_screenshot() try: self._windowMgr.find_button_coordinates( os.path.join(self.image_directory, image_file)) #path to the image except IOError: logging.warning( 'Image file Sample Well Description not found. Quitting..') return if self._windowMgr._pos == None: logging.warning( 'Could not add sample well description. Button not found on screen' ) if not self.button_not_found(image_file): return position = (self._windowMgr._pos[0] + 80, self._windowMgr._pos[1] + 8 ) #add position offset mouse.move(position[0], position[1]) mouse.click() time.sleep(0.5) if sample_number: sampleString = str('sample%i' % sample_number) else: sampleString = '' sample_time = datetime.datetime.now() sample_time = ''.join([ sampleString, 'time', str(sample_time.hour), 'h', str(sample_time.minute), 'm' ]) key.type_string(sample_time)
def calc_mp(): global stop while stop != 'y': with shoot_lock: # grabs blue bar hsv_img = shoot(36, 504, 135, 505, 'hsv') low = np.array([110, 100, 100]) high = np.array([130, 255, 255]) mask = cv2.inRange(hsv_img, low, high) #(conts, _) = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) #print(contours) mask = np.array(mask) percentage = 0 for color in mask: for element in color: if element == 0: break percentage += 1 if percentage < 70: mouse.move(770, 70) sleep(.01) mouse.click(1) # moves back to original location mouse.move(cx, cy) sleep(17) else: sleep(2)
def startMatch(): print("startMatch") x = width / 2 y = height - 105 # find "Ready" button mouse.smooth_move(x, y) mouse.click() time.sleep(0.5)
def startMatch(): print ("startMatch") x = width/2 y = height - 105 # find "Ready" button mouse.smooth_move(x, y) mouse.click() time.sleep(0.5)
def simkey_type_words(pos, words, interal=0.1): mouse.move(*pos) mouse.click() for word in words: time.sleep(interal) key.tap('a', key.MOD_CONTROL) time.sleep(interal) key.type_string(word) key.tap(key.K_RETURN)
def endMatch(): print ("startMatch") x = 50 y = height - 100 # find "Leave" button mouse.smooth_move(x, y) mouse.click() time.sleep(0.5) mouse.click()
def endMatch(): print("startMatch") x = 50 y = height - 100 # find "Leave" button mouse.smooth_move(x, y) mouse.click() time.sleep(0.5) mouse.click()
def redroses(): try: img = shoot(260, 270, 550, 480, "hsv") low = np.array([169, 213, 28]) high = np.array([179, 255, 140]) # black and white image of roses mask = cv2.inRange(img, low, high) kernel = np.ones((5, 5), np.uint8) closing = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel) closing_c = closing.copy() contours, _ = cv2.findContours(closing, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) all_xs = [] all_ys = [] for con in contours: for element in con: all_xs.append(element[0][0]) all_ys.append(element[0][1]) x1 = min(all_xs) y1 = min(all_ys) x2 = max(all_xs) y2 = max(all_ys) movein = 20 x1 += movein y1 += movein x2 -= movein y2 -= movein # add img taken coords x1 += 260 y1 += 270 x2 += 260 y2 += 270 # moves x and y to center of roses x1 = x1 + ((x2 - x1) / 2) y1 = y1 + ((y2 - y1) / 2) mouse.move(x1, y1) sleep(2) mouse.click(1) ############## DEBUG # # cv2.imshow('closing', closing_c) # cv2.waitKey(0) # cv2.destroyAllWindows() return True except: return False
def useTalents(): print ("useTalents") x = width/2 y = height/2 for char in ['q', 'w', 'e', 'r', 'd', '1', '2', '3', '4', '5']: mouse.smooth_move(x-randint(-300,300), y-randint(200,200)) key.tap(char) mouse.click() time.sleep(0.5) key.tap(char) mouse.click(mouse.RIGHT_BUTTON)
def useTalents(): print("useTalents") x = width / 2 y = height / 2 for char in ['q', 'w', 'e', 'r', 'd', '1', '2', '3', '4', '5']: mouse.smooth_move(x - randint(-300, 300), y - randint(200, 200)) key.tap(char) mouse.click() time.sleep(0.5) key.tap(char) mouse.click(mouse.RIGHT_BUTTON)
def double_click(self, x, y, pause=.1, **kwargs): """Perform a classic double click after human mouse movement :param pause: Time to sleep between first and second click (optional, default == .1) :type pause: int/float """ self.move(x, y) click(x, y, **kwargs) sleep(pause) click(x, y, **kwargs)
def ecl_show_view(search): """Uses a series of shortcuts to search functionality in eclipse and selects then.""" key.tap(long(ord('w')),long(key.MOD_ALT)) key.tap(long(ord('v'))) key.tap(long(ord('o'))) time.sleep(1) key.tap(long(key.K_DELETE)) key.type_string(search, 0) time.sleep(1) move_middle_bottom() mouse.click(LEFT_BUTTON) #to gain focus key.tap(long(key.K_RETURN)) time.sleep(1)
def pause_cytometer(self, image_file="pause.png"): """Constructor""" self._windowMgr.retake_screenshot() try: self._windowMgr.find_button_coordinates(os.path.join(self.image_directory, image_file)) # path to the image except IOError: logging.warning("Image file Pause not found. Quitting..") return if self._windowMgr._pos == None: logging.warning("Could not pause cytometer operation. Button not found on screen") if not self.button_not_found(image_file): return position = (self._windowMgr._pos[0] + 50, self._windowMgr._pos[1] + 10) # add position offset mouse.move(position[0], position[1]) mouse.click()
def click_and_wait(self, position=None, seconds=0, click=True, smooth=True): """Go to `position`, click and wait a number of `seconds`. Extra: only move and click if the mouse is on the right of the screen!!! """ move_func = mouse.smooth_move if smooth else mouse.move if self._is_mouse_on_the_right(): if position: move_func( position[0]+self.offset_x, position[1]+self.offset_y) if click: mouse.click() self.sleep(seconds)
async def heal_combo_sequence(self): try: i = 0 l = len(self.heal_seq) while True: if self.heal_cor: await asyncio.sleep(self.heal_seq[i][1]) cmd = self.heal_seq[i][0] if cmd == 'LMC': mouse.click() else: key.tap(cmd) i = (i + 1) % l except asyncio.CancelledError: raise
def snapdragons(): try: print('Looking to harvest') img = shoot(260, 270, 550, 480, "hsv") low = np.array([169, 213, 28]) high = np.array([179, 255, 140]) # black and white image of roses mask = cv2.inRange(img, low, high) kernel = np.ones((1, 1), np.uint8) closing = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel) #closing_c = closing.copy() contours, _ = cv2.findContours(closing.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) ############## DEBUG #cv2.imshow('closing', closing) #cv2.waitKey(0) #cv2.destroyAllWindows() ############## END DEBUG # Gathers all the biggest areas of the snaps big_areas = {} for con in (contours): if cv2.contourArea(con) > 100: M = cv2.moments(con) big_areas[cv2.contourArea(con)] = (int(M["m10"] / M["m10"]), int(M["m01"] / M["m00"])) biggest = max(big_areas.keys()) # clicks on the center of biggest area x1, y1 = big_areas[biggest] # add img taken coords x1 += 260 y1 += 270 mouse.move(x1, y1) sleep(1) mouse.click(1) return True except: return False
def click_radius(coord): coord = list(coord) x = random.randint(coord[0] + 6, coord[2] + coord[0] - 6) y = random.randint(coord[1] + 6, coord[3] + coord[1] - 6) speed = 0.5 # duration_of_move=duration # print x,y curr_x, curr_y = pyautogui.position() # calculates the distance from current position to target position distance = int(((x - curr_x)**2 + (y - curr_y)**2)**speed) # calculates a random time to make the move take based on the distance duration_of_move = (distance * random.random() / 2000) + speed # move the mouse to our position and takes the time of our duration just # calculated pyautogui.moveTo(x, y, duration_of_move, pyautogui.easeInOutQuad) click()
def move_mouse_to_click(x, y): # takes current mouse location and stores it while (True): try: curr_x, curr_y = pyautogui.position() # calculates the distance from current position to target position distance = int(((x - curr_x)**2 + (y - curr_y)**2)**0.5) # calculates a random time to make the move take based on the distance duration_of_move = (distance * random.random() / 2000) + 0.5 # move the mouse to our position and takes the time of our duration just # calculated pyautogui.moveTo(x, y, duration_of_move, pyautogui.easeInOutQuad) click() #pyautogui.moveTo(x, y, duration_of_move, pyautogui.easeOutElastic) break except: print('paused for 10 seconds') time.sleep(10)
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 match_(template): res = cv2.matchTemplate(im, template, cv2.TM_CCOEFF_NORMED) threshold = .8 loc = np.where(res >= threshold) for pt in zip(*loc[::-1]): x,y = pt x += ox y += oy # clicks on use button mouse.move(109,526) sleep(.07) mouse.click(1) mouse.move(x,y) for _ in xrange(5): sleep(random()) mouse.click(1) return True return False
def pause_cytometer(self, image_file="pause.png"): """Constructor""" self._windowMgr.retake_screenshot() try: self._windowMgr.find_button_coordinates( os.path.join(self.image_directory, image_file)) #path to the image except IOError: logging.warning('Image file Pause not found. Quitting..') return if self._windowMgr._pos == None: logging.warning( 'Could not pause cytometer operation. Button not found on screen' ) if not self.button_not_found(image_file): return position = (self._windowMgr._pos[0] + 50, self._windowMgr._pos[1] + 10 ) #add position offset mouse.move(position[0], position[1]) mouse.click()
def do_simulation(my_images): can_find = False my_index = -1 for my_image in my_images: my_index += 1 my_rect = find_image_location_in_screen(my_image) if my_rect: can_find = True print(my_images_name_list[my_index] + ' at rect: ' + str(my_rect)) sleep_random_time(min_time=my_delay_move_min,max_time=my_delay_move_max) mouse.smooth_move(my_rect[0],my_rect[1]) print('Click') sleep_random_time(min_time=my_delay_click_min,max_time=my_delay_click_max) mouse.click() print('Move to 0,0') sleep_random_time(min_time=my_delay_click_min,max_time=my_delay_click_max) mouse.smooth_move(0,0) break if can_find is False: print('Not found.')
def backflush(self, image_file="backflush.png"): """Constructor""" self._windowMgr.retake_screenshot() try: self._windowMgr.find_button_coordinates(os.path.join(self.image_directory, image_file)) # path to the image except IOError: logging.warning("Image file Backflush not found. Proceeding to next step..") return if self._windowMgr._pos == None: logging.warning("Not ready to backflush") if not self.button_not_found(image_file): return position = (self._windowMgr._pos[0] + 32, self._windowMgr._pos[1] + 24) # add position offset mouse.move(position[0], position[1]) mouse.click() if self.checking_end_of_measurements() == 1: return else: logging.warning("backflushing took too long. Moving on..") return
def match_(template): res = cv2.matchTemplate(im, template, cv2.TM_CCOEFF_NORMED) threshold = .8 loc = np.where(res >= threshold) for pt in zip(*loc[::-1]): x, y = pt x += ox y += oy # clicks on use button mouse.move(109, 526) sleep(.07) mouse.click(1) mouse.move(x, y) for _ in xrange(5): sleep(random()) mouse.click(1) return True return False
def executeMove(startX, startY, moveSequence): print(moveSequence) sx = x + startX * tileWidth + tileWidth/4 sy = y + startY * tileHeight + tileHeight/4 mouse.move(sx, sy) mouse.click() mouse.toggle(True) for i in range(len(moveSequence)): if(moveSequence[i] == 'l'): sx = sx - tileWidth if(moveSequence[i] == 'r'): sx = sx + tileWidth if(moveSequence[i] == 'u'): sy = sy - tileHeight if(moveSequence[i] == 'd'): sy = sy + tileHeight mouse.smooth_move(sx, sy) mouse.toggle(False)
def readGame(self): bmp = bitmap.capture_screen() submitPt = bmp.find_bitmap(self.submitImg) replayPt = bmp.find_bitmap(self.replayImg) if submitPt != None or replayPt != None: if submitPt != None: print 'submit found!' mouse.move(submitPt[0], submitPt[1]) mouse.click() time.sleep(10) self.replayGame() return self.gameState for y in range(self.gameState.boardDim.y): for x in range(self.gameState.boardDim.x): gem = self.getGem(bmp, Point(x, y)) self.gameState.board.board[y][x] = gem return self.gameState
def sample(self, image_file="sample_button2.png"): # self._windowMgr.maximize_window() """Constructor""" self._windowMgr.retake_screenshot() try: self._windowMgr.find_button_coordinates(os.path.join(self.image_directory, image_file)) # path to the image except IOError: logging.warning("Image file Sample Button not found. Proceeding to next step..") return if self._windowMgr._pos == None: logging.warning("CFlow not open, no button positions available") if not self.button_not_found(image_file): return x_offset = (self.sample_counter % 12) * 24 y_offset = (self.sample_counter / 12) * 24 position = ( self._windowMgr._pos[0] + x_offset + 36, self._windowMgr._pos[1] + y_offset + 8, ) # position changed to bring to center of button mouse.move(position[0], position[1]) mouse.click()
def click_ad(pos): delta = 100 mouse.smooth_move(pos[0] + delta, pos[1] + delta) mouse.click() mouse.smooth_move(pos[0], 0) # move mouse away #"find the спечели билет button" pos = None while True: time.sleep(1) # wait for the ads page to load 1s pos = findBitmapOnScreen('yatoto_specheli.png') if pos: break mouse.smooth_move(pos[0] + 10, pos[1] + 10) mouse.click() mouse.smooth_move(pos[0], 0) # move mouse away pos = None #"wait 2 seconds and look for вземи билета. if absent repeat" while True: time.sleep(2) # wait for the ads page to load 6s pos = findBitmapOnScreen('yatoto_specheli.png') if pos: break mouse.smooth_move(pos[0] + 10, pos[1] + 10) mouse.click() mouse.smooth_move(pos[0], 0) # move mouse away #"close the current tab with ctrl+W" time.sleep(2) key.tap('w', key.MOD_CONTROL) time.sleep(2)
def delete_events( self, frequency=2, repetitions=5, image_file="delete_events.png" ): ##Frequency is how many seconds to erase every time. Repetitions is how many times to erase """Constructor""" self._windowMgr.retake_screenshot() try: self._windowMgr.find_button_coordinates(os.path.join(self.image_directory, image_file)) # path to the image except IOError: logging.warning("Image file Delete Events not found. Quitting..") return if self._windowMgr._pos == None: logging.warning("Could not delete events. Button not found on screen") else: time.sleep(15) for i in range(repetitions): time.sleep(frequency) position = (self._windowMgr._pos[0] + 32, self._windowMgr._pos[1] + 15) # add position offset mouse.move(position[0], position[1]) time.sleep(0.1) mouse.click() time.sleep(0.4) key.tap(key.K_RETURN)
def make_avalanche(): ct = 0 relogin = False while True: # if not relogin and datetime.now().hour == 5 and datetime.now().minute > 25: # print('\n\n--------------\nRELOGIN\n\n\n') # login() # relogin = True ct += 1 print(f'Round {ct}:') for i in range(4): print('Eating mushroom') key.tap(key.Code.F2) time.sleep(random.random() / 2) for i in range(7): if ct == 1: continue print('Making avalanche') key.tap(key.Code.F1) time.sleep(3 + random.random()) print('...') key.tap(key.Code.F3) time.sleep(5) print('Using Dummy...') key.tap(key.Code.F4) time.sleep(1) mouse.smooth_move(870.0, 61.0) mouse.click() time.sleep(1) mouse.smooth_move(random.random() * 1000, random.random() * 1000) wait_time = 10 * 60 / 2 # wait_time = wait_time print(f'Waiting {wait_time} seconds') time.sleep(wait_time)
def add_sample_well_description(self, sample_number=0, image_file="sample_well_description.png"): """Constructor""" self._windowMgr.retake_screenshot() try: self._windowMgr.find_button_coordinates(os.path.join(self.image_directory, image_file)) # path to the image except IOError: logging.warning("Image file Sample Well Description not found. Quitting..") return if self._windowMgr._pos == None: logging.warning("Could not add sample well description. Button not found on screen") if not self.button_not_found(image_file): return position = (self._windowMgr._pos[0] + 80, self._windowMgr._pos[1] + 8) # add position offset mouse.move(position[0], position[1]) mouse.click() time.sleep(0.5) if sample_number: sampleString = str("sample%i" % sample_number) else: sampleString = "" sample_time = datetime.datetime.now() sample_time = "".join([sampleString, "time", str(sample_time.hour), "h", str(sample_time.minute), "m"]) key.type_string(sample_time)
def backflush(self, image_file="backflush.png"): """Constructor""" self._windowMgr.retake_screenshot() try: self._windowMgr.find_button_coordinates( os.path.join(self.image_directory, image_file)) #path to the image except IOError: logging.warning( 'Image file Backflush not found. Proceeding to next step..') return if self._windowMgr._pos == None: logging.warning('Not ready to backflush') if not self.button_not_found(image_file): return position = (self._windowMgr._pos[0] + 32, self._windowMgr._pos[1] + 24 ) #add position offset mouse.move(position[0], position[1]) mouse.click() if self.checking_end_of_measurements() == 1: return else: logging.warning('backflushing took too long. Moving on..') return
def sample(self, image_file="sample_button2.png"): #self._windowMgr.maximize_window() """Constructor""" self._windowMgr.retake_screenshot() try: self._windowMgr.find_button_coordinates( os.path.join(self.image_directory, image_file)) #path to the image except IOError: logging.warning( 'Image file Sample Button not found. Proceeding to next step..' ) return if self._windowMgr._pos == None: logging.warning('CFlow not open, no button positions available') if not self.button_not_found(image_file): return x_offset = (self.sample_counter % 12) * 24 y_offset = (self.sample_counter / 12) * 24 position = (self._windowMgr._pos[0] + x_offset + 36, self._windowMgr._pos[1] + y_offset + 8 ) #position changed to bring to center of button mouse.move(position[0], position[1]) mouse.click()
def chooseDifficulty(difficulty): """Moves the cursor to the difficulty button specified by the parameter""" width, heigth = screen.get_size() if heigth == 1080: if difficulty == 'novice': mouse.smooth_move(1300,710) time.sleep(10) mouse.click(mouse.LEFT_BUTTON) else: mouse.smooth_move(1300,810) time.sleep(10) mouse.click(mouse.LEFT_BUTTON) elif heigth == 768: if difficulty == 'novice': mouse.smooth_move(1000,630) time.sleep(10) mouse.click(mouse.LEFT_BUTTON) else: mouse.smooth_move(1000,680) time.sleep(10) mouse.click(mouse.LEFT_BUTTON)
def replayGame(self): print 'replay!!!' replayPt = None time.sleep(5) while replayPt == None: bmp = bitmap.capture_screen() replayPt = bmp.find_bitmap(self.replayImg) mouse.move(replayPt[0], replayPt[1]) mouse.click() time.sleep(60) mouse.move(self.gameOffset.x + GAME_SIZE.x / 2, self.gameOffset.y + GAME_SIZE.y / 2) mouse.click() time.sleep(2) mouse.move(self.gameOffset.x + 100, self.gameOffset.y + 100) mouse.click()
def click_ad(pos): delta = 100 mouse.smooth_move(pos[0]+delta, pos[1]+delta) mouse.click() mouse.smooth_move(pos[0], 0) # move mouse away #"find the спечели билет button" pos = None while True: time.sleep(1) # wait for the ads page to load 1s pos = findBitmapOnScreen('yatoto_specheli.png') if pos: break mouse.smooth_move(pos[0]+10, pos[1]+10) mouse.click() mouse.smooth_move(pos[0], 0) # move mouse away pos = None #"wait 2 seconds and look for вземи билета. if absent repeat" while True: time.sleep(2) # wait for the ads page to load 6s pos = findBitmapOnScreen('yatoto_specheli.png') if pos: break mouse.smooth_move(pos[0]+10, pos[1]+10) mouse.click() mouse.smooth_move(pos[0], 0) # move mouse away #"close the current tab with ctrl+W" time.sleep(2) key.tap('w', key.MOD_CONTROL) time.sleep(2)
def itmlst_toggle(): mouse.move(290,198) mouse.click(1)
def leftClick(): mouse.click() return
def double_click_qq_input_text_box(self): mouse.move(self.screen_size[0] / 2, self.screen_size[1] / 2 + 49) mouse.click()
x, y = mouse.location() acc = map(float, ser.readline().split(',')) print(str(x + acc[0]) + " " + str(y + acc[1])) t = x + acc[0] e = y - acc[1] if t >= 1366: t = 1360 elif t <= 0: t = 5 if e >= 766: e = 760 elif e <= 0: e = 5 mouse.move(t, e) if acc[3] == 1: mouse.click(RIGHT_BUTTON) if acc[4] == 1: mouse.click() except: continue #pp[0] = (ser.readline().split()) #print pp #print(accelerometerReading) #x=accelerometerReading.rfind #print(x) #t=acceloremeterReading[x+1:] #y=int(t) #print(accelerometerReading)
def act(guess): """moves the cursor to the appropriate area of the screen""" width, heigth = screen.get_size() if heigth == 1080: if guess == 'r': mouse.smooth_move(660,580) mouse.click(mouse.LEFT_BUTTON) elif guess == 'p': mouse.smooth_move(740,580) mouse.click(mouse.LEFT_BUTTON) elif guess == 's': mouse.smooth_move(560,580) mouse.click(mouse.LEFT_BUTTON) elif heigth == 768: if guess == 'r': mouse.smooth_move(350,480) mouse.click(mouse.LEFT_BUTTON) elif guess == 'p': mouse.smooth_move(500,480) mouse.click(mouse.LEFT_BUTTON) elif guess == 's': mouse.smooth_move(220,480) mouse.click(mouse.LEFT_BUTTON)
def double_click_passwd_input_text_box(self): mouse.move(self.screen_size[0] / 2, self.screen_size[1] / 2 + 76) mouse.click()
def _double_click(self): mouse.click() mouse.click()
def openURL(): """opens website automatically if the resolution of the screen is usual ( HD or FHD ), else asks the user to open it manually""" width, heigth = screen.get_size() if heigth == 1080: mouse.smooth_move(200, 60) mouse.click(mouse.LEFT_BUTTON) mouse.click(mouse.LEFT_BUTTON) mouse.click(mouse.LEFT_BUTTON) elif heigth == 768: mouse.smooth_move(200, 60) mouse.click(mouse.LEFT_BUTTON) mouse.click(mouse.LEFT_BUTTON) mouse.click(mouse.LEFT_BUTTON) else: print 'Please open http://www.nytimes.com/interactive/science/rock-paper-scissors.html then type OK' if 'ok'.lower() == raw_input(): print 'TY' time.sleep(1) speed = 0 key.type_string('http',speed) key.tap('.', key.MOD_SHIFT) key.tap('6', key.MOD_SHIFT) key.tap('6', key.MOD_SHIFT) key.type_string('www.nytimes.com',speed) key.tap('6', key.MOD_SHIFT) key.type_string('interactive',speed) key.tap('6', key.MOD_SHIFT) key.type_string('science',speed) key.tap('6', key.MOD_SHIFT) key.type_string('rock-paper-scissors.html',speed) key.tap('6', key.MOD_SHIFT) key.tap(key.K_RETURN)
def attack(): #swing mouse.click() time.sleep(0.3)
def moveclick(xpos, ypos): mouse.move(xpos, ypos) time.sleep(0.05) mouse.click()
def click(self, point): grid_x = self.offset_x + self.grid_length * (point[1] + 0.5) grid_y = self.offset_y + self.grid_length * (point[0] + 0.5) mouse.move(int(grid_x), int(grid_y)) mouse.click()
def _set_focus_from_taskbar_coords(self): x, y = self._taskbar_coords mouse.move(x, y) mouse.click() sleep(1)
#eof click_ad #"presume the yatoto site is open" autopy.alert.alert("open www.yatoto.com to start") first_row_ads_clicked = 0 done = False #"-main loop-" while not done: #find the search area and click a little to the left pos = findBitmapOnScreen('yatoto_search.png') mouse.smooth_move(pos[0]-350, pos[1]+0) mouse.click() time.sleep(12) # wait for the ads page to load 30s #scroll down one row tap_count_to_scroll_one_row = 10 for i in range(tap_count_to_scroll_one_row): key.tap(key.K_DOWN) time.sleep(0.1) coords = findBitmapOnScreen('yatoto_done.png') if coords != None: done = True coords = findBitmapOnScreen('yatoto_ad_corner.png') if coords != None:
def click(cord): mouse.move(x_pad+cord[0], y_pad+cord[1]) mouse.click() time.sleep(0.1)
minIndex[0] = indices[0] if indices[1] < minIndex[1]: minIndex[1] = indices[1] if indices[0] > maxIndex[0]: maxIndex[0] = indices[0] if indices[1] > maxIndex[1]: maxIndex[1] = indices[1] # im.save("test_%i_%i.png"%(x,y)) fullArray[indices[0],indices[1]] = arrayNumbers.index(ar) - 1 print indices, arrayNumbers.index(ar) - 1 # imagehash.average_hash(meinsweeper) print minIndex, maxIndex usefulArray = fullArray[minIndex[0]:maxIndex[0],minIndex[1]:maxIndex[1]] print usefulArray.shape for x in range(1, usefulArray.shape[0]-1): for y in range(1, usefulArray.shape[1]-1): mn = mineSweepNine(usefulArray[x-1:x+2,y-1:y+2]) if mn.leftClick or mn.rightClick: changedSomething = True p = [offset[0] + (minIndex[0]+x)*tileSize, offset[1] + (minIndex[1]+y)*tileSize] print mn.array ms.smooth_move(p[0]/2+tileInterior/2,p[1]/2+tileInterior/2) if mn.leftClick: ms.click(ms.LEFT_BUTTON) ms.click(ms.LEFT_BUTTON) else: ms.click(ms.RIGHT_BUTTON) time.sleep(0.5)