Ejemplo n.º 1
3
def temp():
    pyautogui.alert('This displays some text with an OK button.')
    pyautogui.position()  # current mouse x and y
    pyautogui.onScreen(x, y)  # True if x & y are within the screen.
    pyautogui.PAUSE = 2.5   # Pause 2.5 s
    pyautogui.dragTo(x, y, duration=num_seconds)  # drag mouse to XY
    pyautogui.dragRel(xOffset, yOffset, duration=num_seconds)  # drag mouse relative to its current position
    pyautogui.click(x=moveToX, y=moveToY, clicks=num_of_clicks, interval=secs_between_clicks, button='left') # The button keyword argument can be 'left', 'middle', or 'right'.
    pyautogui.scroll(amount_to_scroll, x=moveToX, y=moveToY)
    pyautogui.mouseDown(x=moveToX, y=moveToY, button='left')
    pyautogui.mouseUp(x=moveToX, y=moveToY, button='left')
    pyautogui.typewrite('Hello world!\n', interval=secs_between_keys)  # useful for entering text, newline is Enter
    pyautogui.typewrite(['a', 'b', 'c', 'left', 'backspace', 'enter', 'f1'], interval=secs_between_keys)
    pyautogui.hotkey('ctrl', 'c')  # ctrl-c to copy
    pyautogui.hotkey('ctrl', 'v')  # ctrl-v to paste
    pyautogui.alert('This displays some text with an OK button.')
    pyautogui.confirm('This displays text and has an OK and Cancel button.')
    pyautogui.prompt('This lets the user type in a string and press OK.')
    pyautogui.screenshot('foo.png')  # returns a Pillow/PIL Image object, and saves it to a file
    pyautogui.locateOnScreen('looksLikeThis.png')
    pyautogui.locateCenterOnScreen('looksLikeThis.png')  # returns center x and y
Ejemplo n.º 2
1
def logout():
	
	pyautogui.click(820,730)
	time.sleep(0.5)
	pyautogui.click(830,50)
	time.sleep(0.5)
	pyautogui.moveTo(820,600)
	for i in range(15):
		pyautogui.scroll(-10)
	pyautogui.click(820,680)
	time.sleep(0.5)
	pyautogui.click(700,420)
	time.sleep(5)
Ejemplo n.º 3
0
def scrollPage (**options):

    displayMagnification = 2 if sysvar_ratina == True else 1
    pyautogui.moveTo((options.get('top')/displayMagnification) + (options.get('width')/(displayMagnification*2)),
                     (options.get('left')/displayMagnification) + (options.get('height')/(displayMagnification*2)),
                     2)
    pyautogui.click()
    pyautogui.scroll(options.get('scroll'))
Ejemplo n.º 4
0
 def test_scroll(self):
     # TODO - currently this just checks that scrolling doesn't result in an error.
     pyautogui.scroll(1)
     pyautogui.scroll(-1)
     pyautogui.hscroll(1)
     pyautogui.hscroll(-1)
     pyautogui.vscroll(1)
     pyautogui.vscroll(-1)
def web_control():
    x,y=1628, 546
    time.sleep(3)
    n=0
    print(pag.position())
    while n <30:
        for _ in range(15):
            pag.scroll(-500)
            time.sleep(1.1)
        time.sleep(1.5)
        pag.click(x,y)
        time.sleep(3)
Ejemplo n.º 6
0
	def onClick(self, mouse_button):
		if mouse_button == 4: #scroll up
			prev = pyautogui.position()
			pyautogui.moveTo(0, pyautogui.size()[1], pause=False)
			pyautogui.scroll(1)
			pyautogui.moveTo(*prev, pause=False)
		elif mouse_button == 5: #scroll dn
			prev = pyautogui.position()
			pyautogui.moveTo(0, pyautogui.size()[1], pause=False)
			pyautogui.scroll(-1)
			pyautogui.moveTo(*prev, pause=False)
		else: #do nothing
			pass
Ejemplo n.º 7
0
def on_imu(data):
    """
    Process the IMU data to move the mouse around the screen.
    :param data: a dictionary containing information from the IMU sensor
    :return: Nothing
    """

    # Declare some variables for ease of reading
    pitch = float(data['IMU_PITCH_FILTERED'])  # Translate in a displacement on Y axis
    roll = float(data['IMU_ROLL_FILTERED'])  # Translate in a displacement on X axis

    x = 60 * (roll / 180)
    y = 60 * (pitch / 180)

    # Move the mouse on the screen
    pyautogui.scroll(x)
    pyautogui.hscroll(y)
Ejemplo n.º 8
0
 def do_it(self):
     while True:
         try:
             try:
                 body = self.INPUT_Q.get_nowait()
             except:
                 body = None
             if body != None:
                 head = body[:4]
                 body = body[4:]
                 if head == 'MOUS' and self.mous_press == False:
                     mxy = body.split('|')
                     self.mous.move(int(mxy[0]),int(mxy[1]))
                     #pyautogui.moveTo(int(mxy[0]),int(mxy[1]))
                 elif head == 'MCLK' or self.mous_press == True:
                     mxy = body.split('|')
                     if mxy[2] == 'DOWN':
                         if mxy[3] == '1':
                             pyautogui.mouseDown(int(mxy[0]),int(mxy[1]),button='left')
                         elif mxy[3] == '3':
                             pyautogui.mouseDown(int(mxy[0]),int(mxy[1]),button='right')
                         else:
                             pyautogui.scroll(5,x=int(mxy[0]),y=int(mxy[1]))
                     else:
                         self.mous_press = False
                         if mxy[3] == '1':
                             pyautogui.mouseUp(int(mxy[0]),int(mxy[1]),button='left')
                         elif mxy[3] == '3':
                             pyautogui.mouseUp(int(mxy[0]),int(mxy[1]),button='right')
                         else:
                             pyautogui.scroll(-5,x=int(mxy[0]),y=int(mxy[1]))
                 elif head == "KCLK":
                     key_ev = body.split('|')
                     if key_ev[0] == 'DOWN':
                         pyautogui.keyDown(key_ev[1])
                     elif key_ev[0] == "UP":
                         pyautogui.keyUp(key_ev[1])
         except Exception as e:
             print "INPUT CONTROL ERROR",e
Ejemplo n.º 9
0
def main():
    # For interrupting
    pyautogui.PAUSE = 1
    pyautogui.FAILSAFE = True

    # Parse cl arguments
    parser=argparse.ArgumentParser()
    parser.add_argument('entries', type=int, help="Number of entries to delete")
    args = parser.parse_args()

    pyautogui.scroll(3000)
    pyautogui.click(POSITION)

    for i in range(args.entries):
        pyautogui.typewrite('\n', 0.1)
        pyautogui.hotkey('alt','8')
        time.sleep(0.1)

    print("Saving...")
    pyautogui.click(SAVEPOSITION)
    time.sleep(2)
    print("All done!")
    return 0
Ejemplo n.º 10
0
    def test_auto_gui(self):
        if self.cmd_switch:
            # Drag mouse to control some object on screen (such as google map at webpage)
            distance = 100.
            while distance > 0:
                pyautogui.dragRel(distance, 0, duration=2, button='left')    # move right
                distance -= 25
                pyautogui.dragRel(0, distance, duration=2, button='left')    # move down
                distance -= 25
                pyautogui.dragRel(-distance, 0, duration=2, button='left')    # move right
                distance -= 25
                pyautogui.dragRel(0, -distance, duration=2, button='left')    # move down
                distance -= 25

            # scroll mouse wheel (zoom in and zoom out google map)
            pyautogui.scroll(10, pause=1.)
            pyautogui.scroll(-10, pause=1)

            pyautogui.scroll(10, pause=1.)
            pyautogui.scroll(-10, pause=1)

            # message box
            pyautogui.alert(text='pyautogui testing over, click ok to end', title='Alert', button='OK')
            self.cmd_switch = not self.cmd_switch   # turn off
Ejemplo n.º 11
0
def scrollToNextBubble(buttonLocation):
    logging.info("Scrolling to next button")
    scroll = int(-(buttonLocation[0] + buttonLocation[1] - 150))
    logging.debug("Bubble scroll = " + str(scroll))
    pyautogui.scroll(scroll, x=1000, y=1000)
Ejemplo n.º 12
0
# ch28_16.py
import pyautogui
import time

for i in range(1,10):
    pyautogui.scroll(30)    # 往上捲動      
    time.sleep(1)
    pyautogui.scroll(-30)   # 往下捲動
    time.sleep(1)






Ejemplo n.º 13
0
def performAction(yp, rc, bc, action, drag, perform):
    if perform:
        cursor[0] = 4 * (yp[0] - 110)
        cursor[1] = 4 * (yp[1] - 120)
        if action == 'move':

            if yp[0] > 110 and yp[0] < 590 and yp[1] > 120 and yp[1] < 390:
                pyautogui.moveTo(cursor[0], cursor[1])
            elif yp[0] < 110 and yp[1] > 120 and yp[1] < 390:
                pyautogui.moveTo(8, cursor[1])
            elif yp[0] > 590 and yp[1] > 120 and yp[1] < 390:
                pyautogui.moveTo(1912, cursor[1])
            elif yp[0] > 110 and yp[0] < 590 and yp[1] < 120:
                pyautogui.moveTo(cursor[0], 8)
            elif yp[0] > 110 and yp[0] < 590 and yp[1] > 390:
                pyautogui.moveTo(cursor[0], 1072)
            elif yp[0] < 110 and yp[1] < 120:
                pyautogui.moveTo(8, 8)
            elif yp[0] < 110 and yp[1] > 390:
                pyautogui.moveTo(8, 1072)
            elif yp[0] > 590 and yp[1] > 390:
                pyautogui.moveTo(1912, 1072)
            else:
                pyautogui.moveTo(1912, 8)

        elif action == 'left':
            pyautogui.click(button='left')

        elif action == 'right':
            pyautogui.click(button='right')
            time.sleep(0.3)

        elif action == 'up':
            pyautogui.scroll(5)
#			time.sleep(0.3)

        elif action == 'down':
            pyautogui.scroll(-5)


#			time.sleep(0.3)

        elif action == 'drag' and drag == 'true':
            global y_pos
            drag = 'false'
            pyautogui.mouseDown()

            while (1):

                k = cv2.waitKey(10) & 0xFF
                changeStatus(k)

                _, frameinv = cap.read()
                # flip horizontaly to get mirror image in camera
                frame = cv2.flip(frameinv, 1)

                hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

                b_mask = makeMask(hsv, blue_range)
                r_mask = makeMask(hsv, red_range)
                y_mask = makeMask(hsv, yellow_range)

                py_pos = y_pos

                b_cen = drawCentroid(frame, b_area, b_mask, showCentroid)
                r_cen = drawCentroid(frame, r_area, r_mask, showCentroid)
                y_cen = drawCentroid(frame, y_area, y_mask, showCentroid)

                if py_pos[0] != -1 and y_cen[0] != -1:
                    y_pos = setCursorPos(y_cen, py_pos)

                performAction(y_pos, r_cen, b_cen, 'move', drag, perform)
                cv2.imshow('Frame', frame)

                if distance(y_pos, r_cen) > 60 or distance(
                        y_pos, b_cen) > 60 or distance(r_cen, b_cen) > 60:
                    break

            pyautogui.mouseUp()
Ejemplo n.º 14
0
"""
Author: Kristian Saure Knotten
Student ID: 8284
E-mail: [email protected]
"""

import pyautogui


pyautogui.scroll(200)

import pyperclip
import pyautogui, time
numbers = ''
for index in range(200):
    numbers += str(index) + '\n'
print(pyperclip.copy(numbers))

time.sleep(2);
print(pyautogui.scroll(200))
Ejemplo n.º 16
0
		else:
			print('Click Invoked')
			#if len(pointsClicked) <= cursorDoubleClick:
			pyautogui.click()
			pointsClicked.append(pyautogui.position())
			spaceCount = 0
		#If the cursor is near a scroll bar, then scroll, up or down
		scrollUpLoc = pyautogui.locateOnScreen('scrollUp.png')
		print('scrollUpLoc' + str(scrollUpLoc))
		scrollDownLoc = pyautogui.locateOnScreen('scrollDown.png')
		print('scrollDownLoc' + str(scrollDownLoc))
		x, y = pyautogui.position()
		if (scrollUpLoc != None):
			if (x > (scrollUpLoc[0] - 5) and x < (scrollUpLoc[0] + scrollUpLoc[2] + 5) and y > (scrollUpLoc[1] - 5) and y < (scrollUpLoc[1] + scrollUpLoc [3] + 5)):
				print ("Implement scroll up")
				pyautogui.scroll(5)
				print("Scrolled up")
		if (scrollDownLoc != None):
			if (x > (scrollDownLoc[0] - 5) and x < (scrollDownLoc[0] + scrollDownLoc[2] + 5) and y > (scrollDownLoc[1] - 5) and y < (scrollDownLoc[1] + scrollDownLoc [3] + 5)):
				print ("Implement scroll down")
				pyautogui.scroll(5)
				print("Scrolled down")
#        print 'Point Clicked'
#        print pointsClicked[0][0]
#        print pointsClicked[0][1]
#        else:
#            prevClickPos = len(pointsClicked) - 1
#            #print prevClickPos
#            for k in range ((prevClickPos - cursorDoubleClick), prevClickPos):
#                lowClickBound1 = (pointsClicked[prevClickPos - cursorDoubleClick][0])-maxClickMovement
#                lowClickBound2 = (pointsClicked[prevClickPos - cursorDoubleClick][1])-maxClickMovement
Ejemplo n.º 17
0
 def checkStore(self):
     """ Takes ss of all possible 16 items in a shop.
     If there are less, redudant screenshots will be created,
     which will have to be thrown away later."""
     img = self.checkItem(300, 230)
     self.saveImgToUniqueFilename(img)
     img = self.checkItem(300, 270)
     self.saveImgToUniqueFilename(img)
     img = self.checkItem(300, 310)
     self.saveImgToUniqueFilename(img)
     img = self.checkItem(300, 350)
     self.saveImgToUniqueFilename(img)
     img = self.checkItem(300, 390)
     self.saveImgToUniqueFilename(img)
     pyautogui.scroll(-1)
     img = self.checkItem(300, 390)
     self.saveImgToUniqueFilename(img)
     pyautogui.scroll(-1)
     img = self.checkItem(300, 390)
     self.saveImgToUniqueFilename(img)
     pyautogui.scroll(-1)
     img = self.checkItem(300, 390)
     self.saveImgToUniqueFilename(img)
     pyautogui.scroll(-1)
     img = self.checkItem(300, 390)
     self.saveImgToUniqueFilename(img)
     pyautogui.scroll(-1)
     img = self.checkItem(300, 390)
     self.saveImgToUniqueFilename(img)
     pyautogui.scroll(-1)
     img = self.checkItem(300, 390)
     self.saveImgToUniqueFilename(img)
     pyautogui.scroll(-1)
     img = self.checkItem(300, 390)
     self.saveImgToUniqueFilename(img)
     pyautogui.scroll(-1)
     img = self.checkItem(300, 390)
     self.saveImgToUniqueFilename(img)
     pyautogui.scroll(-1)
     img = self.checkItem(300, 390)
     self.saveImgToUniqueFilename(img)
     pyautogui.scroll(-1)
     img = self.checkItem(300, 390)
     self.saveImgToUniqueFilename(img)
     pyautogui.scroll(-1)
     img = self.checkItem(300, 390)
     self.saveImgToUniqueFilename(img)
     time.sleep(0.5)
     pyautogui.click(330, 180)
Ejemplo n.º 18
0
        pyautogui.click()
        time.sleep(2)
        try:
            sendNow_pos = pyautogui.locateCenterOnScreen('sendNow_image.PNG')
        except TypeError:
            print("send button not found!!")
        else:
            print(sendNow_pos)
            x1, y1 = sendNow_pos

            pyautogui.moveTo(x1, y1, 2)
            pyautogui.click()
            time.sleep(2)

    time.sleep(3)
    pyautogui.scroll(-300)
    time.sleep(3)

    for pos in pyautogui.locateAllOnScreen('connect_button_image.PNG'):

        print(pos)
        x, y, w, h = pos
        pyautogui.moveTo(x, y, 2)
        pyautogui.click()
        time.sleep(2)
        try:
            sendNow_pos = pyautogui.locateCenterOnScreen('sendNow_image.PNG')
        except TypeError:
            print("send button not found!!")
        else:
            print(sendNow_pos)
Ejemplo n.º 19
0
import pyautogui
from time import sleep

sleep(5)
for i in range(10):
    sleep(0.5)
    pyautogui.scroll(-2000)

Ejemplo n.º 20
0
def main(day, order):
    six = 70
    seven = six + 80
    eight = seven + 80
    nine = eight + 80
    ten = nine + 80
    eleven = ten + 80
    twelve = eleven + 100
    thirteen = twelve + 80
    fourteen = thirteen + 80
    i = 0

    for classes in order:

        if i >= 1:
            index = order.index(classes)
            sub = index - 1
            total = index - sub
            if total == -2:
                print('3333')
                time.sleep(3)
            elif total == -3:
                print('666666')
                time.sleep(6)
            elif total == -4:
                print('999999')
                time.sleep(9)

        time.sleep(5)
        x, y = gui.locateCenterOnScreen(day + '.png')
        gui.click(x, y)

        gui.move(300, 500)

        gui.scroll(20)
        gui.scroll(-9)

        if classes == 6:
            gui.move(x, y + six)
            gui.click(x, y + six, button='right')
            time.sleep(1)
        elif classes == 7:
            gui.move(x, y + six)
            gui.click(x, y + seven, button='right')
            time.sleep(1)
        elif classes == 8:
            gui.move(x, y + six)
            gui.click(x, y + eight, button='right')
            time.sleep(1)
        elif classes == 9:
            gui.move(x, y + six)
            gui.click(x, y + nine, button='right')
            time.sleep(1)
        elif classes == 10:
            gui.move(x, y + six)
            gui.click(x, y + ten, button='right')
            time.sleep(1)
        elif classes == 11:
            gui.move(x, y + six)
            gui.click(x, y + eleven, button='right')
            time.sleep(1)
        elif classes == 12:
            gui.move(x, y + six)
            gui.click(x, y + twelve, button='right')
            time.sleep(1)
        elif classes == 13:
            gui.move(x, y + six)
            gui.click(x, y + thirteen, button='right')
            time.sleep(1)
        elif classes == 14:
            gui.move(x, y + six)
            gui.click(x, y + fourteen, button='right')
            time.sleep(1)

        x, y = gui.locateCenterOnScreen('view.png')
        gui.click(x, y)
        time.sleep(5)
        x, y = gui.locateCenterOnScreen('join.png')
        gui.click(x, y)

        i += 1
        #50 minute sleep in the session
        time.sleep(10)

        #leaving the seesion
        x, y = gui.locateCenterOnScreen('leave.png')
        gui.click(x, y)

        x, y = gui.locateCenterOnScreen('calender.png')
        gui.click(x, y)
def Coletar_Linkedin():
    global curtidas, output, Tudo

    def alt_tab_to_chrome(a, b, c, extra, alttab):
        if alttab:
            pyautogui.keyDown('alt')
            pyautogui.press('tab')

        c_x, c_y = dar_coordenadas_cor_print(a, b, c, 0)

        pyautogui.click(c_x, c_y + extra, duration=0.2)

        pyautogui.keyUp('alt')

    def facebooktoexcel(letra):
        global curtidas, output

        prefix = "\\r\\n"

        if prefix + "Ana Beatriz Farias" in curtidas:
            output = output + letra + " \t \t \t"
        else:
            output = output + "\t \t \t"

        if prefix + "Beatriz Mendon\\xc3\\xa" in curtidas:
            output = output + letra + " \t \t \t"
        else:
            output = output + "\t \t \t"

        if prefix + "Bianca Souza" in curtidas:
            output = output + letra + " \t \t \t"
        else:
            output = output + "\t \t \t"

        if prefix + "Taynara Ramalho" in curtidas:
            output = output + letra + " \t \t \t"
        else:
            output = output + "\t \t \t"

        if prefix + "Ernane Matheus" in curtidas:
            output = output + letra + " \t \t \t"
        else:
            output = output + "\t \t \t"

        if prefix + "Giovanny Oliveira" in curtidas:
            output = output + letra + " \t \t \t"
        else:
            output = output + "\t \t \t"

        if prefix + "Jo\\xc3\\xa3o Vinicius Santiago" in curtidas:
            output = output + letra + " \t \t \t"
        else:
            output = output + "\t \t \t"

        if prefix + "Pedro Paulo Pinheiro Moura" in curtidas:
            output = output + letra + " \t \t \t"
        else:
            output = output + "\t \t \t"

        if prefix + "J\\xc3\\xbalia Caroline" in curtidas:
            output = output + letra + " \t \t \t"
        else:
            output = output + "\t \t \t"

        if prefix + "Luiz Andr\\xc3\\xa9 Fialho Oliveira" in curtidas:
            output = output + letra + " \t \t \t"
        else:
            output = output + "\t \t \t"

        if prefix + "Emanuelle Paiva" in curtidas:
            output = output + letra + " \t \t \t"
        else:
            output = output + "\t \t \t"

        if prefix + "Izabele Vit\\xc3\\xb3ria Oliveira Leite" in curtidas:
            output = output + letra + " \t \t \t"
        else:
            output = output + "\t \t \t"

        if prefix + "Julia Vieira" in curtidas:
            output = output + letra + " \t \t \t"
        else:
            output = output + "\t \t \t"

        if prefix + "Tuiza Galgani" in curtidas:
            output = output + letra + " \t \t \t"
        else:
            output = output + "\t \t \t"

        if prefix + "Victor Duarte" in curtidas:
            output = output + letra + " \t \t \t"
        else:
            output = output + "\t \t \t"

        output = output + '\n'

    def double_key(a, b):
        pyautogui.keyDown(a)
        pyautogui.press(b)
        pyautogui.keyUp(a)

    def multiple_alttab(a):
        pyautogui.keyDown('alt')
        for i in range(a):
            pyautogui.press('tab')
            time.sleep(0.5)
        pyautogui.keyUp('alt')

    alt_tab_to_chrome(220, 76, 64, 40, True)
    alt_tab_to_chrome(0, 114, 177, 0, False)

    # Clickar na caixa de likes

    c_x, c_y = dar_coordenadas_cor_print(27, 132, 187, 0)
    pyautogui.click(c_x, c_y, duration=0.2)

    # Selecionar curtidas

    pyautogui.moveTo(536, 205, 0.5)
    pyautogui.mouseDown(button='left')
    pyautogui.moveTo(1050, 750, 0.2)
    time.sleep(5)
    pyautogui.mouseUp(button='left')

    double_key('ctrl', 'c')

    time.sleep(0.2)

    win32clipboard.OpenClipboard()
    novo = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)
    Tudo = Tudo + ' ComecouCurtidas: ' + novo
    win32clipboard.CloseClipboard()

    # Fechar caixa de curtidas

    pyautogui.click(1240, 600, duration=0.2)

    # Abrir comentarios

    pyautogui.click(c_x + 90, c_y, duration=0.2)
    time.sleep(0.5)
    pyautogui.click(c_x + 90, c_y, duration=0.2)

    # Selecionar comentarios

    pyautogui.moveTo(c_x - 190, c_y, 0.2)
    pyautogui.mouseDown(button='left')
    pyautogui.moveTo(GetSystemMetrics(0) - 500, c_y, 0.2)

    novo = ''

    # Vai scrollando até o final dos comentários

    while not 'Exibir estat' in novo:
        pyautogui.scroll(-50)
        double_key('ctrl', 'c')

        win32clipboard.OpenClipboard()
        novo = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)
        win32clipboard.CloseClipboard()

    Tudo = Tudo + "ComecouComentarios" + novo

    pyautogui.mouseUp(button='left')

    ### PARTE 2
    ### EXTRAÇÃO DE INFORMAÇÕES DA STRING

    Tudo = str(Tudo.encode('utf-8'))

    curtidas = Tudo[:Tudo.index('ComecouComentarios')]

    output = ''

    facebooktoexcel('A')

    curtidas = Tudo[Tudo.index('ComecouComentarios'):]

    facebooktoexcel('B')

    win32clipboard.OpenClipboard()
    win32clipboard.EmptyClipboard()
    win32clipboard.SetClipboardData(win32con.CF_UNICODETEXT, output)
    win32clipboard.CloseClipboard()

    print(Tudo)
    print(output)

    double_key('alt', 'tab')
Ejemplo n.º 22
0
import pyautogui as pag
import time

if __name__ == '__main__':
    # while True:
    #     x, y = pag.position()
    #     print("x : {}   y : {}".format(x, y), end = "\r")

    # pag.moveTo(725, 57)
    # pag.move(100, 200, duration=2)
    # pag.click()
    # pag.click()
    # pag.doubleClick()

    # pag.drag(0, 200, duration=1)
    # pag.rightClick()

    # pag.click(518, 183, duration=2)
    # pag.scroll(0, 100)

    # pag.moveTo(725, 57, duration=2)
    # pag.click()
    # time.sleep(1)
    # pag.typewrite("http://ticket.interpark.com/")
    # pag.press("enter")

    #TODO: scroll
    time.sleep(2)
    pag.hotkey("alt", "tab")
    pag.scroll(clicks=-2000, x=798, y=185)
        for i in range(10):
            pa.click(x=960, y=119)
            time.sleep(0.05)
        # time.sleep(7)
        pos = imagesearch_loop_timeout(folder+"tag_duel.png", 0.1, 2)
        # pos = imagesearch(folder+"tag_duel.png")
        if pos[0] > -1:
            search = False
            click_image(folder+"tag_duel.png", pos, "left", 0.1)
        else:
            pos2 = imagesearch_loop_timeout(folder+"event_flow.png", 0.1, 2)
            if pos2[0] > -1:
                # Scroll to DM cup
                pa.moveTo(x=1126, y=746)
                for i in range(7):
                    pa.scroll(-10)
                pos2 = imagesearch_loop(folder+"DM_cup.png", 0.1)
                if (pos2[0] > -1):
                    click_image(folder+"DM_cup.png", pos2, "left", 0.1)

    print('Search hard level')
    # Click hard level
    search = True
    while search:
        pos = imagesearch(folder+"hard_level.png")
        if pos[0] > -1:
            search = False
        for i in range(3):
            pa.click(x=960, y=119)
            time.sleep(0.1)
        time.sleep(0.1)
def scrollTest():
    pyautogui.click()
    pyautogui.scroll(200)
Ejemplo n.º 25
0
 time.sleep(1)
 #Fim do mapa
 time.sleep(1)
 pyautogui.click(143, 868)
 time.sleep(1)
 #Titulo
 titulo = trim(gerarFrase(randint(5, 20)))
 pyautogui.write(titulo, interval=0.01)
 time.sleep(1)
 pyautogui.click(143, 947)
 time.sleep(1)
 #Descrição
 descricao = trim(gerarFrase(randint(50, 200)))
 pyautogui.write(descricao, interval=0.01)
 time.sleep(1)
 pyautogui.scroll(-700)
 time.sleep(1)
 pyautogui.click(143, 684)
 time.sleep(1)
 #Nome
 pyautogui.write("Luiza Andaluz", interval=0.01)
 time.sleep(1)
 pyautogui.click(143, 770)
 time.sleep(1)
 #Idade
 pyautogui.write(str(randint(15, 80)), interval=0.01)
 time.sleep(1)
 pyautogui.click(143, 855)
 time.sleep(1)
 #email
 pyautogui.write(gerarFrase(randint(30, 50)), interval=0.01)
Ejemplo n.º 26
0
def performAction( yp, rc, bc, action, drag, perform):

	if action == 'ONOFF':
			perform = not perform
			if perform:
				print 'Mouse simulation ON...'
			else:
				print 'Mouse simulation OFF...'

	if perform:
		
		if not leftHand:
	 		cursor[0] = 4*(yp[0]-110)
	 	else:
	 		cursor[0] = 4*(yp[0]-50)
		cursor[1] = 4*(yp[1]-120)
			
		if action == 'move':
			if not leftHand:
				if yp[0]>110 and yp[0]<590 and yp[1]>120 and yp[1]<390:
					pyautogui.moveTo(cursor[0],cursor[1])
				elif yp[0]<110 and yp[1]>120 and yp[1]<390:
					pyautogui.moveTo( 8 , cursor[1])
				elif yp[0]>590 and yp[1]>120 and yp[1]<390:
					pyautogui.moveTo(1912, cursor[1])
				elif yp[0]>110 and yp[0]<590 and yp[1]<120:
					pyautogui.moveTo(cursor[0] , 8)
				elif yp[0]>110 and yp[0]<590 and yp[1]>390:
					pyautogui.moveTo(cursor[0] , 1072)
				elif yp[0]<110 and yp[1]<120:
					pyautogui.moveTo(8, 8)
				elif yp[0]<110 and yp[1]>390:
					pyautogui.moveTo(8, 1072)
				elif yp[0]>590 and yp[1]>390:
					pyautogui.moveTo(1912, 1072)
				else:
					pyautogui.moveTo(1912, 8)
			else:
				if yp[0]>50 and yp[0]<530 and yp[1]>120 and yp[1]<390:
					pyautogui.moveTo(cursor[0],cursor[1])
				elif yp[0]<50 and yp[1]>120 and yp[1]<390:
					pyautogui.moveTo( 8 , cursor[1])
				elif yp[0]>530 and yp[1]>120 and yp[1]<390:
					pyautogui.moveTo(1912, cursor[1])
				elif yp[0]>50 and yp[0]<530 and yp[1]<120:
					pyautogui.moveTo(cursor[0] , 8)
				elif yp[0]>50 and yp[0]<530 and yp[1]>390:
					pyautogui.moveTo(cursor[0] , 1072)
				elif yp[0]<50 and yp[1]<120:
					pyautogui.moveTo(8, 8)
				elif yp[0]<50 and yp[1]>390:
					pyautogui.moveTo(8, 1072)
				elif yp[0]>530 and yp[1]>390:
					pyautogui.moveTo(1912, 1072)
				else:
					pyautogui.moveTo(1912, 8)
		
		elif action == 'left':
			pyautogui.click(button = 'left')

		elif action == 'right':
			pyautogui.click(button = 'right')
			time.sleep(0.3)	

		elif action == 'up':
			pyautogui.scroll(5)
#			time.sleep(0.3)

		elif action == 'down':
			pyautogui.scroll(-5)			
#			time.sleep(0.3)

		elif action == 'drag' and drag == 'true':
			global y_pos
			drag = 'false'
			pyautogui.mouseDown()
		
			while(1):

				k = cv2.waitKey(10) & 0xFF
				changeStatus(k)

				_, frameinv = cap.read()
				# flip horizontaly to get mirror image in camera
				frame = cv2.flip( frameinv, 1)

				hsv = cv2.cvtColor( frame, cv2.COLOR_BGR2HSV)

				b_mask = makeMask( hsv, blue_range)
				r_mask = makeMask( hsv, red_range)
				y_mask = makeMask( hsv, yellow_range)

				py_pos = y_pos 

				b_cen = drawCentroid( frame, b_area, b_mask, showCentroid)
				r_cen = drawCentroid( frame, r_area, r_mask, showCentroid)	
				y_cen = drawCentroid( frame, y_area, y_mask, showCentroid)
			
				if 	py_pos[0]!=-1 and y_cen[0]!=-1:
					y_pos = setCursorPos(y_cen, py_pos)

				performAction(y_pos, r_cen, b_cen, 'move', drag, perform)					
				cv2.imshow('Frame', frame)

				if distance(y_pos,r_cen)>60 or distance(y_pos,b_cen)>60 or distance(r_cen,b_cen)>60:
					break

			pyautogui.mouseUp()
	return perform			
Ejemplo n.º 27
0
def space(sppp):
    for k in range(0, sppp):
        pyautogui.scroll(-100)
Ejemplo n.º 28
0
def scroll(nclick):
	for i in range(nclick):
		pyautogui.scroll(-10)
Ejemplo n.º 29
0
    def control_pc(self, pre_gesture, now_gesture, head):
        if pre_gesture == now_gesture:
            pass

        else:
            if now_gesture == 'Thumb Up':
                # browser open
                # if self.my_tab_num == -1:
                #     self.browser = webdriver.Chrome(chrome_options=self.options, executable_path = './chromedriver')
                #     self.browser.set_window_position(self.screenW//2, 0)
                #     self.browser.set_window_size(self.screenW//2, self.screenH)
                #     self.browser.get('http://google.com')
                #     self.tabs = self.browser.window_handles
                #     self.my_tab_num += 1
                # else:
                #     self.browser.execute_script('window.open("http://google.com", "_blank");')
                #     self.tabs = self.browser.window_handles
                #     self.my_tab_num =len(self.browser.window_handles) + 1
                # click
                pg.click()
                pass

            elif now_gesture == 'Sliding Two Fingers Up':
                # mouse up
                cur_x, cur_y = pg.position()
                pg.moveTo(cur_x, cur_y - 100, 1)
                if not pg.onScreen(cur_x, cur_y - 100):
                    pg.moveTo(cur_x, 0)

            elif now_gesture == 'Stop Sign':
                # exit
                # self.tabs = self.browser.window_handles
                # for i in range(self.my_tab_num, -1, -1):
                #     self.browser.switch_to_window(self.tabs[i])
                #     self.browser.close()
                # self.browser = None
                # self.tabs = None
                # self.my_tab_num = 0
                pass

            elif now_gesture == 'Swiping Right':
                # mouse righr fast
                cur_x, cur_y = pg.position()
                pg.moveTo(cur_x + 250, cur_y, 1)
                if not pg.onScreen(cur_x + 250, cur_y):
                    pg.moveTo(self.screenW, cur_y)

            elif now_gesture == 'Swiping Left':
                # mouse left fast
                cur_x, cur_y = pg.position()
                pg.moveTo(cur_x - 250, cur_y, 1)
                if not pg.onScreen(cur_x - 250, cur_y):
                    pg.moveTo(0, cur_y)

            elif now_gesture == 'Sliding Two Fingers Right':
                # mouse right
                cur_x, cur_y = pg.position()
                pg.moveTo(cur_x + 100, cur_y, 1)
                if not pg.onScreen(cur_x + 100, cur_y):
                    pg.moveTo(self.screenW, cur_y)

            elif now_gesture == 'Sliding Two Fingers Left':
                # mouse left
                cur_x, cur_y = pg.position()
                pg.moveTo(cur_x - 100, cur_y, 1)
                if not pg.onScreen(cur_x - 100, cur_y):
                    pg.moveTo(0, cur_y)

            elif now_gesture == 'Sliding Two Fingers Down':
                # mouse down
                cur_x, cur_y = pg.position()
                pg.moveTo(cur_x, cur_y + 100, 1)
                if not pg.onScreen(cur_x, cur_y + 100):
                    pg.moveTo(cur_x, self.screenH)

            elif now_gesture == 'Swiping Up':
                # close tab
                # self.browser.switch_to_window(self.tabs[self.my_tab_num])
                # self.browser.close()
                # self.my_tab_num += -1
                # if self.my_tab_num<0:
                #     self.my_tab_num = 0
                # scroll Down
                pg.scroll(10)

            elif now_gesture == 'Swiping Down':
                # scroll Up
                pg.scroll(-10)

            elif now_gesture == 'Rolling Hand Backward':
                # go back
                #self.browser.back()

                pass

            else:
                #
                pass
Ejemplo n.º 30
0
    def __init__(self, active: bool, offsetX: int, offsetY: int):
        self.active = active
        self.offsetX = offsetX
        self.offsetY = offsetY


backupButtonDetectionData = BackupButtonDetectionData(
    False, constants.BUTTON_DETECTION_SCREENSHOT_AREA[0], 0)
while True:
    pyautogui.moveTo(100, 100)
    if animation.hasAnimation():
        numSinceLastEvent = 0
        animation.clickSpeedTextbox()
        animation.clickStart()
        animation.runAnimation()
        pyautogui.scroll(-10, x=1000, y=1000)
    elif backupButtonDetectionData.active and backupButtonDetection.hasButton(
            backupButtonDetectionData):
        backupButtonDetection.clickButton(backupButtonDetectionData)
        backupButtonDetection.shiftScreenshot(backupButtonDetectionData)
    elif multipleChoice.hasBubble() and not backupButtonDetectionData.active:
        numSinceLastEvent = 0
        bubbleLocation = multipleChoice.getBubbleLoc()
        multipleChoice.clickBubble()
        multipleChoice.scrollToNextBubble(bubbleLocation)
    elif bigBoiStart.hasBigBoiButton():
        loc = bigBoiStart.getBigBoiButton()
        bigBoiStart.clickBigBoiButton()
        bigBoiStart.scrollToNextBubble(loc)
    elif nextLesson.hasEnding():
        backupButtonDetectionData = BackupButtonDetectionData(
Ejemplo n.º 31
0
    height, width = imageToProcess.shape[:2]
    datum.cvInputData = imageToProcess
    opWrapper.emplaceAndPop([datum])

    # Display Image Points
    # print("Body keypoints: \n" + str(datum.poseKeypoints))
    # print("Left hand keypoints: \n" + str(datum.handKeypoints[0]))
    # print("Right hand keypoints: \n" + str(datum.handKeypoints[1]))

    if (mode == 1):
        # scroll content
        if (datum.poseKeypoints[0][4][1] == 0):
            pass
        else:
            pyautogui.scroll(
                -(datum.poseKeypoints[0][4][1] - datum.poseKeypoints[0][3][1])
                / 80)

        # change tabs
        if (datum.poseKeypoints[0][6][0] - datum.poseKeypoints[0][7][0] > 100
                and datum.poseKeypoints[0][7][0] != 0):
            if (flag2 == 1):
                flag2 = 0
                pyautogui.hotkey('ctrl', 'pageup')

        elif (datum.poseKeypoints[0][6][0] - datum.poseKeypoints[0][7][0] < -60
              and datum.poseKeypoints[0][7][0] != 0):
            if (flag2 == 1):
                flag2 = 0
                pyautogui.hotkey('ctrl', 'pagedown')
Ejemplo n.º 32
0
cont = 0
#OBS: TODAS AS COORDENADAS PASSADAS SÃO DE ACORDO COM MINHA RESOLUÇÃO, QUE É 1440x900

#A variavel "quant" é o tempo que o programa ficara em cada vídeo
quant = int(
    input(
        'Quanto tempo deseja esperar para passar os videos? (EM SEGUNDOS): '))

while True:
    time.sleep(3)  # Tempo para iniciar o programa.
    print(cursor.position())
    cursor.click(
        x=2856,
        y=1202)  # Caso o programa esteja minimizado ele o abre novamente
    cursor.click(
        x=2856,
        y=1202)  # Caso o programa esteja minimizado ele o abre novamente

    cursor.moveTo(
        x=2869,
        y=292)  # Cursor do mouse se move nas coordenadas x=2869 e y=292.

    cursor.scroll(-100)  #Scroll do mouse passa para o próximo vídeo.

    time.sleep(
        quant
    )  # O Programa espera o tempo máximo do vídeo que é 1 minuto e continua.
    cont += 1
    print(f'Você ja viu {cont} vídeos')
Ejemplo n.º 33
0
pyautogui.moveRel(xOffset=600)
pyautogui.click()
one_img()
pyautogui.moveRel(yOffset=800)
pyautogui.click()
one_img()
pyautogui.moveRel(yOffset=800)
pyautogui.moveRel(xOffset=300)
pyautogui.click()
one_img()
pyautogui.moveRel(yOffset=800)
pyautogui.moveRel(xOffset=600)
pyautogui.click()
one_img()
pyautogui.moveRel(yOffset=800)
pyautogui.scroll(-195)

#first two rows:

u = 0
while u != final_url:
    for m in range(20):
        if u != final_url:
            for i in range(100):
                if u != final_url:
                    for shift in [0, 300, 600]:
                        if u != final_url:
                            pyautogui.moveRel(xOffset=shift)
                            pyautogui.click()
                            print(i)
                            u = one_img()
Ejemplo n.º 34
0
#alt:
pyautogui.click(100, 150, button='left')
pyautogui.click(100, 150, button='right')
#alt
#pyautogui.mousedown to click mouse down (held) then .mouseup to release.
#also .middleclick(), .rightclick(), .doubleClick()
#draw test
import pyautogui, time
time.sleep(5)
pyautogui.click()
distance = 200
while distance > 0:
    pyautogui.dragRel(distance, 0, duration=0.2)  #move right
    distance = distance - 5
    pyautogui.dragRel(0, distance, duration=0.2)  #down
    pyautogui.dragRel(-distance, 0, duration=0.2)  #left
    distance = distance - 5
    pyautogui.dragRel(0, -distance, duration=0.2)  #up
#satisfying as f**k
#also
pyautogui.scroll()
#Keyboard stuff:
pyautogui.click(100, 100)
pyautogui.typewrite('Hello world!')
#dang thats fast
#inputing non-text characters:
pyautogui.typewrite(['a', 'b', 'left', 'right', 'ctrlleft', 'tab'])  #etc.
#form filling program if I am ever interested

# Thats the book gone through, WOO~!
Ejemplo n.º 35
0
        MOUTH_COUNTER = 0

    if INPUT_MODE:
        cv2.putText(frame, "READING INPUT!", (10, 30),
                    cv2.FONT_HERSHEY_SIMPLEX, 0.7, RED_COLOR, 2)
        x, y = ANCHOR_POINT
        nx, ny = nose_point
        w, h = 60, 35
        multiple = 1
        cv2.rectangle(frame, (x - w, y - h), (x + w, y + h), GREEN_COLOR, 2)
        cv2.line(frame, ANCHOR_POINT, nose_point, BLUE_COLOR, 2)

        direct = direction(nose_point, ANCHOR_POINT, w, h)
        direct = direct * .5
        if SCROLL_MODE:
            pag.scroll(int(direct[1] * 2))
        else:
            pag.moveRel(*direct)

    if SCROLL_MODE:
        cv2.putText(frame, 'SCROLL MODE IS ON!', (10, 60),
                    cv2.FONT_HERSHEY_SIMPLEX, 0.7, RED_COLOR, 2)

    # cv2.putText(frame, "MAR: {:.2f}".format(mar), (500, 30),
    #             cv2.FONT_HERSHEY_SIMPLEX, 0.7, YELLOW_COLOR, 2)
    # cv2.putText(frame, "Right EAR: {:.2f}".format(rightEAR), (460, 80),
    #             cv2.FONT_HERSHEY_SIMPLEX, 0.7, YELLOW_COLOR, 2)
    # cv2.putText(frame, "Left EAR: {:.2f}".format(leftEAR), (460, 130),
    #             cv2.FONT_HERSHEY_SIMPLEX, 0.7, YELLOW_COLOR, 2)
    # cv2.putText(frame, "Diff EAR: {:.2f}".format(np.abs(leftEAR - rightEAR)), (460, 80),
    #             cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2)
Ejemplo n.º 36
0
    incoming_data = str(
        Arduino_Serial.readline())  # read the serial data and print it as line
    print incoming_data  # print the incoming Serial data

    if 'next' in incoming_data:  # if incoming data is 'next'
        pyautogui.hotkey(
            'ctrl', 'pgdn'
        )  # perform "ctrl+pgdn" operation which moves to the next tab

    if 'previous' in incoming_data:  # if incoming data is 'previous'
        pyautogui.hotkey(
            'ctrl', 'pgup'
        )  # perform "ctrl+pgup" operation which moves to the previous tab

    if 'down' in incoming_data:  # if incoming data is 'down'

        pyautogui.scroll(-100)

    if 'up' in incoming_data:  # if incoming data is 'up'

        pyautogui.scroll(100)

    if 'change' in incoming_data:  # if incoming data is 'change'
        pyautogui.keyDown(
            'alt')  # performs "alt+tab" operation which switches the tab
        pyautogui.press('tab')
        pyautogui.keyUp('alt')

    incoming_data = ""
    # clears the data
Ejemplo n.º 37
0
def scroll(clicks):
    pyautogui.scroll(clicks)
Ejemplo n.º 38
0
if warningYN.lower() == "y":
    warningLength = int(input("Seconds warning before change: "))

scrollFactor = 0
scrollYN = input("Autoscroll? (y/n) ")

if scrollYN.lower() == "y":
    calibrated = "n"
    scrollFactor = input('Okay, let\'s test your scroll. Open your editor to the destination file. If you have done this before and already know your scroll factor, enter it here. Otherwise, just hit ENTER, then click in the editor window of the destination file.') or 100

    while calibrated == "n":
        time.sleep(5)
        for i in range(len(blocks)):
            time.sleep(1)
            pyautogui.scroll(-len(blocks[i])//scrollFactor)
            destination = open(dPath, 'a')
            destination.write(blocks[i])
            destination.close()

        calibrated = input('Did that scroll correctly? (y/n) ')
        if calibrated == 'n':
            scrollFactor = int(input('Ok. That test was with a scroll factor of %d. The lower the number, the greater the scrolling. What number would you like to try now? ' % scrollFactor))

input('Great. We\'re all set. When you\'re ready, just hit ENTER and click inside the editor window of your destination file.')
time.sleep(5)

def warn():
    if platform == 'win32':
        duration = 500  # millisecond
        a = 440  # Hz
s.save('screenshot1.jpg')

print 'The resolution of your screen: ', pyautogui.size()

print 'Current position of mouse: ', pyautogui.position()

# Drag mouse to control some object on screen (such as googlemap at webpage)
distance = 100.
while distance > 0:
    pyautogui.dragRel(distance, 0, duration=2 , button='left')    # move right
    distance -= 25
    pyautogui.dragRel(0, distance, duration=2 , button='left')    # move down
    distance -= 25
    pyautogui.dragRel(-distance, 0, duration=2 , button='left')    # move right
    distance -= 25
    pyautogui.dragRel(0, -distance, duration=2 , button='left')    # move down
    distance -= 25

# scroll mouse wheel (zoon in and zoom out googlemap)
pyautogui.scroll(10, pause=1.)
pyautogui.scroll(-10, pause=1)

pyautogui.scroll(10, pause=1.)
pyautogui.scroll(-10, pause=1)

# message box
pyautogui.alert(text='pyautogui testing over, click ok to end', title='Alert', button='OK')



Ejemplo n.º 40
0
 pyautogui.PAUSE = 0.50
 pyautogui.hotkey('tab')
 pyautogui.hotkey('space')
 #To the robot
 pyautogui.hotkey('tab')
 pyautogui.PAUSE = 1
 pyautogui.hotkey('space')
 #Human Interaction
 pyautogui.PAUSE = 20.0
 pyautogui.hotkey('tab')
 pyautogui.PAUSE = 0.25
 pyautogui.hotkey('tab')
 pyautogui.PAUSE = 0.25
 pyautogui.hotkey('tab')
 pyautogui.PAUSE = 0.25
 pyautogui.hotkey('tab')
 pyautogui.PAUSE = 0.25
 pyautogui.hotkey('tab')
 pyautogui.PAUSE = 0.25
 pyautogui.hotkey('tab')
 pyautogui.PAUSE = 0.25
 pyautogui.hotkey('enter')
 pyautogui.scroll(+10)
 pyautogui.scroll(-10)
 pyautogui.PAUSE = 3
 pyautogui.scroll(+10)
 pyautogui.scroll(-10)
 pyautogui.hotkey('tab')
 pyautogui.PAUSE = 12.0
 pyautogui.hotkey('ctrl', 'w')
 pyautogui.PAUSE = 1
Ejemplo n.º 41
0
def run_algorithm():
    skip_state = False
    pyautogui.moveTo(500, 400, duration=0.5)
    pyautogui.rightClick()
    pyautogui.moveTo(571, 575, duration=0.5)
    pyautogui.click()
    time.sleep(1.5)
    # name image
    pyautogui.typewrite(str(image_num))
    time.sleep(1)
    pyautogui.press('enter')
    # click on large image
    pyautogui.moveRel(-150, -250, duration=0.5)
    pyautogui.rightClick()
    pyautogui.moveRel(10, 5, duration=0.5)
    pyautogui.click()
    time.sleep(4)
    pyautogui.moveTo(283, 13, duration=1)
    pyautogui.click()
    time.sleep(4)
    # Grab affiliate link text
    pyautogui.moveTo(186, 90, duration=1)
    time.sleep(3)
    pyautogui.doubleClick()
    time.sleep(3)
    pyautogui.keyDown('ctrl')
    pyautogui.press('c')
    pyautogui.keyUp('ctrl')
    #copy from clipboard to variable
    clip.OpenClipboard()
    afl_link = clip.GetClipboardData()
    clip.CloseClipboard()
    if "http" not in afl_link:
        afl_link = "www.kiitri.com"
    #copy part link
    pyautogui.moveTo(361, 45)
    pyautogui.dragTo(443, 45, duration=1)
    pyautogui.keyDown('ctrl')
    pyautogui.press('c')
    pyautogui.keyUp('ctrl')
    #copy from clipboard to variable
    clip.OpenClipboard()
    part_link = clip.GetClipboardData()
    clip.CloseClipboard()
    #check if part of link is one of last 3 used links
    if part_link in link_list:
        renew_state()
        pyautogui.scroll(-318)  # scroll down 318 pixels
        skip_state = True
        return skip_state
    else:
        link_list[0] = link_list[1]
        link_list[1] = link_list[2]
        link_list[2] = part_link
        print(link_list)
    #Get text desciption of this item
    description = run_bs4(afl_link)
    # close tab
    pyautogui.keyDown('ctrl')
    pyautogui.press('w')
    pyautogui.keyUp('ctrl')
    #go to pinterest tab
    pyautogui.moveTo(283, 13, duration=0.5)
    pyautogui.click()
    # hover over plus sign
    pyautogui.moveTo(1192, 90, duration=1)
    # move to hover over "upload image"
    pyautogui.moveTo(1192, 156, duration=0.5)
    pyautogui.click()
    time.sleep(0.5)
    # hover over "destination url"
    pyautogui.moveTo(567, 446, duration=0.5)
    pyautogui.click()
    time.sleep(0.5)
    # paste affiliate link
    pyautogui.typewrite(afl_link)
    # upload image I just created
    pyautogui.moveTo(866, 359)
    time.sleep(1)
    pyautogui.click()
    time.sleep(1)
    pyautogui.typewrite(str(image_num) + ".jpg")
    pyautogui.press('enter')
    time.sleep(1)
    # post item (Pinterest)
    pyautogui.moveTo(891, 510, duration=0.2)
    time.sleep(2)
    pyautogui.click()
    time.sleep(2)
    # add caption (Pinterest)
    pyautogui.moveTo(432, 525, duration=0.2)
    pyautogui.click()
    time.sleep(0.4)
    pyautogui.typewrite(description)
    # choose board (Pinterest)
    pyautogui.moveTo(764, 170)
    pyautogui.doubleClick()
    pyautogui.typewrite('Best Amazon Finds')
    time.sleep(2)
    pyautogui.moveTo(773, 235, duration=0.5)
    pyautogui.click()
    time.sleep(3)
    pyautogui.moveTo(484, 640, duration=0.5)
    pyautogui.click()
    time.sleep(3)
    # jump back to amazon page
    pyautogui.keyDown('ctrl')
    pyautogui.press('pgup')
    pyautogui.keyUp('ctrl')
    time.sleep(1)
    # close big image of previous item
    pyautogui.press('esc')
    pyautogui.moveTo(773, 235, duration=0.5)
    return skip_state
Ejemplo n.º 42
0
import pyautogui

pyautogui.moveTo(100, 200)      # moves mouse to X of 100, Y of 200.
pyautogui.moveTo(None, 500)     # moves mouse to X of 100, Y of 500.
pyautogui.moveTo(600, None)     # moves mouse to X of 600, Y of 500.
pyautogui.moveTo(100, 200, 2)   # moves mouse to X of 100, Y of 200 over 2 seconds

pyautogui.moveRel(0, 50)        # move the mouse down 50 pixels.
pyautogui.moveRel(-30, 0)       # move the mouse left 30 pixels.

pyautogui.click()                          # Left button click on current position
pyautogui.click(clicks=2)
pyautogui.click(clicks=2, interval=0.25)   # with a quarter second pause in between clicks

pyautogui.click(10, 5)                     # Mouse left button click, x=10, y=5
pyautogui.click(200, 250, button='right')  # Mouse right button click, x=200, y=250

pyautogui.scroll(10)   # scroll up 10 "clicks"
pyautogui.scroll(10, x=100, y=100)  # move mouse cursor to 100, 200, then scroll up 10 "clicks"
Ejemplo n.º 43
0
        multiple = 1
        cv2.rectangle(frame, (x - w, y - h), (x + w, y + h), GREEN_COLOR, 2)
        cv2.line(frame, ANCHOR_POINT, nose_point, BLUE_COLOR, 2)

        dir = direction(nose_point, ANCHOR_POINT, w, h)
        cv2.putText(frame, dir.upper(), (10, 90), cv2.FONT_HERSHEY_SIMPLEX,
                    0.7, RED_COLOR, 2)

        drag = 18
        if dir == 'right':
            pag.moveRel(drag, 0)
        elif dir == 'left':
            pag.moveRel(-drag, 0)
        elif dir == 'up':
            if SCROLL_MODE:
                pag.scroll(40)
            else:
                pag.moveRel(0, -drag)
        elif dir == 'down':
            if SCROLL_MODE:
                pag.scroll(-40)
            else:
                pag.moveRel(0, drag)

    if SCROLL_MODE:
        cv2.putText(frame, 'SCROLLING', (10, 60), cv2.FONT_HERSHEY_SIMPLEX,
                    0.7, RED_COLOR, 2)

    cv2.imshow("Frame", frame)
    key = cv2.waitKey(1) & 0xFF
Ejemplo n.º 44
0
        ltFrame = frame[:, 0:int(cap.get(3)/4)-50]
        rtFrame = frame[:, int(3*cap.get(3)/4)+50:]
        
        _, uCount, _, _, upFrame = upDetector.getMotion(upFrame)
        _, dCount, _, _, dnFrame = dnDetector.getMotion(dnFrame)
        _, lCount, _, lArea, ltFrame = ltDetector.getMotion(ltFrame)
        s, rCount, _, rArea, rtFrame = rtDetector.getMotion(rtFrame)
        if not s:
            continue
        if "-v" in sys.argv:
            cv2.imshow("up", upFrame)
            cv2.imshow("dn", dnFrame)
            cv2.imshow("lt", ltFrame)
            cv2.imshow("rt", rtFrame)
        if uCount in range(2, 5):
            pyautogui.scroll(100)
            if "-p" in sys.argv:
	        print "Up"
        elif dCount in range(2, 5):
            pyautogui.scroll(-100)
	    if "-p" in sys.argv:			
	        print "Down"	
        elif rArea>7000 and not rtimer:
            rtimer = True
            ltimer = False
            orgArea = rArea
            stTime = time()
        elif lArea>7000 and not ltimer:
            ltimer = True
            rtimer = False
            orgArea = lArea
控制鼠标交互
"""

import pyautogui as pg
import time
"""
###1 点击鼠标  click = mouseDown + mouseUp

pg.click(700,850,button='left')
"""
##pyauotgui.doubleClick() 双击左键
##pyautogui.rightClick()  双击右键
## pyautogui.middleClick()  双击中间

### 2 拖动鼠标  dragTo()  dragRel()
time.sleep(5)  ###延迟5s  便于切换窗口
pg.click()  ###确定画图 软件窗口置前
distance = 200
while distance > 0:
    pg.dragRel(distance, 0, duration=0.2)
    distance = distance - 5
    pg.dragRel(0, distance, duration=0.2)
    pg.dragRel(-distance, 0, duration=0.2)
    distance = distance - 5
    pg.dragRel(0, -distance, duration=0.2)

### 3 窗口滚动

pg.scroll(100)  ## + :up  - : down
Ejemplo n.º 46
0
def move_mouse(x1,y1):
    spaceCount = 0 #counter for single clicks
    cursorClick = 10 #alters how long the user must look at a point before a click
    maxMovement = 250 #alters the area the user must look at to invoke a click or double click
    cursorDoubleClick = 20 #alters how long the user must look at a point before a double click
    doubleCount = 0 #counter for double clicks
    scollBox = 50 #how close the gaze point must be to the scroll thumb
	
	
	#Move to the first location and add the location to the list	
    if len(pointsVisited) <=0:
		pyautogui.moveTo((x1,y1), duration=0)
		pointsVisited.append(pyautogui.position())
    
    #For the next locations find the previous location, work out the distance between
    #the previous location and the one to move to and set the time this should take
    #Move to the current location for the set amount of time, and add the current
    #location to the list
    else:
		prevPos = len(pointsVisited) - 1
		point = pointsVisited[prevPos]
		oldX = point[0]
		oldY = point[1]
		#For each set of coordinates in the list, move to the coordinates, at an
        #appropriate speed.
		distance = math.sqrt(math.pow(x1-oldX, 2) + math.pow(y1 -oldY,2))
		dur = distance/speed
		pyautogui.moveTo((x1,y1), duration=dur)
		pointsVisited.append(pyautogui.position())

#    print 'len points visited'
#    print (len(pointsVisited))

    #If there have been x number of movements set a bounding box around the 'x'th previous
    #location. Check each of the locaitons in this range, if all of them are within the
    #bounding box, invoke a click
    if len(pointsVisited) > cursorClick:
        #Set a box, (maxMovement) pixels wide
        lowBound1 = (pointsVisited[prevPos-cursorClick][0])-maxMovement
        lowBound2 = (pointsVisited[prevPos-cursorClick][1])-maxMovement
        highBound1 = (pointsVisited[prevPos-cursorClick][0])+maxMovement
        highBound2 = (pointsVisited[prevPos-cursorClick][1])+maxMovement
		#spaceCount = 0
    #For all the moves between the (cursorClick)th previous move and the current one,
    #check if the cursor has stayed within the bounds, if it has for each then add one to
    #spaceCount, repeat for doubleCount
        for j in range((prevPos-(cursorClick - 1)), (prevPos+1)):
			if((lowBound1<= pointsVisited[j][0]) & (pointsVisited[j][0] <= highBound1) & 
			(lowBound2 <= pointsVisited[j][1]) & (pointsVisited[j][1] <= highBound2)):
				spaceCount += 1
			else:
				spaceCount = 0
        if len(pointsVisited) > cursorDoubleClick:
			for k in range((prevPos-(cursorDoubleClick - 1)), (prevPos+1)):
				if((lowBound1<= pointsVisited[k][0]) &  (pointsVisited[k][0] <= highBound1) & 
				(lowBound2 <= pointsVisited[k][1]) & (pointsVisited[k][1] <= highBound2)):
					doubleCount += 1
				else:
					doubleCount = 0
	#print doubleCount
	#print spaceCount
    
	#Check doubleCount and spaceCount to see if a double click or click should be invoked,
    #if so also check if there should be a scroll
	if (doubleCount == cursorDoubleClick):
		print ('Double Click')
		pyautogui.click(clicks = 2)
		doubleCount = 0
		spaceCount = 0

	if (spaceCount == cursorClick):
		print('Click Invoked')
		pyautogui.click()
		spaceCount = 0
		
        #To ivoke a scroll search for occurances of the scroll thumb on the screen, then
        #check each of these locations to see if the cursor is there, if so scroll in the
        #correct direction.
		for k in (pyautogui.locateAllOnScreen(scrollUpFileHightlighted, grayscale=True)):
			if (x1 > (k[0] - scollBox) and x1 < (k[0] + k[2] + scollBox) and y1 > (k[1] - scollBox) and y1 < (k[1] + k[3] + scollBox)):
				pyautogui.scroll(scrollDist)
				print("Scrolled Up")
		for l in (pyautogui.locateAllOnScreen(scrollDownFileHighlighted, grayscale=True)):
			if (x1 > (l[0] - scollBox) and x1 < (l[0] + l[2] + scollBox) and y1 > (l[1] - scollBox) and y1 < (l[1] + l[3] + scollBox)):
				pyautogui.scroll(-scrollDist)
				print("Scrolled Down")
		for m in (pyautogui.locateAllOnScreen(scrollUpFile, grayscale=True)):
			if (x1 > (m[0] - scollBox) and x1 < (m[0] + m[2] + scollBox) and y1 > (m[1] - scollBox) and y1 < (m[1] + m[3] + scollBox)):
				pyautogui.scroll(scrollDist)
				print("Scrolled Up")
		for n in (pyautogui.locateAllOnScreen(scrollDownFile, grayscale=True)):
			if (x1 > (n[0] - scollBox) and x1 < (n[0] + n[2] + scollBox) and y1 > (n[1] - scollBox) and y1 < (n[1] + n[3] + scollBox)):
				pyautogui.scroll(-scrollDist)
				print("Scrolled Down")
 def scroll(self, clicks=1, direction="DOWN", **kwargs):
     if ("force" in kwargs and kwargs["force"] is True) or self.game_is_focused:
         clicks = clicks * (1 if direction == "DOWN" else -1)
         pyautogui.scroll(clicks)
Ejemplo n.º 48
0
    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
            #-576 刚好下一页    -1500 以上最后
            pyautogui.scroll(-576)
        elif num > 68:
            num = num - 69
            pyautogui.scroll(-1600)

        pyautogui.click(x=281, y=442 + (16 * num), button='left')
        # 默认
        pyautogui.click(x=332, y=460 + (16 * num), button='left')
        pyautogui.click(x=795, y=595, button='left')
        pyautogui.click(x=1399, y=276, button='left')
        #huitui --->
        pyautogui.alert('这个消息弹窗是文字+OK按钮')
        # pyautogui.locateOnScreen( 'huitui.png' )
        x, y = pyautogui.center((1864, 215, 24, 16))  # 获得中心点
        pyautogui.click(x, y)
    time.sleep(3)
Ejemplo n.º 49
0
		spaceCount = 0
		#If the cursor is near a scroll bar, then scroll, up or down
		#scrollUpLoc = []
		# scrollUpLoc.append(pyautogui.locateAllOnScreen('scrollUpWindows.png', grayscale=True))
		# scrollUpLoc.append(pyautogui.locateAllOnScreen('scrollUpWindowsHighlighted.png', grayscale=True))
		#print('scrollUpLoc' + str(scrollUpLoc[0]))
		# print (list(pyautogui.locateAllOnScreen('scrollUpWindowsHighlighted.png', grayscale=True)))
		# print (list(pyautogui.locateAllOnScreen('scrollUpWindows.png', grayscale=True)))
		# scrollDownLoc = []
		# scrollDownLoc.append(pyautogui.locateAllOnScreen('scrollDownWindows.png', grayscale=True))
		# scrollDownLoc.append(pyautogui.locateAllOnScreen('scrollDownWindowsHighlighted.png', grayscale=True))
		#print('scrollDownLoc' + str(scrollDownLoc[0]))
		# list(scrollUpLoc)
		x, y = pyautogui.position()
		print (x, y)
		for k in (pyautogui.locateAllOnScreen(scrollUpFile, grayscale=True)):
			if (x > (k[0] - 5) and x < (k[0] + k[2] + 5) and y > (k[1] - 5) and y < (k[1] + k[3] + 5)):
				pyautogui.scroll(scrollDist)
				print("Scrolled up")
		for l in (pyautogui.locateAllOnScreen(scrollDownFile, grayscale=True)):
			if (x > (l[0] - 5) and x < (l[0] + l[2] + 5) and y > (l[1] - 5) and y < (l[1] + l[3] + 5)):
				pyautogui.scroll(-scrollDist)
				print("Scrolled down")
	i += 1






Ejemplo n.º 50
0
 def do_it(self,body):
     try:
         if body != None:
             head = body[:4]
             body = body[4:]
             if head == 'MOUS':
                 #MOUSE MOVE EVENT
                 mxy = body.split('|')
                 self.mous.move(int(mxy[0]),int(mxy[1]))
                 #pyautogui.moveTo(int(mxy[0]),int(mxy[1]))
             elif head == 'MCLK':
                 #MOUSE CLICK EVENT
                 mxy = body.split('|')
                 if mxy[2] == 'DCLK':
                     # DOUBLE CLICK
                     if mxy[3] == '1':
                         pyautogui.doubleClick(int(mxy[0]),int(mxy[1]),button='left')
                     elif mxy[3] == '2':
                         pyautogui.doubleClick(int(mxy[0]),int(mxy[1]),button='right')
                 elif mxy[2] == 'SCLK':
                     #SINGLE CLICK
                     if mxy[3] == '1':
                         pyautogui.click(int(mxy[0]),int(mxy[1]),button='left')
                     elif mxy[3] == '2':
                         pyautogui.click(int(mxy[0]),int(mxy[1]),button='right')
                 elif mxy[2] == 'DOWN':
                     #MOUSE PRESS
                     if mxy[3] == '1':
                         pyautogui.mouseDown(int(mxy[0]),int(mxy[1]),button='left')
                     elif mxy[3] == '3':
                         pyautogui.mouseDown(int(mxy[0]),int(mxy[1]),button='right')
                     elif mxy[3] == '4':
                         #SCROLL DOWN
                         pyautogui.scroll(-5,x=int(mxy[0]),y=int(mxy[1]))
                 elif mxy[2] == 'UP':
                     #MOUSE RELEASE
                     if mxy[3] == '1':
                         pyautogui.mouseUp(int(mxy[0]),int(mxy[1]),button='left')
                     elif mxy[3] == '3':
                         pyautogui.mouseUp(int(mxy[0]),int(mxy[1]),button='right')
                     elif mxy[3] == '4':
                         #SCROLL UP
                         pyautogui.scroll(5,x=int(mxy[0]),y=int(mxy[1]))
             elif head == "KCLK":
                 #KEYBOARD EVENT
                 key_ev = body.split('|')
                 if key_ev[0] == 'DOWN':
                     pyautogui.keyDown(key_ev[1])
                 elif key_ev[0] == "UP":
                     pyautogui.keyUp(key_ev[1])
                 elif key_ev[0] == "PRES":
                     pyautogui.press(key_ev[1])
             elif head == 'CLIP':
                 # CLIP BOARD EVENT
                 if body[:4] == 'COPY':
                     #send local clipboard to remote
                     lclip = pyperclip.paste()
                     screen_output_q.put_nowait(self.controler+lclip)
                 elif body[:4] == 'PAST':
                     #receive remote clipboad
                     data = body[4:]
                     pyperclip.copy(data)
              
         return True
     except Exception as e:
         print "INPUT CONTROL ERROR",e
         return False
Ejemplo n.º 51
0
    pyautogui.press('esc')
    pyautogui.moveTo(773, 235, duration=0.5)
    return skip_state


time.sleep(5)
image_num = 1
while True:
    slot = 1
    while slot <= 5:
        pyautogui.moveTo(150 + (slot - 1) * 255, 250, duration=0.5)
        #click image corresponding to this slot.
        pyautogui.doubleClick()
        time.sleep(0.5)
        if check_if_slot_is_link():
            slot += 1
            #go back to prev page (navagate back from link page)
            pyautogui.moveTo(17, 44, duration=0.5)
            pyautogui.click()
            time.sleep(3.5)
            pyautogui.moveTo(773, 235, duration=0.2)

        else:
            if run_algorithm():
                slot = 0
        slot += 1
        image_num += 1
    #Grab scroll bar and move down a row
    time.sleep(2)
    pyautogui.scroll(-318)  # scroll down 318 pixels