Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 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
Esempio n. 4
0
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)
Esempio n. 5
0
 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
Esempio n. 6
0
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
Esempio n. 7
0
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)
Esempio n. 8
0
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
Esempio n. 9
0
 def move(self, x, y):
     """Human mouse movement """
     startCoords = get_pos()
     coordsAndDelay = self._calcCoordsAndDelay(startCoords, (x, y))
     print coordsAndDelay
     print x, y
     for x, y, delay in coordsAndDelay:
         move(int(x), int(y))
         sleep(delay / 1000)
     move_mouse_to(x, y)
Esempio n. 10
0
    def move_radius(self, coord):
        """Human mouse movement """
        x = random.randint(coord[0] + 6, coord[2] + coord[0] - 6)
        y = random.randint(coord[1] + 6, coord[3] + coord[1] - 6)

        print x, y
        startCoords = get_pos()
        coordsAndDelay = self._calcCoordsAndDelay(startCoords, (x, y))
        for x, y, delay in coordsAndDelay:
            move(int(x), int(y))
            sleep(delay / 1000)
        move_mouse_to(x, y)
Esempio n. 11
0
def singlemove(queryParams, content_type):
    content = "OK"
    if queryParams.has_key('disx') and queryParams.has_key('disy'):
        disx = int(queryParams['disx'])
        disy = int(queryParams['disy'])
        x, y = mouse.get_pos()
        xx, yy = disx + x, disy + y
        print(disx, disy, x, y, xx, yy)
        try:
            mouse.move(xx, yy)
        except ValueError:
            print("out of side")
    return content_type, content
Esempio n. 12
0
def launch_ball(x0, y0, x1, y1):
  mouse.move(x0, y0)
  #time.sleep(0.1)
  for y3 in range(y0+40, y1-40, -1):
    if y3 == y0:
      mouse.toggle(True, 1)
    x3 = int(float(y3-y1)/(y0-y1)*(x0-x1)+x1)
    if y3 % 10 == 0:
      mouse.move(x3, y3)
    if y3 == y1:
      mouse.toggle(False, 1)
    time.sleep(0.001)
  time.sleep(1)
Esempio n. 13
0
def singlemove(queryParams,content_type):
    content = "OK"
    if queryParams.has_key('disx') and queryParams.has_key('disy'):
        disx = int(queryParams['disx'])
        disy = int(queryParams['disy'])
        x,y = mouse.get_pos()
        xx,yy = disx+x,disy+y
        print(disx,disy,x,y,xx,yy)
        try:
            mouse.move(xx,yy)
        except ValueError:
            print("out of side")
    return content_type,content
Esempio n. 14
0
 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()
Esempio n. 15
0
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
Esempio n. 16
0
    def onFrame(self, controller):
        # Get the most recent frame and report some basic information
        frame = controller.frame()
        hands = frame.hands()
        numHands = len(hands)
        pos = Leap.Vector(self.avgx, self.avgy, 0)
        if len(hands) > 0:
            hand = hands[-1]

            move_x = x(self.avgx)
            move_y = y(self.avgy)
            mouse.move(move_x, move_y)
            print "Moving to %d, %d" % (move_x, move_y)

            fingers = hand.fingers()
            print "Frame id: %d, timestamp: %d, hands: %d" % (
                        frame.id(), frame.timestamp(), numHands)

            hand = hands[0]

            palmRay = hand.palm()
            if palmRay is not None:
                print "Hand has palm position (%f, %f" % (
                    pos.x, pos.y)
                palm = palmRay.position
                pos.x = palm.x
                pos.y = palm.y

            numFingers = len(fingers)
            if numFingers == 1:
                mouse.toggle(False, mouse.LEFT_BUTTON)
                mouse.toggle(True, mouse.RIGHT_BUTTON)
            elif numFingers == 2:
                mouse.toggle(True, mouse.LEFT_BUTTON)
                mouse.toggle(False, mouse.RIGHT_BUTTON)
            else:
                mouse.toggle(False, mouse.LEFT_BUTTON)
                mouse.toggle(False, mouse.RIGHT_BUTTON)
        else:
            mouse.toggle(False, mouse.LEFT_BUTTON)
            mouse.toggle(False, mouse.RIGHT_BUTTON)
        self.avgx = self.avgx*0.7 + pos.x*0.3
        self.avgy = self.avgy*0.7 + pos.y*0.3
        time.sleep(0.001)
Esempio n. 17
0
    def onFrame(self, controller):
        # Get the most recent frame and report some basic information
        frame = controller.frame()
        hands = frame.hands()
        numHands = len(hands)
        pos = Leap.Vector(self.avgx, self.avgy, 0)
        if len(hands) > 0:
            hand = hands[-1]

            move_x = x(self.avgx)
            move_y = y(self.avgy)
            mouse.move(move_x, move_y)
            print "Moving to %d, %d" % (move_x, move_y)

            fingers = hand.fingers()
            print "Frame id: %d, timestamp: %d, hands: %d" % (
                frame.id(), frame.timestamp(), numHands)

            hand = hands[0]

            palmRay = hand.palm()
            if palmRay is not None:
                print "Hand has palm position (%f, %f" % (pos.x, pos.y)
                palm = palmRay.position
                pos.x = palm.x
                pos.y = palm.y

            numFingers = len(fingers)
            if numFingers == 1:
                mouse.toggle(False, mouse.LEFT_BUTTON)
                mouse.toggle(True, mouse.RIGHT_BUTTON)
            elif numFingers == 2:
                mouse.toggle(True, mouse.LEFT_BUTTON)
                mouse.toggle(False, mouse.RIGHT_BUTTON)
            else:
                mouse.toggle(False, mouse.LEFT_BUTTON)
                mouse.toggle(False, mouse.RIGHT_BUTTON)
        else:
            mouse.toggle(False, mouse.LEFT_BUTTON)
            mouse.toggle(False, mouse.RIGHT_BUTTON)
        self.avgx = self.avgx * 0.7 + pos.x * 0.3
        self.avgy = self.avgy * 0.7 + pos.y * 0.3
        time.sleep(0.001)
Esempio n. 18
0
    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
Esempio n. 19
0
 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
Esempio n. 20
0
 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()
Esempio n. 21
0
    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
Esempio n. 22
0
def track_color():
    global mousedown
    global thresh

    # Get threshold image
    thresh = getThresImage()

    # find contours in the threshold image
    contours, hierarchy = cv2.findContours(thresh, cv2.RETR_LIST,
                                           cv2.CHAIN_APPROX_SIMPLE)

    # finding contour with maximum area and store it as best_cnt
    max_area = 0
    for cnt in contours:
        area = cv2.contourArea(cnt)
        if area > max_area:
            max_area = area
            best_cnt = cnt

    try:
        # finding centroids of best_cnt and draw a circle there
        M = cv2.moments(best_cnt)
        cx, cy = int(M['m10'] / M['m00']), int(M['m01'] / M['m00'])
        cv2.circle(frame, (cx, cy), 8, [0, 0, 0], 5)
        cv2.circle(frame, (cx, cy), 8, [0, 255, 0], 4)
        # mouse
        if subproc == 'Mouse control':
            scX, scY = ps.screenXY(cx, cy)
            am.move(scX, scY)
            if mousedown == False:
                #am.toggle(True,am.LEFT_BUTTON)
                mousedown = True
                print 'mousedown'

    except NameError:  # the color was not detected
        # mouse
        if subproc == 'Mouse control':
            if mousedown == True:
                #am.toggle(False,am.LEFT_BUTTON)
                mousedown = False
                print 'mouseup'
Esempio n. 23
0
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)
Esempio n. 24
0
 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
Esempio n. 25
0
 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()
Esempio n. 26
0
def track_color():
	global mousedown
	global thresh

	# Get threshold image
	thresh = getThresImage()

    # find contours in the threshold image
	contours,hierarchy = cv2.findContours(thresh,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE)

    # finding contour with maximum area and store it as best_cnt
	max_area = 0
	for cnt in contours:
	    area = cv2.contourArea(cnt)
	    if area > max_area:
	        max_area = area
	        best_cnt = cnt

	try:
		# finding centroids of best_cnt and draw a circle there
		M = cv2.moments(best_cnt)
		cx,cy = int(M['m10']/M['m00']), int(M['m01']/M['m00'])
		cv2.circle(frame,(cx,cy),8,[0, 0, 0],5)
		cv2.circle(frame,(cx,cy),8,[0, 255, 0],4)
		# mouse
		if subproc == 'Mouse control':
			scX, scY = ps.screenXY(cx,cy)
			am.move(scX, scY)
			if mousedown==False:
				#am.toggle(True,am.LEFT_BUTTON)
				mousedown = True
				print 'mousedown'

	except NameError: # the color was not detected
    	# mouse
		if subproc == 'Mouse control':
			if mousedown==True:
				#am.toggle(False,am.LEFT_BUTTON)
				mousedown = False
				print 'mouseup'
Esempio n. 27
0
 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)
Esempio n. 28
0
 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)
Esempio n. 29
0
 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()
Esempio n. 30
0
 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
Esempio n. 31
0
 def makeMove(self, move):
     self.gameState.makeMove(move)
     
     firstPt, secondPt = move.pointTuple()
     
     absFirst = self.boardToAbsPt(firstPt)
     absSecond = self.boardToAbsPt(secondPt)
     
     lastX, lastY = mouse.get_pos()
     
     mouse.move(absFirst.x, absFirst.y)
     mouse.toggle(True)
     mouse.move(absSecond.x, absSecond.y)
     mouse.toggle(False)
     
     mouse.move(lastX, lastY)
Esempio n. 32
0
 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(x,y):
	mouse.move(x, y)
	time.sleep(.5)
	mouse.click()
Esempio n. 34
0
def move_middle_bottom():
    """Moves the mouse to the bottom middle of the screen."""
    size = screen.get_size()
    middle_bottom = (size[0]/2, size[1]-1)
    mouse.move(middle_bottom[0],middle_bottom[1])
Esempio n. 35
0
 def moveOffBoard(self):
     mouse.move(self.gameOffset.x - 10, self.gameOffset.y - 10)
Esempio n. 36
0
def mouse_down(x, y):
    mouse.move(x, y)
    mouse.toggle(True)
Esempio n. 37
0
 def itmlst_toggle():
     mouse.move(290, 198)
     mouse.click(1)
Esempio n. 38
0
def click(cord):
    mouse.move(x_pad+cord[0], y_pad+cord[1])
    mouse.click()
    time.sleep(0.1)
Esempio n. 39
0
 def itmlst_toggle():
     mouse.move(290,198)
     mouse.click(1)
def go_and_rclick(x, y, delay=.1):
    mouse.move(x, y)
    mouse.click(mouse.RIGHT_BUTTON)
    time.sleep(delay)
Esempio n. 41
0
 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()
Esempio n. 42
0
 def double_click_passwd_input_text_box(self):
     mouse.move(self.screen_size[0] / 2, self.screen_size[1] / 2 + 76)
     mouse.click()
Esempio n. 43
0
 def double_click_qq_input_text_box(self):
     mouse.move(self.screen_size[0] / 2, self.screen_size[1] / 2 + 49)
     mouse.click()
Esempio n. 44
0
def mouse_up(x, y):
    mouse.move(x, y)
    mouse.toggle(False)
Esempio n. 45
0
def moveclick(xpos, ypos):
    mouse.move(xpos, ypos)
    time.sleep(0.05)
    mouse.click()
Esempio n. 46
0
 def _move_mouse(self, coords):
     mouse.move(coords[0], coords[1])
Esempio n. 47
0
def move_click(coordinates, button):
    """Moves the mouse to the specified coordinate and click the specified button."""
    print "moving mouse position to coordinates (X=%s , Y=%s) and click on this position!" % (coordinates[0],coordinates[1])
    mouse.move(coordinates[0], coordinates[1])
    mouse.click(button)
Esempio n. 48
0
    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'))
Esempio n. 49
0
 def _set_focus_from_taskbar_coords(self):
     x, y = self._taskbar_coords
     mouse.move(x, y)
     mouse.click()
     sleep(1)
Esempio n. 50
0
 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()
Esempio n. 51
0
import serial  # import Serial
from autopy import mouse
#from autopy.mouse import LEFT_BUTTON, RIGHT_BUTTON
ser = serial.Serial('COM3', 9600)
mouse.move(683, 359)
x = 0
y = 0
while 1:
    try:
        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
Esempio n. 52
0
def mouse_move(x, y):
    mouse.move(x, y)
        time.sleep(.05)
        key.type_string('no fog')
        time.sleep(.05)
        key.tap(key.K_RETURN)

        time.sleep(1)

        stdin, stdout = start_recording(unit, deselect)

        # select unit
        go_and_click(480, 275)

        go_and_rclick(805, 105)
        if deselect:
            mouse.click()
        mouse.move(500, 725)
        time.sleep(9)
        go_and_click(805, 105)

        go_and_rclick(412, 345)
        if deselect:
            mouse.click()
        mouse.move(500, 725)
        time.sleep(12)
        go_and_click(412, 345)

        go_and_rclick(205, 185)
        if deselect:
            mouse.click()
        mouse.move(500, 725)
        time.sleep(7)