Example #1
1
def buscar_test():
    msg = ''
    pyautogui.PAUSE = 0.5
    pyautogui.FAILSAFE = False
    pyperclip.copy('')
    
    findTest = pyautogui.locateOnScreen('buscar-tests.png')
    if findTest is None:
        msg = 'La opcion LOGIN TO CONSOLE no esta seleccionada'
        return (False, msg)
        #exit(0)
    else:
        testPos = list(findTest)
        #print testPos
         
    centroTest = pyautogui.center(testPos)     
    print centroTest
    pyautogui.moveTo(centroTest)
    pyautogui.click(None,None,1)
    pyautogui.moveRel(10, 30)
    pyautogui.click(None,None,1)
    #pyautogui.screenshot('menu-screen2.png')
    #pyautogui.click(None,None,1)
    #pyautogui.screenshot('menu-screen1.png')
    findLogin = pyautogui.locateOnScreen('imagenx.png')
    print findLogin
    
    return (True, msg)
def buscar_campo_id():
    msg = ''
    pyautogui.PAUSE = 0.5
    pyautogui.FAILSAFE = False
    pyperclip.copy('')
    
    dondeEstaElCampoID = pyautogui.locateOnScreen('operator-id-field.png')
    if dondeEstaElCampoID is None:
        msg = 'El campo de OPERATOR-ID no fue encontrado'
        return (False, msg)
        
    else:
        campoIDPos = list(dondeEstaElCampoID)
        #print campoIDPos
         
    centrocampoID = pyautogui.center(campoIDPos)     
    #print centrocampoID
    pyautogui.moveTo(centrocampoID)
    pyautogui.click(None,None,2)
    pyautogui.typewrite('operador1')
    pyautogui.press('enter')
    pyautogui.press('enter')
    pyautogui.press('enter')
    
    
    
    return (True, msg)
Example #3
0
def GetShitDone():
    "Tis function looks after the moon and get shit done"
    pos = pyautogui.locateOnScreen('moon.png') 
    if (pos != None):
        x, y = pyautogui.center(pos)       
        print(time.ctime(), 'Found moon @ x:', x , ' y:', y)
        pyautogui.click(x, y+75)
        time.sleep( 1.5 )
        pos = pyautogui.locateOnScreen('horn.png') 
        if (pos != None):
            x, y = pyautogui.center(pos)       
            print(time.ctime(), 'make horn @ x:', x , ' y:', y)
            pyautogui.click(x, y+75)
            return  
        pos = pyautogui.locateOnScreen('pot.png') 
        if (pos != None):
            x, y = pyautogui.center(pos)       
            print(time.ctime(), 'make pot @ x:', x , ' y:', y)
            pyautogui.click(x, y+75)
            return  
        pos = pyautogui.locateOnScreen('kohl.png') 
        if (pos != None):
            x, y = pyautogui.center(pos)       
            print(time.ctime(), 'make kohl @ x:', x , ' y:', y)
            pyautogui.click(x, y)
            return 
        pos = pyautogui.locateOnScreen('close.png') 
        if (pos != None):
            x, y = pyautogui.center(pos)       
            print(time.ctime(), 'exit @ x:', x , ' y:', y)
            pyautogui.click(x, y)
            return                   
    return
Example #4
0
def for_image_click_left_cornor(image_path, click = 1):
	try:
		print('MOUSE: Click left cornor on ', image_path, ' for ', click)
		if gui.locateOnScreen(image_path) != None:
			x, y, x2, y2 = gui.locateOnScreen(image_path)
			mouse.moveTo(x, y)
			while(click > 0):
				print('\tclicked')
				mouse.click()
				click -= 1
	except Exception as e:
		gui.alert("Failed: " + str(e))
		print(e)
Example #5
0
	def facebookPost(self):
		self.gotoWeb(-1,'www.facebook.com')
		time.sleep(3)
		pag.press('p')
		currentTime = '{:%Y-%b-%d %H:%M:%S}'.format(datetime.datetime.now())
		context = 'Hello, facebook!\n\nSent from Music: Project -- ' + currentTime+'\n'
		pag.typewrite(context, interval=0.2)
		loc = pag.locateOnScreen('./post_zh.png')
		if loc:
			pos = pag.center(loc)
			pag.click(pos[0]/2, pos[1]/2)
		else:
			pos = pag.center(pag.locateOnScreen('./post.png'))
			pag.click(pos[0]/2, pos[1]/2)
Example #6
0
def output_doulist(input_list):
    # 1. find button and change focus in browser
    button_pos = pyautogui.locateOnScreen('output/add_button.png')
    if not button_pos: 
        # no valid button        
        print '没有找到有效的"添加内容"按钮, 请检查后再次导出.'
        return
    elif len(list(pyautogui.locateAllOnScreen('output/add_button.png'))) > 1:
        # more than one valid button
        print '屏幕中有多个有效的"添加内容"按钮, 请检查后再次导出.'
        return
    else:
        # valid input: only one button available
        # remaining issue: the picture is not alwas found in screen...that's strange.
        pyautogui.click(button_pos)
    for i in input_list:
        # 2. press button 
        time.sleep(4)
        pyautogui.click(button_pos)
        # 3. write link
        time.sleep(2)
        pyautogui.typewrite(i)
        pyautogui.press('enter')
        # 4. add to Doulist
        time.sleep(2)
        pyautogui.press('tab')
        pyautogui.press('tab')
        pyautogui.press('tab')
        pyautogui.press('enter')
    print 'iDoulist: 书籍列表已被添加到屏幕上的豆列中.'
def find_game_region():
    """
    Uses image inactive_window.png to find the coordinates of the game
    Inputs: None
    Outputs: the tuple of the coordinates of the game window
    """
    logging.debug("About to take a screenshot and look for inactive_window.png")
    coors = pyautogui.locateOnScreen("images/inactive_window.png")
    if coors is None:
        logging.debug("Did not find inactive_window.png")
        logging.debug("Maybe the window is active instead. Will look for active_window.png")
        coors = pyautogui.locateOnScreen("images/active_window.png")
        if coors is None:
            raise Exception("The game as not found on this screen. Make sure it is visible.")
    logging.debug("Successfully found the game region: " + str(coors[0],coors[1]))
    return (coors[0],coors[1])
Example #8
0
def navigateStartGameMenu():
	"""Performs the clicks to navigate from the start screen (where the PLAY button is visible) to the beginning 
	of the first level."""
    # Click on everything needed to get past the menus at the start of the game.
	
	# Click on PLAY
	logging.debug('Looking for Play button...')
	while True: # loop because it could be the blue or ping Play button displayed (blinking)
		pos = pyautogui.locateOnScreen(imPath('play_button.png'), region=GAME_REGION)
		if pos is not None:
			break
	pyautogui.click(pos, duration=0.25)
	logging.debug('Clicked Play button.')

	# click on Continue
	pos = pyautogui.locateCenterOnScreen(imPath('continue_button.png'), region=GAME_REGION)
	pyautogui.click(pos, duration=0.25)
	logging.debug('Clicked on Continue button.')

	# click on Skip
	logging.debug('Looking for Skip button...')
	while True: # loop because it could be the yellow or red Skip button displayed (blinking)
		pos = pyautogui.locateCenterOnScreen(imPath('skip_button.png'), region=GAME_REGION)
		if pos is not None:
			break
	pyautogui.click(pos, duration=0.25)
	logging.debug('Clicked on Skip button.')

	# click on Continue
	pos = pyautogui.locateCenterOnScreen(imPath('continue_button.png'), region=GAME_REGION)
	pyautogui.click(pos, duration=0.25)
	logging.debug('Clicked Continue button.')
Example #9
0
 def __init__(self):
     self.osk = pyautogui.locateOnScreen('data/osk.png')
     if self.osk is None:
         raise NoKeyboardException()
     self.time_created = time.time()
     self.hp_pots_used = 0
     self.mana_pots_used = 0
def buscar_campo_serial(serial_number):
    msg = ''
    pyautogui.PAUSE = 0.5
    pyautogui.FAILSAFE = False
    pyperclip.copy('')
    
    dondeEstaElCampoSerial = pyautogui.locateOnScreen('operator-id-field.png')
    if dondeEstaElCampoSerial is None:
        msg = 'El campo de SERIAL NUMBER no fue encontrado'
        return (False, msg)
        
    else:
        campoSerialPos = list(dondeEstaElCampoSerial)
        #print campoSerialPos
         
    centrocampoSerial = pyautogui.center(campoSerialPos)     
    #print centrocampoSerial
    pyautogui.moveTo(centrocampoSerial)
    pyautogui.click(None,None,2)
    #pyautogui.typewrite('C3WB4E768226230')
    pyautogui.typewrite(serial_number)
    pyautogui.press('enter')
    #pyautogui.press('enter')
    #pyautogui.press('enter')
    
    return (True, msg)
Example #11
0
def makeOrder(orderType):
    """Does the mouse clicks needed to create an order.

    The orderType parameter has the value of one of the ONIGIRI, GUNKAN_MAKI, CALIFORNIA_ROLL, SALMON_ROLL, SHRIMP_SUSHI, UNAGI_ROLL, DRAGON_ROLL, COMBO constants.

    The INVENTORY global variable is updated in this function for orders made.

    The return value is None for a successfully made order, or the string of an ingredient constant if that needed ingredient is missing."""
    global ROLLING_COMPLETE, INGRED_COORDS, INVENTORY

    # wait until the mat is clear. The previous order could still be there if the conveyor belt has been full or the mat is currently rolling.
    while time.time() < ROLLING_COMPLETE and pyautogui.locateOnScreen(imPath('clear_mat.png'), region=(GAME_REGION[0] + 115, GAME_REGION[1] + 295, 220, 175)) is None:
        time.sleep(0.1)

    # check that all ingredients are available in the inventory.
    for ingredient, amount in RECIPE[orderType].items():
        if INVENTORY[ingredient] < amount:
            logging.debug('More %s is needed to make %s.' % (ingredient, orderType))
            return ingredient

    # click on each of the ingredients
    for ingredient, amount in RECIPE[orderType].items():
        for i in range(amount):
            pyautogui.click(INGRED_COORDS[ingredient], duration=0.25)
            INVENTORY[ingredient] -= 1
    findAndClickPlatesOnBelt() # get rid of any left over meals on the conveyor belt, which may stall this meal from being loaded on the belt
    pyautogui.click(MAT_COORDS, duration=0.25) # click the rolling mat to make the order
    logging.debug('Made a %s order.' % (orderType))
    ROLLING_COMPLETE = time.time() + 1.5 # give the mat enough time (1.5 seconds) to finish rolling before being used again
Example #12
0
def hangup():
    location = pyautogui.locateOnScreen(image('hangup.png'))
    if location is None:
        print 'Could not find hangup button'
        return False
    location_x, location_y = pyautogui.center(location)
    pyautogui.click(location_x, location_y)
    time.sleep(3)
Example #13
0
def GetTheArmy():
    "Tis function grabs a frame and click below the hammer"
    pos = pyautogui.locateOnScreen('schwert.png') 
    if (pos != None):
        x, y = pyautogui.center(pos)       
        print(time.ctime(), 'Found sword @ x:', x , ' y:', y)
        pyautogui.click(x, y+75)
    return
Example #14
0
def GetTheResources():
    "Tis function grabs a frame and click below the hammer"
    pos = pyautogui.locateOnScreen('hammer.png') 
    if (pos != None):
        x, y = pyautogui.center(pos)       
        print(time.ctime(), 'Found hammer @ x:', x , ' y:', y)
        pyautogui.click(x, y+100)
    return
Example #15
0
def GetTheMoney():
    "Tis function grabs a frame and click below the coin"
    pos = pyautogui.locateOnScreen('geld.png') 
    if (pos != None):
        x, y = pyautogui.center(pos)       
        print(time.ctime(), 'Found coin @ x:', x , ' y:', y)
        pyautogui.click(x, y+55)
    return
Example #16
0
	def run(self):		
		if (self.ws == 0):
				self.showErrMsg.emit(u'錯誤', u'請選取有效檔案')

		else:
			start=1
			count = 0
			while start:
				sleep(1)
				count += 1
				trigger  = None
				trigger1 = locateOnScreen('./img/det1.png')
				trigger2 = locateOnScreen('./img/det2.png')
				trigger3 = locateOnScreen('./img/det3.png')
				detStr = u'狀態:  偵測中.{0}'

				self.addStatus.emit( detStr.format('.'*(count%4)), 0)
				if   trigger1 != None:
					trigger = trigger1
				elif trigger2 != None:
					trigger = trigger2
				elif trigger3 != None:
					trigger = trigger3
				else:
					if self.stopSign == 1:
						start = 0
						self.addStatus.emit( u'狀態:  手動終止偵測程序', 1)
					else:
						self.addStatus.emit( u'狀態:  偵測不到輸入區域', 0)

				if trigger != None:
					self.addStatus.emit( u'狀態:  偵測到輸入區域', 9)
					self.toTray.emit(1)
					start = 0
					moveToX = (trigger[0]+trigger[2])
					moveToY = (trigger[1]+trigger[3])
					click(x=moveToX, y=moveToY, clicks=1, interval=0, button='left') 
					self.wswrite(self.ws)
					if self.stopSign == 1:
						self.addStatus.emit( u'狀態:  手動終止輸入程序', 1)
					else:
						self.threadDone.emit()
						self.toTray.emit(0)
		self.enableButtons.emit()
		return 0
Example #17
0
 def checkHealth(self, pot_key):
     """
     Given a key that is bound to a health potion, this method will check
     for a depleted health bar and use potions until it can no longer see a
     depleted health bar.
     """
     while not pyautogui.locateOnScreen('data/hp.png'):
         self.click(pot_key, 0.25)
         self.hp_pots_used += 1
Example #18
0
 def checkMana(self, pot_key):
     """
     Given a key that is bound to a mana potion, this method will check for a
     depleted mana bar and use potions until it can no longer see a depleted
     mana bar.
     """
     while not pyautogui.locateOnScreen('data/mana.png'):
         self.click(pot_key, 0.25)
         self.mana_pots_used += 1
Example #19
0
def checkForGameOver():
    """Checks the screen for the "You Win" or "You Fail" message.

    On winning, returns the string in LEVEL_WIN_MESSAGE.

    On losing, the program terminates."""

    # check for "You Win" message
    result = pyautogui.locateOnScreen(imPath('you_win.png'), region=(GAME_REGION[0] + 188, GAME_REGION[1] + 94, 262, 60))
    if result is not None:
        pyautogui.click(pyautogui.center(result))
        return LEVEL_WIN_MESSAGE

    # check for "You Fail" message
    result = pyautogui.locateOnScreen(imPath('you_failed.png'), region=(GAME_REGION[0] + 167, GAME_REGION[1] + 133, 314, 39))
    if result is not None:
        logging.debug('Game over. Quitting.')
        sys.exit()
Example #20
0
def pass_search():
    pyautogui.PAUSE = 0.5
    pyautogui.FAILSAFE = False
    pyperclip.copy("")

    dondeEstaElBoton = pyautogui.locateOnScreen("go-button.png")
    if dondeEstaElBoton is None:
        print "El boton de GO no fue encontrado"

    else:
        botonPos = list(dondeEstaElBoton)
        print botonPos

    centroBoton = pyautogui.center(botonPos)
    print centroBoton

    contador = 0
    while True:
        contador += 1
        pyautogui.moveTo(centroBoton)
        pyautogui.moveRel(796, 0)  # Mover el raton a la barra de desplazamiento
        pyautogui.click(None, None, 2)
        # if contador == 1:
        #    time.sleep(0.3)
        #    pyautogui.typewrite('!reset')
        #    pyautogui.press('enter')

        pyautogui.click(None, None, 1)
        pyautogui.dragRel(0, -293, 1, button="left")
        # pyautogui.scroll(10)  #Hacer scroll para llegar a la parte superior del cuadro de texto
        # pyautogui.moveRel(0, -294)   #Mover el raton a la parte superior de la barra de desplazamiento
        pyautogui.moveRel(-390, 0)  # Mover el raton a la posicion en donde se encuentra la clave

        pyautogui.PAUSE = 0.05

        pyautogui.click(None, None, 2)
        # pyautogui.doubleClick()   #Hacer dobleclic en la palabra de la clave
        pyautogui.hotkey("ctrl", "c")

        # pyautogui.doubleClick()   #Hacer dobleclic en la palabra de la clave
        # pyautogui.hotkey('ctrl', 'c')

        # pyautogui.doubleClick()   #Hacer dobleclic en la palabra de la clave
        # pyautogui.hotkey('ctrl', 'c')
        pyautogui.PAUSE = 1

        r = pyperclip.paste()
        print r

        if len(r) == 10:
            print "clave encontrada"
            break
        if contador == 5:
            print "Se hizo el intento 5 veces para buscar la clave"
            break
        time.sleep(0.5)
Example #21
0
def getGameRegion():
    """Obtains the region that the Kanpani Girls game is on the screen and assigns it to GAME_REGION.
       The game must be at the start screen (where the PLAY button is visible)."""
    global GAME_REGION

    # identify the CEO Office
    logging.info("Finding game region...")
    region = pyautogui.locateOnScreen(imgPath("CeoOffice.png"))
    while region is None:
        logging.info("Could not find game on screen. Is the game visible?")
        time.sleep(5)
        region = pyautogui.locateOnScreen(imgPath("CeoOffice.png"))
        # raise Exception('Could not find game on screen. Is the game visible?')

    # calculate the region of the entire game
    bottomLeftX = region[0]  # left
    bottomLeftY = region[1] + region[3]  # bottom + width
    GAME_REGION = (bottomLeftX, bottomLeftY - 590, 950, 590)  # the game screen is always 950 x 590
    logging.info("Game region found: %s" % (GAME_REGION,))
Example #22
0
def locateOnScreen(interfaceObject):
	logging.info('trying to locate "%s" on screen' % interfaceObject)
	if type( interface[interfaceObject] ) == tuple:
		logging.info('object is not an image, check your code!')
		raise Exception('given object to find on screen is not an image!')
	
	found = pyautogui.locateOnScreen( interface[interfaceObject] )
	if not found:
		logging.info( "can't locate '%s' on screen :(" % interfaceObject )
	return found
Example #23
0
 def mana(self):
     """Checks health bar, if it's low use 2 potions bound to '5' """
     potions_to_chug = 2
     logging.info('Checking mana.')
     while not pyautogui.locateOnScreen(self.mana_img):
         logging.info('Drinking mana pots.')
         for x in range(potions_to_chug):
             pyautogui.click(self.FIVE)
             time.sleep(0.3)
     logging.info('Mana replenished.')
Example #24
0
def orderIngredient(ingredient):
    """Do the clicks to purchase an ingredient. If successful, the ORDERING_COMPLETE dictionary is updated for when the ingredients will arive and INVENTORY can be updated. (This is handled in the updateInventory() function.)"""
    logging.debug('Ordering more %s (inventory says %s left)...' % (ingredient, INVENTORY[ingredient]))
    pyautogui.click(PHONE_COORDS, duration=0.25)

    if ingredient == RICE and ORDERING_COMPLETE[RICE] is None:
        # Order rice.
        pyautogui.click(RICE1_COORDS, duration=0.25)

        # Check if we can't afford the rice
        if pyautogui.locateOnScreen(imPath('cant_afford_rice.png'), region=(GAME_REGION[0] + 498, GAME_REGION[1] + 242, 90, 75)):
            logging.debug("Can't afford rice. Canceling.")
            pyautogui.click(GAME_REGION[0] + 585, GAME_REGION[1] + 335, duration=0.25) # click cancel phone button
            return

        # Purchase the rice
        pyautogui.click(RICE2_COORDS, duration=0.25)
        pyautogui.click(NORMAL_DELIVERY_BUTTON_COORDS, duration=0.25)
        ORDERING_COMPLETE[RICE] = time.time() + NORMAL_RESTOCK_TIME
        logging.debug('Ordered more %s' % (RICE))
        return

    elif ORDERING_COMPLETE[ingredient] is None:
        # Order non-rice ingredient.
        pyautogui.click(TOPPING_COORDS, duration=0.25)

        # Check if we can't afford the ingredient
        if pyautogui.locateOnScreen(imPath('cant_afford_%s.png' % (ingredient)), region=(GAME_REGION[0] + 446, GAME_REGION[1] + 187, 180, 180)):
            logging.debug("Can't afford %s. Canceling." % (ingredient))
            pyautogui.click(GAME_REGION[0] + 597, GAME_REGION[1] + 337, duration=0.25) # click cancel phone button
            return

        # Order the ingredient
        pyautogui.click(ORDER_BUTTON_COORDS[ingredient], duration=0.25)
        pyautogui.click(NORMAL_DELIVERY_BUTTON_COORDS, duration=0.25)
        ORDERING_COMPLETE[ingredient] = time.time() + NORMAL_RESTOCK_TIME
        logging.debug('Ordered more %s' % (ingredient))
        return

    # The ingredient has already been ordered, so close the phone menu.
    pyautogui.click(GAME_REGION[0] + 589, GAME_REGION[1] + 341) # click cancel phone button
    logging.debug('Already ordered %s.' % (ingredient))
Example #25
0
def fileMenu():
    #!OS specific!
    #get the top left xy coords of the file menu
    try:
        x,y,bx,by = cntrl.locateOnScreen('File.png')
        cntrl.moveTo(x, y)
        cntrl.moveRel(9,35)
        cntrl.click()
       
    except:
        cntrl.alert("oops...something went wrong with File menu. See Andre")
Example #26
0
 def heal(self):
     """Checks health bar, if it's low use 2 potions bound to '4' """
     potions_to_chug = 2
     logging.info('Checking health.')
     while not pyautogui.locateOnScreen(self.health_img):
         for x in range(potions_to_chug):
             pyautogui.click(self.FOUR)
             time.sleep(0.3)
         self.potion_count += potions_to_chug
         logging.info('Used %d potions.', self.potion_count)
     logging.info('Done healing.')
Example #27
0
def leftClickTwice(image):
    try:
        if type(image) == tuple:
            location = image
        else:
            location = pyautogui.locateOnScreen(image, grayscale=True)
        x, y = pyautogui.center(location)
        pyautogui.doubleClick(x, y)
    except TypeError:
        print 'double click error' + ' ' + image
        return leftClickTwice(image)
def find_board():
    '''
    Returns a tuple of the game board region. (top, left, width, height)
    '''
    title = pyautogui.locateOnScreen('title.png')
    if title == None:
        title = pyautogui.locateOnScreen('title_active.png')
    screenshot = pyautogui.screenshot()
    border = [(title[0]+30), (title[1]+title[3]+1), 0, 0]
    while screenshot.getpixel((border[0], border[1])) != BACKGROUND:
        border[1] += 1
    while screenshot.getpixel((border[0], border[1])) != BORDER:
        border[1] += 1
    while screenshot.getpixel((border[0]-1, border[1])) == BORDER:
        border[0] -= 1
    while screenshot.getpixel((border[0]+border[2], border[1])) == BORDER:
        border[2] += 1
    while screenshot.getpixel((border[0], border[1]+border[3])) == BORDER:
        border[3] += 1
    return tuple(border)
Example #29
0
 def heal(self):
     """If red health bar not detected try R, if health still low 
     press T until it is.  This method overrides MapleChar.heal"""
     return
     potions_to_chug = 3
     logging.info("Checking health.")
     if not pyautogui.locateOnScreen(self.health_img):
         logging.info("Health low, attempting Overload Release")
         pyautogui.click(self.R)
         time.sleep(0.5)
         logging.info('Checking health again.')
         while not pyautogui.locateOnScreen(self.health_img):
             logging.info("Health didn't regenerate, drinking potions.")
             for x in range(potions_to_chug):
                 pyautogui.click(self.T)
                 time.sleep(0.3)
             self.potion_count += potions_to_chug
             logging.info("Used %d potions", self.potion_count)
         logging.info('Done healing.')
     else:
         logging.info('Health checked out')
Example #30
0
def callnumber(number):
    callsetup()
    pyautogui.typewrite(number, interval=TYPE_INTERVAL) # type with quarter-second pause in between each key
    # pyautogui.press('enter')
    time.sleep(1)
    location = pyautogui.locateOnScreen(image('call-button.png'))
    if location is None:
        print 'Could not find call button'
        return False
    location_x, location_y = pyautogui.center(location)
    pyautogui.click(location_x, location_y)
    time.sleep(1)
Example #31
0
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 12 18:57:51 2019

@author: s.lagousis
"""

#Based on code from here
# https://automatetheboringstuff.com/chapter18/

import pyautogui
width, height = pyautogui.size()

#for i in range(10):
#    pyautogui.moveTo(100, 100, duration=0.25)
#    pyautogui.moveTo(200, 100, duration=0.25)
#    pyautogui.moveTo(200, 200, duration=0.25)
#    pyautogui.moveTo(100, 200, duration=0.25)

#for i in range(10):
#    pyautogui.moveRel(100, 0, duration=0.25)
#    pyautogui.moveRel(0, 100, duration=0.25)
#    pyautogui.moveRel(-100, 0, duration=0.25)
#    pyautogui.moveRel(0, -100, duration=0.25)

#print(pyautogui.position())

rect = pyautogui.locateOnScreen('microphone.png')
pos = pyautogui.center(rect)
pyautogui.click(pos)
Example #32
0
import pyautogui
import time
time.sleep(5)
im = pyautogui.screenshot()
im.save('C:\\Users\\user\\Desktop\\001f.png')
button7location = pyautogui.locateOnScreen('C:\\Users\\user\\Desktop\\001.png',
                                           grayscale=True)
button7x, button7y = pyautogui.center(button7location)
pyautogui.click(button7x + 100, button7y + 15)
time.sleep(5)
im = pyautogui.screenshot()
im.save('C:\\Users\\user\\Desktop\\002f.png')
button8location = pyautogui.locateOnScreen('C:\\Users\\user\\Desktop\\002.png',
                                           grayscale=True)
button8x, button8y = pyautogui.center(button8location)
pyautogui.click(button8x, button8y)
pyautogui.click(button8x, button8y + 10)
time.sleep(5)
pyautogui.typewrite('psw  ', interval=0.25)
pyautogui.press('enter')
Example #33
0
import pyautogui
import sys

arg1 = sys.argv[1]

if arg1 == 'victory':
    s = pyautogui.locateOnScreen('./python/assets/victory.png')
elif arg1 == 'combat':
    s = pyautogui.locateOnScreen('./python/assets/combatCheck.png')

print(s)
Example #34
0
import time
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract-OCR\tesseract.exe"


# SR display resolution = 1024x768



R = 6371000 #m
g = 9.8 #m/s^2
gamma_1 = 85 #deg
to = 0
delta_gamma = 0


teleX, teleY ,teleW, teleH = pag.locateOnScreen(r"C:\Users\IMAD-PC\Desktop\LaunchControlSystem\marker.PNG")
pag.click(teleX, teleY, button='left')
print('Marker found '+str(teleX)+','+str(teleY))
time.sleep(2)




def throttle(P):
    if P == 0:
        pass
        #pag.press('0')



def autoHeading(targetAngle , currentAngle):
Example #35
0
def button6fail():
    return pyautogui.locateOnScreen('fail.bmp',
                                    region=(1575, 930, 330, 50),
                                    grayscale=True,
                                    confidence=0.8)
Example #36
0
def button8accept():
    return pyautogui.locateOnScreen('accept.bmp',
                                    grayscale=True,
                                    confidence=0.9)
Example #37
0
def button10close():
    return pyautogui.locateOnScreen('close.bmp',
                                    region=(1650, 1000, 170, 45),
                                    grayscale=True,
                                    confidence=0.9)
Example #38
0
				elif x=='exit':
					break

				else:
					output = os.system(x)
					print()
					if output == 1:
						#log("Unknown Command .." + '\n')	
						pass



pt.click(x=141, y=756)				# firefox-coordinate x=141, y=756

while True:
		new_msg_loc = pt.locateOnScreen(img,confidence=0.8)
		if new_msg_loc ==None:
			print("no new message !")
			#time.sleep(6)
			sys.exit()

		else:
			print("You have a new message sir !")
			loc = pt.center(new_msg_loc)
			#print('loc ==',loc)
			loc_list = list(loc)
			#print(loc_list)
			x = int(loc_list[0]) -50
			y = int(loc_list[1])
			pt.moveTo(x,y)
			pt.click(x,y)							# new_msg_loc = 890,642
Example #39
0
import pyautogui

w, h = pyautogui.size()

print(w, h, pyautogui.position())

#pyautogui.moveTo(50, 10, duration=2)

#pyautogui.moveRel(80, 400, duration=2)

#pyautogui.moveTo(122, 402, duration=2)

#pyautogui.click()

#pyautogui.typewrite('Hello World', interval=0.25)

#pyautogui.typewrite(['e','y','left','left','H', 'right', 'right', 'space', 'Y','o','u','.'], interval=0.25)
#print(pyautogui.KEYBOARD_KEYS)

#pyautogui.press('f5')

#pyautogui.hotkey('ctrl','n')

#pyautogui.screenshot('Automation\\files\\ss.png')

print(pyautogui.locateOnScreen('Automation\\files\\ot.png'))

print(pyautogui.locateCenterOnScreen('Automation\\files\\ot.png'))
Example #40
0
def localeImage(image, confidence=0.7, grayscale=True):
    return pyautogui.locateOnScreen(image + '.png',
                                    confidence=confidence,
                                    grayscale=grayscale)
Example #41
0
def autoqq():
    img_pos = pyautogui.locateOnScreen('BAR-fullhp.png', confidence=0.2)
    if img_pos is not None:
        pyautogui.click(img_pos)
        pydirectinput.press('q')
Example #42
0
def imgExists(img):
    return bool(
        pyautogui.locateOnScreen(imageDir + img + '.png', grayscale=True))
Example #43
0
#Automatic recommendation sender to the profile (LinkedIn)
#as a fallsafe if script goes unresponsive, take your cursor to anycorner of the screen
import pyautogui
import time

connectbutpoint = pyautogui.locateCenterOnScreen('plus.png', confidence =0.8)

while True:

    connectbutlocation = pyautogui.locateOnScreen('plus.png', confidence =0.8)
    connectbutpoint = pyautogui.center(connectbutlocation)
    pyautogui.click(connectbutpoint) #click on plus button
    time.sleep(1.4)  #giving the time to browser to render the recommendation popup
    notebutpoint = pyautogui.locateCenterOnScreen('hs.png', confidence =0.8) #locate the highly skilled button
    pyautogui.click(notebutpoint)  #click on highly skilled button
    sendbutpoint = pyautogui.locateCenterOnScreen('sar.png', confidence =0.8) #locate the relation button
    pyautogui.click(sendbutpoint) #click on how do you know button
    sbutpoint = pyautogui.locateCenterOnScreen('workedtogether.png', confidence =0.8) #locate the worked together button
    pyautogui.click(sbutpoint)
    sndbutpoint = pyautogui.locateCenterOnScreen('submit.png', confidence =0.8) #locate the submit button
    pyautogui.click(sndbutpoint)
    time.sleep(1)   #a one second delay just so that linkedin does not consider you a bot spitting connect requests 
                    #also helps in the fallsafe 
     

#defalt007
Example #44
0
def button1svitok():
    return pyautogui.locateOnScreen('svitok.bmp',
                                    region=(1480, 295, 440, 420),
                                    grayscale=True,
                                    confidence=0.9)
Example #45
0
import pyautogui
import time
import numpy as np
import cv2
from PIL import ImageGrab

rect = pyautogui.locateOnScreen('./flappy_bird.png')
box = (rect[0], rect[1], rect[0] + rect[2], rect[1] + 2 * rect[3])

while True:
    img = ImageGrab.grab()
    # img = img.crop(box)
    img = np.array(img.getdata(), dtype='uint8').reshape((img.size[1], img.size[0],3))
    cv2.imshow('window', img)
    if cv2.waitKey(25) & 0xFF == ord('q'):
        cv2.destroyAllWindows()
        break

Example #46
0
def checkInGame():
    while True:
        nice = pyautogui.locateOnScreen('sidebar.png', grayscale=False)
        if nice != None:
            break
        time.sleep(random.randint(1000, 2000) * 0.01)
Example #47
0
def button9warning():
    return pyautogui.locateOnScreen('warning.bmp',
                                    grayscale=True,
                                    confidence=0.9)
Example #48
0

smile = Image.open('smile.bmp')
brandon_folder = Image.open('brandon.bmp')
brandon_target = Image.open('brandon_target.bmp')


pyautogui.doubleClick(pyautogui.locateCenterOnScreen(brandon_folder))
print 'found'
time.sleep(2)
pyautogui.doubleClick(pyautogui.locateCenterOnScreen(brandon_target))
print 'fin'
time.sleep(2)
pyautogui.typewrite(['f11'])
exit()
center_list = list(pyautogui.center(pyautogui.locateOnScreen(smile)))
print center_list
center_list[0] = center_list[0] - 80
center = tuple(center_list)
print center

pyautogui.doubleClick(center)

exit()
#importing reference image library
components_screen = Image.open('components.bmp')
deadlock_popup = Image.open('deadlock.bmp')
device_screen = Image.open('device_shellmods.bmp')
discount_screen = Image.open('discounts_charges.bmp')
general_screen = Image.open('general.bmp')
pt_popup = Image.open('new_pt_popup.bmp')
Example #49
0
def button7won():
    return pyautogui.locateOnScreen('won.bmp',
                                    region=(1575, 930, 330, 50),
                                    grayscale=True,
                                    confidence=0.9)
Example #50
0
def button4start():
    return pyautogui.locateOnScreen('start.bmp',
                                    region=(1650, 1000, 170, 45),
                                    grayscale=True,
                                    confidence=0.9)
Example #51
0
def button5next():
    return pyautogui.locateOnScreen('next.bmp',
                                    region=(1650, 1000, 90, 40),
                                    grayscale=True,
                                    confidence=0.9)
Example #52
0
 def check_move_span_ok(self):
     return pyautogui.locateOnScreen('./images/span_ok.png',
                                     region=(1242, 321, 465, 404),
                                     confidence=0.8)
Example #53
0
import pyautogui

# Takes an screenshot and save it
pyautogui.screenshot('screen_shot.png')

# Finds an image on the screen
print(pyautogui.locateOnScreen('calc7.png'))

# Finds the center of an image on the screen
x, y = pyautogui.locateCenterOnScreen('calc7.png')

# Moves to the image
pyautogui.moveTo(x, y)

# Clicks into the image
pyautogui.click(x, y)
Example #54
0
    def get_button_box(self, image):

        button_box = pag.locateOnScreen(image)
        return button_box
Example #55
0
def button3kuda():
    return pyautogui.locateOnScreen('kuda.bmp',
                                    region=(1570, 760, 630, 165),
                                    grayscale=True,
                                    confidence=0.9)
Example #56
0
def check_button(filename):
    _cor = pyautogui.locateOnScreen(
        pre_path + filename, confidence=0.9, grayscale=True)
    return _cor
# In[77]:

while (True):
    # Get current time
    timestr = datetime.now().strftime("%H:%M")

    #Check if the current time is mentioned in the Dataframe containing meeting details
    if timestr in df.Time.values:
        df1 = df[df['Time'].astype(str).str.contains(timestr)]

        #Open the Zoom app
        subprocess.Popen("C:/Users/Malee/AppData/Roaming/Zoom/bin/Zoom.exe")
        time.sleep(5)

        #Locate the position of the join button on the screen
        JoinButtonlocation = pyautogui.locateOnScreen('D:/JOIN_BUTTON1.png')

        #Move the cursor to the position of the button
        pyautogui.moveTo(JoinButtonlocation)

        #Perform click operation
        pyautogui.click()
        time.sleep(2)

        #Write the meeting ID from the dataframe onto the Zoom App
        keyboard.write(df1.iloc[0, 1])

        #For tapping the Turn off video option on Zoom app
        TurnOffVideolocation = pyautogui.locateOnScreen(
            "D:/turn_off_vid_button.png")
        pyautogui.moveTo(TurnOffVideolocation)
Example #58
0
def window1():
    return pyautogui.locateOnScreen('okno.bmp', grayscale=True, confidence=0.9)
Example #59
0
async def main():
    try:
        import pyautogui
        import time
        from random import choice
        import nhentaigen.nhentai_code_generator as nh
        from pyperclip import copy as cpy
        from utils.argparser import get_args
        from utils.read_txt import get_txt, get_copypasta

        pyautogui.FAILSAFE = True
        pyautogui.PAUSE = 0.69

        NHENTAI, TEXT, COPYPASTA = 0, 1, 2

        flags = get_args()
        write_mode = flags['w']

        txt = get_txt(flags['s'])
        copypasta = None
        if not txt:
            copypasta = get_copypasta(flags['s'])

        state = NHENTAI
        if txt:
            state = TEXT
        elif copypasta:
            state = COPYPASTA

        # Initial delay
        time.sleep(flags['i'])

        if state == NHENTAI:
            if not nh.fetch_latest():
                print('Error connecting to nhentai!')
                print('TXT mode')
                path = choice(('./uzumakibayu.txt', './shakespeare.txt',
                               './potterspells.txt'))
                with open(path) as f:
                    txt = f.read().splitlines()

        if flags['l']:
            width, height = pyautogui.size()
            # posx, posy = 0.3140625 * width, 0.95 * height
            loc = pyautogui.locateOnScreen('ss.png', grayscale=True)
            if loc:
                posx, posy = pyautogui.center(loc)
                pyautogui.moveTo(posx, posy)
                pyautogui.click()

        delay = max(50.69, flags['d'])

        ## PLACE CURSOR IN THE TEXT BOX
        async def nh_mode():
            nhcode = nh.valid_url()
            while True:
                s = await nhcode
                if write_mode:
                    pyautogui.write(s, interval=0.1)
                else:
                    cpy(s)
                    await asyncio.sleep(0.69)
                    pyautogui.hotkey('ctrl', 'v', interval=0.15)
                pyautogui.press('enter')
                await asyncio.sleep(1)
                if flags['r']:
                    pyautogui.press('a')
                    pyautogui.press('backspace')
                    pyautogui.press('up')
                    pyautogui.hotkey('ctrl', 'a', interval=0.15)
                    pyautogui.press('backspace')
                    pyautogui.press('enter')
                    await asyncio.sleep(1)
                    pyautogui.press('enter')
                nhcode = asyncio.create_task(nh.valid_url())
                schleep = asyncio.create_task(asyncio.sleep(delay))
                await schleep

        def txt_mode():
            while True:
                s = choice(txt)
                if write_mode:
                    pyautogui.write(s, interval=0.1)
                else:
                    cpy(s)
                    time.sleep(0.69)
                    pyautogui.hotkey('ctrl', 'v', interval=0.15)
                pyautogui.press('enter')
                time.sleep(1)
                if flags['r']:
                    pyautogui.press('a')
                    pyautogui.press('backspace')
                    pyautogui.press('up')
                    pyautogui.hotkey('ctrl', 'a', interval=0.15)
                    pyautogui.press('backspace')
                    pyautogui.press('enter')
                    time.sleep(1)
                    pyautogui.press('enter')
                time.sleep(delay)

        def copypasta_mode():
            while True:
                cpy(copypasta)
                time.sleep(0.69)
                pyautogui.hotkey('ctrl', 'v', interval=0.15)
                pyautogui.press('enter')
                time.sleep(1)
                if flags['r']:
                    pyautogui.press('a')
                    pyautogui.press('backspace')
                    pyautogui.press('up')
                    pyautogui.hotkey('ctrl', 'a', interval=0.15)
                    pyautogui.press('backspace')
                    pyautogui.press('enter')
                    time.sleep(1)
                    pyautogui.press('enter')
                time.sleep(delay)

        if state == TEXT:
            txt_mode()
        elif state == COPYPASTA:
            copypasta_mode()
        elif state == NHENTAI:
            await nh_mode()

    except Exception as e:
        print(e)
Example #60
0
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 10 23:17:40 2017

@author: 毛荳荳
"""

import pyautogui
import time
#getsize
#print(pyautogui.size())
#1600x900

#getposition
while True:
    x, y = pyautogui.position()
    print(x, y)

#chrome位置:741,882
#書籤位置:1437,80
#北京大學網關:1242,425
#登陸按鈕1270,368
#time.sleep(5)
#im = pyautogui.screenshot(region=(900,230, 80, 26))
#print(im)
#pyautogui.screenshot('nctu.png')
x, y, a, b = pyautogui.locateOnScreen(im)
#print(x,y)