示例#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)
示例#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
示例#4
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)
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)
示例#6
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
示例#7
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
示例#8
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
示例#9
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)
示例#10
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)
示例#11
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)
示例#12
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)
示例#13
0
def callsetup():
    # Hangouts rotates through a few lines of text in its search bar
    # any of them coudl be displayed so check them all and click if found
    search_bar_options = [
        image('hangouts-search-2.png'), \
        image('hangouts-search.png')
    ]
    for option in search_bar_options:
        location = pyautogui.locateOnScreen(option)
        if location is None:
            print'Could not find ' + option + ' input area'
            continue
        location_x, location_y = pyautogui.center(location)
        pyautogui.click(location_x, location_y)
        break
    time.sleep(1)
示例#14
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()
示例#15
0
def buscar_app_title():
    msg = ''
    #pyautogui.PAUSE = 0.5
    pyautogui.FAILSAFE = False
    pyperclip.copy('')
    
    findTitle = pyautogui.locateOnScreen('find-app-title.png')
    if findTitle is None:
        msg = 'La opcion LOGIN TO CONSOLE no esta seleccionada'
        return (False, msg)
        #exit(0)
    else:
        titlePos = list(findTitle)
        #print botonStartPos
         
    centroTitle = pyautogui.center(titlePos)     
    #print centroLogin
    pyautogui.moveTo(centroTitle)
    pyautogui.click(None,None,1)
    
    return (True, msg)
示例#16
0
def buscar_app_title():
    msg = ''
    #pyautogui.PAUSE = 0.5
    pyautogui.FAILSAFE = False
    pyperclip.copy('')
    
    findTitle = pyautogui.locateOnScreen('find-app-title.png')
    if findTitle is None:
        msg = 'La opcion MODEMS INFORMATION no fue encontrada...favor de hacer click en la aplicacion...'
        return (False, msg)
        #exit(0)
    else:
        titlePos = list(findTitle)
        #print botonStartPos
         
    centroTitle = pyautogui.center(titlePos)     
    #print centroLogin
    pyautogui.moveTo(centroTitle)
    pyautogui.click(None,None,1)
    
    return (True, msg)
示例#17
0
def buscar_login_console():
    msg = ''
    pyautogui.PAUSE = 0.5
    pyautogui.FAILSAFE = False
    pyperclip.copy('')
    
    findLogin = pyautogui.locateOnScreen('login-console.png')
    if findLogin is None:
        msg = 'La opcion LOGIN TO CONSOLE no esta seleccionada O el programa en LabView no esta corriendo'
        return (False, msg)
        #exit(0)
    else:
        loginPos = list(findLogin)
        #print botonStartPos
         
    centroLogin = pyautogui.center(loginPos)     
    #print centroLogin
    #pyautogui.moveTo(centroLogin)
    #pyautogui.click(None,None,1)
    
    return (True, msg)
def buscar_boton_stop():
    msg = ''
    pyautogui.PAUSE = 0.5
    pyautogui.FAILSAFE = False
    pyperclip.copy('')
    
    dondeEstaElBotonDeStop = pyautogui.locateOnScreen('stop-button.PNG')
    if dondeEstaElBotonDeStop is None:
        msg = 'El boton de STOP no fue encontrado'
        return (False, msg)
        #exit(0)
    else:
        botonStopPos = list(dondeEstaElBotonDeStop)
        #print botonStopPos
         
    centroBotonStop = pyautogui.center(botonStopPos)     
    #print centroBotonStop
    pyautogui.moveTo(centroBotonStop)
    pyautogui.click(None,None,2)
    
    return (True, msg)
示例#19
0
def buscar_boton_go():
    msg = ''
    pyautogui.PAUSE = 0.5
    pyautogui.FAILSAFE = False
    pyperclip.copy('')
    
    dondeEstaElBoton = pyautogui.locateOnScreen('go-button.png')
    if dondeEstaElBoton is None:
        msg = 'El boton de GO no fue encontrado'
        return (False, msg)
        
    else:
        botonPos = list(dondeEstaElBoton)
        #print botonPos
         
    centroBoton = pyautogui.center(botonPos)     
    #print centroBoton
    
    pyautogui.moveTo(centroBoton)
    pyautogui.click()
    
    return (True, msg)
示例#20
0
def fillform():
	time.sleep(2)
	pyautogui.click(579,137)
	pyautogui.typewrite(['down', '\t', '\t'])
	time.sleep(.25)
	pyautogui.typewrite(['down','down', '\t'])

	pyautogui.typewrite(['down','down','down','\t'])

	pyautogui.typewrite(['down','down','down','down', '\t'])

	pyautogui.typewrite('Hello world!')
	pyautogui.typewrite(['enter'])
	pyautogui.typewrite('Hello world!')

	pyautogui.typewrite(['\t'])
	pyautogui.typewrite('Some random Reason', 0.15)


	find = pyautogui.locateOnScreen('btn.png')
	coord = pyautogui.center(find)
	pyautogui.click(coord)
	time.sleep(1)
	pyautogui.typewrite(['enter'])
    def mulligan(self, num, cards = [], choose = False):
        """ 
        Mulligans the selected list of cards. Assumes that the card indices
        start from 1 and are between 3 or 4 (inclusive) depending on the
        number of cards, num, available to mulligan (the parameter num must
        either be 3 or 4.
        """
        cx, cy = p.center( (self.left, self.top, self.width, self.height) )
        
        self.center_line = cy - HS.MAC_HEIGHT_BORDER
        self.endturn = (23.5+1.6)/29.5 * self.width + self.left

        if num == 3:
            inc = 0.2 * self.width
            xstart = cx - inc

        if num == 4:
            xstart = round(8.2/29.5 * self.width)
            inc = 0.15 * self.width

        p.click(self.left + 5, self.top + 5)    # ensure HS is active window
        p.moveTo(xstart, cy)                    # move to start position

        for card_num in cards:
            p.click(xstart + (card_num-1)*inc, cy)        

        if not choose:
            p.click(cx, cy + self.height/4 + HS.CONFIRM_HEIGHT/2)
        
        self.cx = cx
        self.cy = cy

        self.hero_y = self.center_line + self.height/4 + HS.CONFIRM_HEIGHT/2
        self.enemy_y = self.center_line - self.height/4 - HS.CONFIRM_HEIGHT/2

        self.hero_power_xy = (self.cx + 130.0/1280*self.width, self.hero_y)
def pass_search():
    
    msg = ''
    result = False
    clave = ''
    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
    
        clave = pyperclip.paste()
        print clave
        clave = clave.encode('ascii')
        if len(clave) == 10:
            msg = 'clave encontrada'
            #print msg
            result = True
             
            break;
        if contador == 5:
            msg = 'Se hizo el intento 5 veces para buscar la clave' 
            #print msg
            result = False
            break;
        time.sleep(0.5)
    
    return (result, msg, clave)
示例#23
0
def change():
    global pause
    pause = not pause
    print(pause)

keyboard.add_hotkey('page up', lambda: change())
keyboard.add_hotkey('esc', lambda: exit())
while 1:

    
    if pause == True:
        find = pyautogui.locateOnScreen('Assets/find.png',confidence=0.9)

        if find != None:
            find_location = pyautogui.center(find)
            pyautogui.click(x=find_location.x,y=find_location.y)
            sleep(1)
            pyautogui.moveTo(100, 200)
        
        accept = pyautogui.locateOnScreen('Assets/accept.png',confidence=0.9)

        if accept != None:
            accept_location = pyautogui.center(accept)
            pyautogui.click(x=accept_location.x,y=accept_location.y)
            sleep(5)
            pyautogui.moveTo(100, 200)

        _exit = pyautogui.locateOnScreen('Assets/exit.png',confidence=0.9)

        if _exit != None:
示例#24
0
def resetform():
    find = pyautogui.locateOnScreen('reset.png')
    coord = pyautogui.center(find)
    pyautogui.click(coord)
    time.sleep(1)
示例#25
0
    import time
    import pyautogui
except ImportError:
    subprocess.check_call(
        [sys.executable, "-m", "pip", "install", "pyautogui"])
    import pyautogui

message = '''Hi, Hope you are doing great.
I would love to add you in my professional network.
Thank you'''

while True:

    connectbutlocation = pyautogui.locateOnScreen(
        'connectbut.png', confidence=0.8)  #locate the connect button
    connectbutpoint = pyautogui.center(
        connectbutlocation)  #give the co-ordinates to our variable
    pyautogui.click(connectbutpoint)  #click on connect button
    time.sleep(0.2)  #giving the time to browser to letrender the addnote popup
    notebutpoint = pyautogui.locateCenterOnScreen(
        'notebut.png', confidence=0.8)  #locate the add note button
    pyautogui.click(notebutpoint)  #click on add note button button

    pyautogui.write(message)  #to input the designated message

    sendbutpoint = pyautogui.locateCenterOnScreen(
        'sendbut.png', confidence=0.8)  #locate the send invitation button
    pyautogui.click(sendbutpoint)  #click on send invitation button

    time.sleep(
        1
    )  #a one second delay just so that linkedin does not consider you a bot spitting connect requests
 def click_snap(snap_location):
     formx, formy = pya.center(snap_location)
     pya.click(formx, formy)
示例#27
0
文件: pop.py 项目: aqsakhan/games-2
def check_big_button():
    # 出现成就框,自动同意
    location_img = pyautogui.locateOnScreen('agree.png')
    if location_img:
        buttonx, buttony = pyautogui.center(location_img)
        pyautogui.click(buttonx, buttony)
示例#28
0
1. 打开运行窗口 win + r
2. 输入cmd,进入命令行。
3. 输入pip install pyautogui
"""
# 准备一个自动化工具
import pyautogui

# 显示鼠标位置
# pyautogui.displayMousePosition()

# 使用自动化工具的移动功能
# pyautogui.moveTo(x轴坐标,y轴坐标,持续时间)
pyautogui.moveTo(37, 735, 3)  # 移动到酷狗

# # 使用自动化工具的双击功能
pyautogui.doubleClick()  # 打开酷狗

# 等待
pyautogui.sleep(5)
pyautogui.displayMousePosition()
# 1. 截图
# pyautogui.screenshot("play.png", region=(485, 621, 50, 50))

# 2. 定位
button7location = pyautogui.locateOnScreen("play.png")
play_button_point = pyautogui.center(button7location)

# 移动到播放按钮
pyautogui.moveTo(play_button_point.x, play_button_point.y, 3)
pyautogui.click()  # 单击
示例#29
0
def resetform():
	find = pyautogui.locateOnScreen('reset.png')
	coord = pyautogui.center(find)
	pyautogui.click(coord)
	time.sleep(1)	
def center_click(location):
    x, y = pyautogui.center(location)
    pyautogui.click(x, y)
    print('Click ({}, {})'.format(x, y))
    return True
ft_default_im = r'c:\python tem\ft_default.png'
bt_default_im = r'c:\python tem\bt_default.png'
cpicon_num = int(input('please enter control pad ico num:')) - 1
speaker_num = str(
    input(
        'please enter speaker num(1 means fantasia usb speaker,2 means bluetooth speaker):'
    ))
if speaker_num not in ('1', '2'):
    print(
        'please enter the right speaker_num(1 means fantasia usb speaker,2 means bluetooth speaker):'
    )
    sys.exit()
else:
    pyautogui.click(80 + cpicon_num * 62, 1060, button='right')
    time.sleep(0.2)
    x, y = pyautogui.center(pyautogui.locateOnScreen(sound_im))
    pyautogui.click(x, y)
    time.sleep(0.8)
    if speaker_num == '1':
        if pyautogui.locateOnScreen(ft_default_im):
            print('ft_speaker is already the default speaker')
            sys.exit()
        else:
            a, b = pyautogui.center(pyautogui.locateOnScreen(ft_speaker_im))
    else:
        if pyautogui.locateOnScreen(bt_default_im):
            print('bt_speaker is already the default speaker')
            sys.exit()
        else:
            a, b = pyautogui.center(pyautogui.locateOnScreen(bt_speaker_im))
    pyautogui.click(a, b, button='right')
示例#32
0
def moveto(area):
    tmp1 = pag.locateOnScreen(area)
    x, y = pag.center(tmp1)
    pag.moveTo(x, y, duration=0.35)
示例#33
0
def move_and_click(area):
    tmp1 = pag.locateOnScreen(area)
    x, y = pag.center(tmp1)
    pag.moveTo(x, y, duration=0.35)
    time.sleep(0.5)
    pag.click()
示例#34
0
#Ask for the desired Properties
mesh = input('Enter the value of mesh size (in m): ')
#Do this for a certain amount of time (8 hours)
timeout = time.time() + 8 * 60 * 60
while True:
    if time.time() > timeout:
        break
    image = pag.screenshot("ss.png")
    image = cv2.imread("ss.png")
    #cv2.imshow("Screenshot", imutils.resize(image, width = 400))
    #cv2.waitKey(0)
    logoLocation = pag.locateOnScreen('logo.png', confidence=0.9)
    if logoLocation != None:
        #save as new project
        newLocation = pag.locateOnScreen('new.png', confidence=0.9)
        newPoint = pag.center(newLocation)
        pag.moveTo(newPoint)
        pag.click()
        time.sleep(2)
        dt = datetime.now().strftime("%H%M%S_%d%m")
        newLocation = pag.locateOnScreen('name.png', confidence=0.9)
        newPoint = pag.center(newLocation)
        pag.moveTo(newPoint)
        pag.click()
        pag.write("Snow Explosion_" + dt)
        time.sleep(1)
        newLocation = pag.locateOnScreen('save.png', confidence=0.9)
        newPoint = pag.center(newLocation)
        pag.moveTo(newPoint)
        pag.click()
        time.sleep(10)
示例#35
0
import pyautogui

button = pyautogui.locateOnScreen('cancel.png')
cords = pyautogui.center(button)
pyautogui.click(cords)
示例#36
0
import pyautogui, time
print('Press Ctrl-C to quit.')
time.sleep(2)
pyautogui.click(586, 323)
pyautogui.typewrite('Hello world!', 0.25)
pyautogui.typewrite(['enter'])
pyautogui.typewrite(['a', 'b', 'left', 'left', 'X', 'Y'])
pyautogui.tripleClick()
#pyautogui.typewrite(['volumemute'])
find = pyautogui.locateOnScreen('btn.png')
coord = pyautogui.center(find)
pyautogui.click(coord)
示例#37
0
def copy(img):
    location = gui.locateOnScreen(img)
    center = gui.center(location)
    return center
示例#38
0
import pyautogui as pag
import time

if __name__ == '__main__':
    # 크롬 이미지 인식하자
    data = pag.locateOnScreen("크롬.PNG")
    print(data)
    # 가운데 좌표 찾자
    center = pag.center(data)
    # 마우스 이동하자
    pag.moveTo(center, duration=2)
    # 더블클릭하자
    pag.doubleClick()
def reservation():
    T = 0
    while T < 2:
        pingmu_X = win32api.GetSystemMetrics(0)
        pingmu_Y = win32api.GetSystemMetrics(1)

        def move_click(x, y, t=0):
            win32api.SetCursorPos((x, y))
            win32api.mouse_event(
                win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTUP, x,
                y, 0, 0)
            if t == 0:
                time.sleep(random.random() * 2 + 1)
            else:
                time.sleep(t)
            return 0

        AppName = '微信'
        hwnd1 = win32gui.FindWindow("WeChatMainWndForPC", AppName)
        time.sleep(0.8)
        win32gui.ShowWindow(hwnd1, win32con.SW_MAXIMIZE)
        time.sleep(1)
        try:
            cposition = pyautogui.locateOnScreen('gongzhonghao.png')
            cc = pyautogui.center(cposition)
            pyautogui.moveTo(cc[0], cc[1])
            pyautogui.click(clicks=1)
        except:
            move_click(int(pingmu_X / 7), int(pingmu_Y / 7), 1)
            time.sleep(0.1)
            move_click(int(pingmu_X / 7), int(pingmu_Y / 7), 1)
        try:
            cposition = pyautogui.locateOnScreen('zuowei.png')
            cc = pyautogui.center(cposition)
            pyautogui.moveTo(cc[0], cc[1])
            pyautogui.click(clicks=1)
        except:
            move_click(int(pingmu_X / 2.3), int(pingmu_Y / 1.1), 2)
            time.sleep(1)
        hwnd2 = win32gui.FindWindow(None, AppName)
        win32gui.SetWindowPos(hwnd2, win32con.HWND_TOPMOST, 0, 0,
                              int(pingmu_X / 3), int(pingmu_Y / 1.1),
                              win32con.SWP_SHOWWINDOW)
        time.sleep(2)
        try:
            cposition = pyautogui.locateOnScreen('zuoweibiaozhi.png')
            cc = pyautogui.center(cposition)
            pyautogui.moveTo(cc[0] - int(pingmu_X / 4.5), cc[1])
            pyautogui.click(clicks=1)
            time.sleep(3)
            pyautogui.moveTo(cc[0] - int(pingmu_X / 11), cc[1])
            pyautogui.click(clicks=1)
            time.sleep(3)
        except:
            time.sleep(4)
            try:
                cposition = pyautogui.locateOnScreen('zuoweibiaozhi.png')
                cc = pyautogui.center(cposition)
                pyautogui.moveTo(cc[0] - int(pingmu_X / 4.5), cc[1])
                pyautogui.click(clicks=1)
                time.sleep(3)
                pyautogui.moveTo(cc[0] - int(pingmu_X / 11), cc[1])
                pyautogui.click(clicks=1)
                time.sleep(3)
            except:
                try:
                    cposition = pyautogui.locateOnScreen('changyongzuowei.png')
                    cc = pyautogui.center(cposition)
                    pyautogui.moveTo(cc[0] - int(pingmu_X / 11),
                                     cc[1] + int(pingmu_Y / 1.9))
                    pyautogui.click(clicks=1)
                    time.sleep(3)
                    pyautogui.moveTo(cc[0] + int(pingmu_X / 13),
                                     cc[1] + int(pingmu_Y / 1.9))
                    pyautogui.click(clicks=1)
                    time.sleep(3)
                except:
                    move_click(int(pingmu_X / 11), int(pingmu_Y / 1.7), 3)
                    move_click(int(pingmu_X / 4.6), int(pingmu_Y / 1.7), 3)
        try:
            cposition = pyautogui.locateOnScreen('qiandao.png')
            cc = pyautogui.center(cposition)[0]
            win32gui.PostMessage(hwnd1, win32con.WM_CLOSE, 0, 0)
            win32gui.PostMessage(hwnd2, win32con.WM_CLOSE, 0, 0)
            T += 2
        except:
            pass
        win32gui.PostMessage(hwnd1, win32con.WM_CLOSE, 0, 0)
        win32gui.PostMessage(hwnd2, win32con.WM_CLOSE, 0, 0)
        T += 1
import pyautogui as pg
import time

pg.PAUSE = 2
pg.FAILSAFE = True

pg.hotkey('command', 'space')
time.sleep(2)
pg.typewrite('chrome', interval=0.2)
pg.hotkey('enter')
pos = pg.locateOnScreen(r'/Users/vish/Desktop/searchbar.png')
x, y = pg.center(pos)
pg.moveTo(x, y, duration=2)
pg.click(x, y)
time.sleep(40)
pg.typewrite('http://180.211.119.163:8081/PUMIS/', interval=0.1)
pg.hotkey('enter')
pos = pg.locateOnScreen(r'/Users/vish/Desktop/student.png')
x, y = pg.center(pos)
pg.moveTo(x, y, duration=2)
pg.click(x, y)
time.sleep(20)
pg.typewrite('150303105087', interval=0.5)
pg.hotkey('tab')
pg.typewrite('*****', interval=0.5)
pg.hotkey('enter')
time.sleep(20)
pos = pg.locateOnScreen(r'/Users/vish/Desktop/academic.png')
x, y = pg.center(pos)
pg.moveTo(x, y, duration=2)
pos = pg.locateOnScreen(r'/Users/vish/Desktop/attend.png')
示例#41
0
#/usr/bin/env python
# _*_ coding:utf-8 _*_
import pyautogui
import time

# 鼠标光标在屏幕左上角,PyAutoGUI函数就会产生pyautogui.FailSafeException异常
pyautogui.FAILSAFE = True
# 可以为所有的PyAutoGUI函数增加延迟
pyautogui.PAUSE = 0.4

x, y = pyautogui.center((16, 448, 191, 21))
pyautogui.click(x, y)
# pyautogui.click( x=87, y=456, button='left' )
x, y = pyautogui.center((43, 585, 87, 15))
pyautogui.click(x, y)
# pyautogui.click( x=76, y=593, button='left' )
for yeshu in range(12, 14):
    for num in range(1, 105):
        #回退的地方
        x, y = pyautogui.center((256, 316, 107, 21))  # 获得中心点
        pyautogui.click(x, y)
        # pyautogui.click(x=321, y=321, button='left')
        pyautogui.click(x=279, y=927, button='left')
        pyautogui.click(x=262, y=424, button='left')
        hangshu = 1
        while hangshu < yeshu:
            pyautogui.click(x=581, y=424, button='left')
            hangshu += 1
        #第35个开始就从最后开始
        if 69 > num > 34:
            num = num - 35
示例#42
0
def imgSearchClick(p_imgName):
    v_imgLocation = pa.locateOnScreen(p_imgName)
    imgLocationX, imgLocationY = pa.center(v_imgLocation)
    pa.click(imgLocationX, imgLocationY, interval=0.5, pause=0.5)
示例#43
0
import pyautogui,PIL,pytesseract
import time
#time.sleep(1)
#print(pyautogui.position())
#im = pyautogui.screenshot("GUANBI.png",region=(91,660,160,60))

#print(im)

#button7location = pyautogui.locateOnScreen('1.png')
#print(button7location)
#buttonBlevelcenter = pyautogui.center(button7location)

#
boss = pyautogui.locateOnScreen("C:\\Users\\大胆的豌豆\\boss.PNG")

bossS = pyautogui.center(boss)
skipS =  (bossS.x+216,bossS.y+100)
closeS = (bossS.x,bossS.y+100)

pytesseract.pytesseract.tesseract_cmd = r'D:\Program Files\Tesseract-OCR\tesseract.exe'
print(bossS)
n=0
bossn = 0
y=0
NG=0
url = "C:\\Users\\大胆的豌豆\\textpic.png"
list = []
while True:
    textpic = pyautogui.screenshot(url,region=(bossS.x-79,bossS.y-227, 169, 30))
    textpic = PIL.Image.open(url).convert("L")
    textpic.save("textpic.png")
示例#44
0
import pyautogui

_cor = pyautogui.locateOnScreen('complete.png',
                                confidence=0.35,
                                grayscale=True)
x, y = pyautogui.center(_cor)

print(_cor)
示例#45
0
import pyautogui
from time import sleep


def operation():
    pyautogui.press('down')
    sleep(0.31)
    pyautogui.press('up')


basePoint = pyautogui.locateOnScreen('img/base_point.png',
                                     grayscale=True,
                                     confidence=0.980)
cBasePoint = pyautogui.center(basePoint)
print("見つけました")
level = 0.95
Lx = cBasePoint[0] + 900
Ly = cBasePoint[1] + 240
Rx = 1270
Ry = 430
range_list = [
    440,
    410,
    410,
    410,
    440,
    440,
    440,
]
level_list = [
    0.94,
#Compiles queue changes needed into a dictionary data structure for use later
with open('audit.csv') as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=',')
    for row in csv_reader:
        change_list.append(row)

del change_list[0]

for list in change_list:
    try:
        change_dict[list[0]].update({list[1]: (list[2], list[3])})
    except KeyError:
        change_dict[list[0]] = {list[1]: (list[2], list[3])}

pad.click(pad.center(pad.locateOnScreen('search.png')))

for extension in change_dict:

    while True:

        try:

            pad.typewrite(extension)
            time.sleep(SLEEP)
            pad.click(pad.center(pad.locateOnScreen('at.png')))
            time.sleep(SLEEP)
            pad.click(pad.center(pad.locateOnScreen('attributes.png')))
            time.sleep(SLEEP)
            pad.click(pad.center(pad.locateOnScreen('add.png')))
            time.sleep(SLEEP)
示例#47
0
import pyautogui
from pywinauto import Application
import time
# print(pyautogui.position())

kakao = pyautogui.locateOnScreen(
    'C:/Users/qodls/PycharmProjects/auto/data/kakao.png', confidence=0.5)
center_kko = pyautogui.center(kakao)
pyautogui.moveTo(center_kko[0], center_kko[1])
pyautogui.doubleClick()
time.sleep(1.5)

finder = pyautogui.locateOnScreen(
    'C:/Users/qodls/PycharmProjects/auto/data/finder.png', confidence=0.6)
profile = pyautogui.locateOnScreen(
    'C:/Users/qodls/PycharmProjects/auto/data/profile.png', confidence=0.6)

center_find = pyautogui.center(finder)
center_pro = pyautogui.center(profile)

partner = pyautogui.prompt("choose your partner")

app = Application().start("C:/Windows/system32/notepad.exe")
app.UntitledNotepad.Edit.type_keys(partner, with_spaces=True)
file = pyautogui.locateOnScreen(
    'C:/Users/qodls/PycharmProjects/auto/data/file.png', confidence=0.6)
center_file = pyautogui.center(file)
pyautogui.moveTo(center_file[0], center_file[1])
pyautogui.moveRel(None, 20)
pyautogui.doubleClick()
pyautogui.hotkey('ctrl', 'c')
示例#48
0
    x -= 1
pyautogui.click(773, 1051)
random_key = ['w', 'a', 's', 'd']

pyautogui.hotkey('enter')
pyautogui.hotkey('enter')
pyautogui.hotkey('e')
while True:
    name_box = pyautogui.locateOnScreen('name box.png', confidence=0.7)
    if name_box is None:
        square1 = pyautogui.locateAllOnScreen('square1.png', confidence=0.7)
        square = list(square1)
        print(len(square))
        if len(square) != 0:
            for i in square:
                pyautogui.moveTo(pyautogui.center(i))
        else:
            x = choice(random_key)
            y = choice(random_key)
            z = choice(random_key)
            a = choice(random_key)
            pyautogui.keyDown(x, 2)
            pyautogui.keyDown(y, 2)
            pyautogui.keyDown(z, 3)
            pyautogui.keyDown(a, 2)
            pyautogui.keyUp(x)
            pyautogui.keyUp(y)
            pyautogui.keyUp(z)
            pyautogui.keyUp(a)
    else:
        pyautogui.hotkey('enter')
示例#49
0
(action.send_keys(customer_num[0]).key_down(Keys.TAB).key_down(
    Keys.TAB).key_down(Keys.TAB).key_down(Keys.TAB).key_down(
        Keys.TAB).key_down(Keys.TAB).key_down(Keys.TAB).key_down(
            Keys.TAB).key_down(Keys.TAB).key_down(Keys.TAB).key_down(
                Keys.TAB).key_down(Keys.TAB).send_keys(cus_name).key_down(
                    Keys.TAB).key_down(Keys.TAB).send_keys(id_num).perform())

# .pause(1).key_down(Keys.TAB).key_down(Keys.TAB).send_keys(id_num[0])
# .perform())

#신청인 정보 버튼 클릭 매크로 3단계
Win = win.getWindowsWithTitle('PyCharm')[0]
Win.activate()

a = gui.locateOnScreen('combo1.png')
center1 = gui.center(a)
print(center1)
gui.click(center1.x - 89, center1.y)

Win = win.getWindowsWithTitle('PyCharm')[0]
Win.activate()

b = gui.locateOnScreen('combo2.png')
center2 = gui.center(b)
print(center2)
gui.click(center2.x - 119, center2.y)

Win = win.getWindowsWithTitle('PyCharm')[0]
Win.activate()

c = gui.locateOnScreen('print.png')
示例#50
0
import pyautogui, time

pyautogui.FAILSAFE = True

loc = pyautogui.locateOnScreen('box.png')
while loc == None:
    time.sleep(0.1)
    loc = pyautogui.locateOnScreen('box.png')

for loc_i in pyautogui.locateAllOnScreen('box.png'):
    print(loc_i)
    center = pyautogui.center(loc_i)
    pyautogui.click(center)
示例#51
0
import pyautogui
import time
# from PIL import Image
time.sleep(5)
addButtonImg = pyautogui.screenshot(imageFilename='images/add_button.png',
                                    region=(0, 0, 570, 100))
# addButtonImg.save('images/add_button.png')

coords = pyautogui.locateOnScreen('images/add_button.png')
x, y = pyautogui.center(coords)
print(x, y)
示例#52
0
#Enter time.
ttr_minutes = pyautogui.prompt('Enter Total Run Time in Minutes. Only use whole numbers.')

#Convert to Seconds
ttr_seconds = int(ttr_minutes)*60


# Start clock
for t in range(ttr_seconds,-1,-1):
    minutes = t / 60
    seconds = t % 60
    print "%d:%2d" % (minutes,seconds) # Python v2 only
    time.sleep(1.0)

#SCREESHOTS - find and click - end capture OR Grab window and hit 'ESC" key to end.
#!! pyautogui.press('esc')

button_location = pyautogui.locateOnScreen('capture.png')

bx, by = pyautogui.center(button_location)


pyautogui.click(bx, by) # Click Button


# ALERT
pyautogui.alert('Your Capture has finished.')
print('DONE! - Click - <Your Capture has finished> Window')


示例#53
0
import pyautogui

iconW = 106
iconH = 130
xGap = 14
yGap = 18
miniW, miniH = (92, 75)

try:
    noxApp = pyautogui.locateOnScreen('NoxLogo.PNG')
    noxPoint = pyautogui.center(noxApp)
    pyautogui.click(noxPoint.x, noxPoint.y)
    xo = noxApp.left + 1284 - 586
    yo = noxApp.top + noxApp.height + 198
    xi, yi = (xo, yo)
    borderSide, borderTop = (7, 21)
    index = 0
    for y in range(0, 2):
        if y == 1:
            yi = yi + iconH + yGap
            iconH = 129
            borderTop = 20
        for x in range(0, 4):

            if x > 0:
                xi = xi + iconW + xGap
            else:
                xi = xo

            if x == 1 or x == 2:
                iconW = 105
示例#54
0
import pyautogui
import time
print "comfirm1"
while True:
    try:
        confirm = pyautogui.locateOnScreen(
            r'D:/Zhe sean/Desktop/hello/img/confirm.png')
        if confirm is not None:
            print "comfirming1"
            x, y = pyautogui.center(comfirm)
            pyautogui.click(x, y)
    except:
        pass
示例#55
0
print(firma20)
print(firma21)
print(firma22)
print(firma23)
print(firma24)

# images = driver.find_elements_by_tag_name('img')
#
# for image in images:
#     print(image.get_attribute('src'))

# driver.find_element_by_xpath('//*[@id="c68651"]/div[3]/div[9]/div/div[3]/a/img').click()
os.chdir()

button = pyautogui.locateOnScreen('arrow_black_right.png')
buttonx, buttony = pyautogui.center(button)
pyautogui.click(buttonx, buttony)

# pyautogui.moveTo(897, 880, 2, pyautogui.easeInQuad)
# pyautogui.click(x=897, y=880)

# from pymongo import MongoClient
# client = MongoClient("192.168.100.5", 27017, maxPoolSize=50)
# db = client['yanghi']  # mz durch die entsprechende Datenbank ersetzen
# collection = db['zveh']  # db durch entsprechende DB ersetzen
# collection.insert_one(firma)
# collection.insert_one(firma2)
# collection.insert_one(firma3)
# collection.insert_one(firma4)
# collection.insert_one(firma5)
# collection.insert_one(firma6)
示例#56
0
import pyautogui
import time

time.sleep(2)

pyautogui.click(button='right')

# numberCentre = pyautogui.center(pyautogui.locateOnScreen('notes.jpg'))
location = pyautogui.locateOnScreen('note.jpg')
print(location)
location1 = pyautogui.center(location)
print(location1)
pyautogui.click(location1)
"""头都大了还是不对"""
示例#57
0
    )
    time.sleep(60)
else:
    pg.getWindowsWithTitle(
        "Cherwell Service Management (licensed to Sutter Health)")[0].minimize(
        )
    pg.getWindowsWithTitle(
        "Cherwell Service Management (licensed to Sutter Health)")[0].maximize(
        )
    time.sleep(1)

# Open the CAB Report
cabreportbutton = pg.locateOnScreen('screenshots\cabreport.png',
                                    confidence=0.8,
                                    region=(700, 70, 300, 50))
button_x, button_y = pg.center(cabreportbutton)
pg.click(button_x, button_y)
time.sleep(3)

# Export the report as-is FINISHED
print('Running Hotkeys')
time.sleep(5)
pg.hotkey('Alt', 'f')
pg.press(['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Enter'])
pg.write('I:\CM\CAB.csv')
pg.press(['Tab', 'Tab', 'Tab', 'Tab', 'Tab', 'Tab', 'Space', 'Tab', 'Enter'])
pg.press('Enter')

# Pull CSV into DataFrame
print('Opening CSV')
time.sleep(5)
示例#58
0
文件: foe_auto.py 项目: GLMF/GLMF187
if __name__ == '__main__':
    region = {}
    units = ('tanneur', 'chevrier_1', 'chevrier_2', 'forgeron', 'fruitier')
    prod = { 'tanneur' : 'peau de chèvre', 'chevrier_1' : '1/6 fromage',
             'chevrier_2' : '1/6 fromage', 'forgeron' : 'fer à cheval',
             'fruitier' : 'choux'
           }

    while True:
        for unit in units:
            detect_state(unit, region)

        for key in region:
            if region[key] is not None:
                pyautogui.moveTo(pyautogui.center(region[key]))
                pyautogui.moveRel(None, 10)
                clickAndForget()
                region[key] = None
                if key.endswith('_ready'):
                    unit = key.split('_ready')[0]
                    print('[{} / {}] Récupération ressources'.format(time.strftime('%H:%M:%S'),
                                                                     unit))
                elif key.endswith('_wait'):
                    unit = key.split('_wait')[0]
                    print('[{} / {}] Ordre de fabrication'.format(time.strftime('%H:%M:%S'),
                                                                  unit))
                    region_2 = None
                    while region_2 is None:
                        unitType = unit.split('_')[0]
                        region_2 = pyautogui.locateOnScreen('images/' + unitType +'_prod.png')
示例#59
0
try:
    username_element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.NAME, 'email')))
    password_element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.NAME, 'password')))
    submit_element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, '//input[@type="submit" and @value="登录"]')))
    username_element.send_keys('test')
    password_element.send_keys('test')
    submit_element.click()
    # print(driver.page_source)

    loveTree_element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.NAME, '情侣树')))
    loveTree_element.click()
    time.sleep(3)
    print('start to locate')
    water_location = pyautogui.locateOnScreen('./img/water.png')
    print(water_location)
    flower_location = pyautogui.locateOnScreen('./img/flower.png')
    print(flower_location)

    pyautogui.click(pyautogui.center(water_location))
    time.sleep(3)
    pyautogui.click(pyautogui.center(water_location))
    time.sleep(3)
    pyautogui.click(pyautogui.center(flower_location))
    time.sleep(3)
    pyautogui.click(pyautogui.center(flower_location))
except Exception as e:
    print(e)
finally:
    driver.close()
    driver.quit()