Exemplo 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
Exemplo n.º 2
0
def episode_get_mcn_and_ref():
    # get mcn
    mcn = pyperclip.copy('na')
    pya.moveTo(424, 474, duration=0.1)
    pya.dragTo(346, 474, duration=0.1)
    pya.hotkey('ctrl', 'c')
    mcn = pyperclip.paste()
    pya.moveTo(424, 474, duration=0.1)
    pya.click(button='right')
    pya.moveTo(481, 268, duration=0.1)
    pya.click()
    
    mcn = pyperclip.paste()
    mcn = mcn.replace(' ', '')
    # get ref
    ref = pyperclip.copy('na')
    pya.moveTo(500, 475, duration=0.1)
    pya.dragRel(-8, 0, duration=0.1)
    pya.hotkey('ctrl', 'c')
    ref = pyperclip.paste()
    pya.moveRel(8, 0, duration=0.1)
    pya.click(button='right')
    pya.moveTo(577, 274, duration=0.1)
    pya.click()
    
    ref = pyperclip.paste()
    return mcn, ref
Exemplo n.º 3
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)
Exemplo n.º 4
0
def draw():
  distance = 200
  while distance > 0:
    pyautogui.dragRel(distance, 0, duration = 0.2)
      distance = distance - 5
      pyautogui.dragRel(0, distance, duration = 0.2)
      pyautogui.dragRel(-distance, 0, duration = 0.2)
      distance = distance - 5
      pyautogui.dragRel(0, -distance, duration = 0.2)
def draw_rect():
    time.sleep(5)
    distance = 200
    while distance > 0:
        pyautogui.dragRel(distance, 0, duration=0.5)  # move right
        distance -= 5
        pyautogui.dragRel(0, distance, duration=0.5)  # move down
        pyautogui.dragRel(-distance, 0, duration=0.5)  # move left
        distance -= 5
        pyautogui.dragRel(0, -distance, duration=0.5)  # move up
def drawSpiral():
    DUR = .2
    time.sleep(5)
    pyautogui.click()
    distance = 200

    while distance > 0:
        pyautogui.dragRel(distance, 0, duration=DUR)
        distance -= 5
        pyautogui.dragRel(0, distance, duration=DUR)
        pyautogui.dragRel(-distance, 0, duration=DUR)
        distance -= 5
        pyautogui.dragRel(0, -distance, duration=DUR)
Exemplo n.º 7
0
def draw_circles():
    x, y = pyautogui.position()
    time.sleep(5)
    pyautogui.click()
    distance = 200
    while distance > 0:
        pyautogui.dragRel(distance, 0, duration=0.2)
        distance -= 5
        pyautogui.dragRel(0, distance, duration=0.2)
        pyautogui.dragRel(-distance, 0, duration=0.2)
        distance -= 5
        pyautogui.dragRel(0, -distance, duration=0.2)
    return
def spiralPaint():
    dist = 200;
    de = 5;
    dur = 0.2;
    pyautogui.click()
    while dist>de * 5:
        pyautogui.dragRel(dist, 0, duration = dur);
        dist = dist - de
        pyautogui.dragRel(0, dist, duration = dur);
        dist = dist - de
        pyautogui.dragRel( - dist, 0, duration = dur);
        dist = dist - de
        pyautogui.dragRel(0,  - dist, duration = dur);
        dist = dist - de
Exemplo n.º 9
0
def resetWindow():
    '''
        method to set the trainstation window to default
    '''
    print('Resetting Window...')
    # move to dragging position
    pygui.moveTo(1516, 379)
    pygui.click()

    # drag up
    for x in range(1, 4):
        pygui.dragRel(0, -100, .15)
        pygui.moveTo(1516, 379)

    # drag left
    for x in range(1, 4):
        pygui.dragRel(-100, 0, .15)
        pygui.moveTo(1516, 379)

    # zoom out
    for x in range(1, 8):
        pygui.scroll(-50)
Exemplo n.º 10
0
def draw():
    """
    This function gives you 10 seconds to open up your canvas and select your 
    drawing tool. Hover your mouse over the starting position. 

    """
    time.sleep(10)

    try:
        frdm = serial.Serial('/dev/tty.usbmodem1421', 9600)  # replace
    except:
        print("failed to connect")
        exit()

    pyautogui.click()
    while True:
        latestData = frdm.readline()
        delX, delY, buttonPressed = parse(latestData)
        if buttonPressed:
            pyautogui.dragRel(delX, delY, duration=0.1, button='left')
        else:
            pyautogui.moveRel(delX, delY, duration=0.1)
Exemplo n.º 11
0
Arquivo: run.py Projeto: HeziPad/EFbot
def power():
    pyautogui.click(1220, 980)
    time.sleep(wR.delay * 2)
    if pyautogui.locateCenterOnScreen('./pictures/shopOn.png', region=(1175, 940, 100, 100)):
        logging.info('shopOn found')
        pyautogui.click(970, 460)
        try:
            pyautogui.moveTo(930, 770)
            pyautogui.dragRel(0, 200, 1, tween=pyautogui.easeOutQuad, button='left')
            time.sleep(wR.delay * 2)
            pyautogui.click(1200, 765)
            time.sleep(wR.delay * 2)
            try:
                x, y = pyautogui.locateCenterOnScreen('./pictures/powerConfirm.png', region=(800, 775, 100, 70))
                logging.info('powerConfirm found')
                pyautogui.click(x, y)
                time.sleep(wR.delay)
                wR.power_used = True
            except Exception as e:
                logging.debug('powerConfirm NOT found {}'.format(e))
        except Exception as e:
            logging.debug('ViewAd NOT found {}'.format(e))
Exemplo n.º 12
0
 def drawI(self, startX, startY):
     pyautogui.moveTo(startX + 25, startY)
     pyautogui.dragRel(0, 100)
     pyautogui.moveRel(-30, 0)
     pyautogui.dragRel(60, 0)
     pyautogui.moveTo(startX + 25, startY)
     pyautogui.moveRel(-30, 0)
     pyautogui.dragRel(60, 0)
Exemplo n.º 13
0
def Draw_luoquan():
    print(pyautogui.position())

    pyautogui.click()
    distance = 100
    interval = 20
    dur = 0.1

    while distance > 0:
        pyautogui.dragRel(distance, 0, dur)
        distance = distance - interval
        pyautogui.dragRel(0, distance, dur)
        pyautogui.dragRel(-distance, 0, dur)
        distance = distance - interval
        pyautogui.dragRel(0, -distance, dur)
Exemplo n.º 14
0
def squarespiral(current_colors_xy, canvas_width, canvas_height):
    name, (place, row) = r.choice(list(current_colors_xy.items()))
    gui.click(place, row, 2, 0.2)
    # ^^ choose a color
    a, b = canvas_height
    gui.click(r.randint(0, canvas_width), r.randint(a, b))
    distance = r.randint(20, 300)
    increment = r.randint(4, 10)
    while distance > 0:
        gui.dragRel(distance, 0)  # move right
        distance -= increment
        gui.dragRel(0, distance)  # move down
        gui.dragRel(-distance, 0)  # move left
        distance -= increment
        gui.dragRel(0, -distance)  # move up
Exemplo n.º 15
0
def spiralDraw():
    """When you run this program, there will be a five-second delay 
    for you to move the mouse cursor over the drawing program’s window 
    with the Pencil or Brush tool selected. Then spiralDraw.py will take 
    control of the mouse and click to put the drawing program in focus"""
    time.sleep(5)
    pyautogui.click()  # click to put drawing program in focus
    distance = 200
    while distance > 0:
        pyautogui.dragRel(distance, 0, duration=0.2)  # move right
        distance = distance - 5
        pyautogui.dragRel(0, distance, duration=0.2)  # move down
        pyautogui.dragRel(-distance, 0, duration=0.2)  # move left
        distance = distance - 5
        pyautogui.dragRel(0, -distance, duration=0.2)  # move up
Exemplo n.º 16
0
def drag_relative(distance: int,
                  direction: Direction,
                  btn: str = "left",
                  duration_ms: int = 100) -> Tuple[int, int]:
    x_offset = 0
    y_offset = 0
    if direction is Direction.UP:
        y_offset = -distance
    elif direction is Direction.DOWN:
        y_offset = distance
    elif direction is Direction.RIGHT:
        x_offset = distance
    elif direction is Direction.LEFT:
        x_offset = -distance
    elif direction is Direction.UPPER_RIGHT:
        x_offset = int(distance / SQRT_TWO)
        y_offset = -x_offset
    elif direction is Direction.UPPER_LEFT:
        x_offset = -int(distance / SQRT_TWO)
        y_offset = x_offset
    elif direction is Direction.LOWER_RIGHT:
        x_offset = int(distance / SQRT_TWO)
        y_offset = x_offset
    elif direction is Direction.LOWER_LEFT:
        y_offset = int(distance / SQRT_TWO)
        x_offset = -y_offset

    if btn.lower() == "left":
        btn = pyautogui.PRIMARY
    elif btn.lower() == "right":
        btn = pyautogui.SECONDARY

    pyautogui.dragRel(xOffset=x_offset,
                      yOffset=y_offset,
                      duration=duration_ms / 1000,
                      button=btn)

    return (x_offset, y_offset)
def convert_book(pages=10):
    x = list(range(0, pages, 2))
    for i in x:
        time.sleep(1)
        if pyauto.pixelMatchesColor(979, 588, (255, 255, 255)):
            '''Left Page Download'''
            pyauto.leftClick(980, 550)
            pyauto.hotkey('ctrl', 'prtsc')
            pyauto.moveTo(210, 135)
            time.sleep(1.1)
            pyauto.dragRel(770, 890, duration=1.3)
            time.sleep(0.5)
            pyauto.hotkey('ctrl', 's')
            time.sleep(1)
            pyauto.typewrite(str(i))
            time.sleep(0.45)
            pyauto.press('enter')

            '''Right Page Download'''
            pyauto.leftClick(980, 550)
            pyauto.hotkey('ctrl', 'prtsc')
            pyauto.moveTo(960, 130)
            time.sleep(1.1)
            pyauto.dragRel(780, 890, duration=1.3)
            time.sleep(0.5)
            pyauto.hotkey('ctrl', 's')
            time.sleep(1)
            pyauto.typewrite(str(i+1))
            time.sleep(0.45)
            pyauto.press('enter')

            '''Next Page'''
            time.sleep(0.75)
            pyauto.rightClick()
            pyauto.press('right')

        else:
            continue
Exemplo n.º 18
0
def ai_make_bet(rise, made_rises, x_y):
    pyautogui.moveTo(*x_y, 0.1)
    pyautogui.dragRel(-75, 0, 0.1, button='left')

    print('RISING {}. SO WE...\n'.format(rise))

    if rise == 0:
        print('PRESS F6 CHECK')

        pyautogui.press('f6')

        time.sleep(0.2)

    else:
        print('rise {}'.format(rise))
        print('made_rise {}'.format(made_rises))
        input_rise = str(rise + made_rises)

        if len(input_rise) == 1:
            input_rise = '00' + input_rise
        elif len(input_rise) == 2:
            input_rise = '0' + input_rise

        print('input_rise {}'.format(input_rise))

        for i, amo in enumerate(input_rise):
            if len(input_rise) - i != 2:
                pyautogui.press(amo)
            else:
                pyautogui.press('.')
                pyautogui.press(amo)

        print('\n\nINPUT_RISING {}.\n\nPRESS F7\n\n'.format(input_rise))

        pyautogui.press('f7')

        time.sleep(0.2)
Exemplo n.º 19
0
def mob_farm():

    # Constantly checks whether or not you are at campaign view
    var = -1
    x = 0
    y = 0
    while var < 0:
        is_at_field_screen = auto.locateOnScreen('FieldMenu.png',
                                                 grayscale=True)
        print(is_at_field_screen)
        sleep(1)
        if is_at_field_screen is not None:
            print("campaign screen detected")
            x = is_at_field_screen[0]
            y = is_at_field_screen[1]
            auto.moveTo(x + 530, y + 350)
            while is_at_field_screen == auto.locateOnScreen('FieldMenu.png'):
                delay = 0.5
                auto.dragRel(
                    60,
                    0,
                    delay,
                    auto.easeInOutQuad,
                    button='left',
                )
                auto.dragRel(0, 100, delay, auto.easeInOutQuad, button='left')
                auto.dragRel(-60, 0, delay, auto.easeInOutQuad, button='left')
                auto.dragRel(0, -100, delay, auto.easeInOutQuad, button='left')

        else:
            print("campaign map not found / in battle")
            # checks if in combat
            in_combat = auto.pixelMatchesColor(x, y + 700, (160, 182, 191))
            auto_battle_btn_x, auto_battle_btn_y = (x, y + 700)
            if in_combat is True:
                print("In battle detected")
                auto.moveTo(auto_battle_btn_x, auto_battle_btn_y)
                auto.click(clicks=1)
                print("auto battle activated")
                while in_combat is True:
                    vic = auto.pixelMatchesColor(x + 748, y + 69,
                                                 (227, 201, 138))
                    if vic is True:
                        print("click")
                        auto.click(clicks=3, interval=0.2)
                        in_combat = False
Exemplo n.º 20
0
def check_city():
    check = scanwindow()
    drag_dist = 300
    #check if it is main window or not. if not make it into main window.
    a = auto.locate(r'IMG\window_main.png', check, confidence=0.6)
    if a == None:
        check_window()

    while True:
        for i in range(len(boards)):
            check = scanwindow()
            whatcity = auto.locate(r'IMG\%s.png' % boards[i],
                                   check,
                                   confidence=0.6)
            if whatcity != None:
                print('you are at ' + str(boards[i][6:] + '!'))
                areas_name = boards[i][6:]
                break

        if whatcity == None:
            a = scanwindow()
            auto.moveTo(x=main_x + 240, y=main_y + 215, duration=0.5)
            auto.dragRel(drag_dist, 0, duration=0.30)
            time.sleep(2)
            b = auto.screenshot(region=(main_x + 120, main_y + 215, 200, 200))
            c = auto.locate(b, a, confidence=0.8)
            if c != None:
                drag_dist = drag_dist * -1
                continue
            if c == None:
                drag_dist = drag_dist
                continue

        if whatcity:
            break
    return areas_name
Exemplo n.º 21
0
def imhotepvrBotActions():
    initPos = [954, 954, 623, 623]
    patientPos = [928, 928, 482, 482]
    layerPos = [670, 670, 1003, 1003]
    liverMeshPos = [714, 714, 274, 274]
    XPos = [1244, 1244, 999, 999]
    time.sleep(6)
    keyboard_action.mouse_click(initPos)
    time.sleep(12)
    keyboard_action.mouse_click(patientPos)
    time.sleep(4)
    for i in range(10):
        keyboard.press('up')
        time.sleep(0.2)
        keyboard.release('up')
    keyboard_action.mouse_click(layerPos)
    time.sleep(1)
    keyboard_action.mouse_click(liverMeshPos)
    time.sleep(1)
    pyautogui.dragRel(-100, 0, duration=1)
    time.sleep(2)
    keyboard_action.mouse_click(XPos)
    time.sleep(1)
    return
Exemplo n.º 22
0
def c():
    try:
        mouse.PAUSE = 0.01
        init.centralizar()
        fim = 5000
        while fim > 0:
            x = randint(-30, 30)
            y = randint(-30, 30)
            z = randint(1, 3)
            if z == 1:
                mouse.dragRel(x, 0)
            else:
                mouse.dragRel(0, y)
            posicao_x, posicao_y = mouse.position()
            if posicao_y > 600 or posicao_y < 191 or posicao_x > 1341 or posicao_x < 100 and posicao_y < 100:
                init.centralizar()
                continue
            fim -= 1

    except Exception as cancelamento:
        print('Processo cancelado! Erro:', cancelamento)
    finally:
        mouse.PAUSE = 0.1
        mouse.mouseUp()
Exemplo n.º 23
0
def put_cursor_and_get_from_input(x_y, game_num=0):
    win32clipboard.OpenClipboard()
    win32clipboard.EmptyClipboard()
    win32clipboard.CloseClipboard()

    time.sleep(0.02)

    print(f'Двигаем мышку в {x_y}')
    pyautogui.moveTo(*x_y, 0.1)
    print(f'Выделяем {x_y}, реальная позиция {pyautogui.position()}')
    pyautogui.dragRel(-75, 0, 1, button='left')
    print(f'В конце выделения реальная позиция {pyautogui.position()}')
    pyautogui.keyDown('ctrl')
    pyautogui.press('c')
    pyautogui.keyUp('ctrl')

    win32clipboard.OpenClipboard()

    value = win32clipboard.GetClipboardData(13)

    win32clipboard.CloseClipboard()

    print('Получено значение {}'.format(value))

    try:
        dollars, cents = value.split('.')
    except ValueError:
        dollars = value
        cents = None

    if not cents:
        res_value = int(str(dollars) + str('00'))
    else:
        res_value = int(str(dollars) + str(cents))

    return res_value
Exemplo n.º 24
0
def control_mouse(position):
    commands = {
        'near': pg.dragRel(5, 5),  #pg.click(button='left', clicks=1), 
        'same_width':
        pg.dragRel(30, 0),  #pg.click(button='right', clicks=2, interval=0.25),
        'same_height': pg.dragRel(0, 30),  #pg.scroll(30),
        'right_up': pg.dragRel(30, 30),
        'right_down': pg.dragRel(30, -30),
        'left_up': pg.dragRel(-30, 30),
        'left_down': pg.dragRel(-30, -30)
    }
    print(pg.position())
    commands[position]
    return True
Exemplo n.º 25
0
 def system_draw_01(x, y):
     """
     :param x: 绘画初始x坐标
     :param y: 绘画初始y坐标
     :return:
     """
     # 移动画笔初始位置
     pyautogui.moveTo(x=x, y=y, duration=0)
     sleep(0.5)
     distance = 300
     while distance > 0:
         # 进行绘画操作
         pyautogui.dragRel(distance, 0, duration=0.1)
         distance = distance - 50
         pyautogui.dragRel(0, distance, duration=0.1)
         pyautogui.dragRel(-distance, 0, duration=0.1)
         distance = distance - 50
         pyautogui.dragRel(0, -distance, duration=0.1)
Exemplo n.º 26
0
def attack():
    print("Attack!")
    #进攻
    axis_click(154, 914)  #icon of attack
    axis_click(1422, 660)  #icon of find

    #判断是否进攻
    judge_sucess("Attack_cup", 5)

    (g_number, e_number, b_number) = count(list2)

    while (g_number < 170000 or e_number < 170000):
        axis_click(1700, 753)
        judge_sucess("Attack_cup", 5)
        (g_number, e_number, b_number) = count(list2)
        total = g_number + e_number + b_number
    #调整画面
    pyautogui.moveTo(1920 / 2, 1080 / 2)
    pyautogui.dragRel(0, 200, duration=0.3)
    pyautogui.scroll(500)
    sleep(3)
    pyautogui.dragRel(-300, 0, duration=0.25)
    sleep(2)

    #下兵
    window_capture("screenshot.jpg")
    '''
    click('Attack_lig')
    pyautogui.moveTo(1920/2,1080/2)
    pyautogui.click(clicks=3,interval=0.2)
    '''
    click('Attack_clan')
    pyautogui.press('x')
    place('z', 'x', 'c', 'v', 'b', 'n')
    place('a', 's', 'd', 'f', 'g', 'h')
    click('Attack_queen')
    #click('Attack_king')
    pyautogui.press('s')

    #调整画面
    pyautogui.moveTo(1920 / 2, 1080 / 2)
    pyautogui.dragRel(0, -200, duration=0.3)
    pyautogui.scroll(-500)
    #下兵
    place('q', 'w', 'e', 'r', 't', 'y')
    place('u', 'j', 'm', 'i', 'k', 'o')
    click('Attack_queen')
    #click('Attack_king')

    sleep(45)
    judge_sucess("return_home", 15)
    axis_click(941, 926)
    print("Return home!")
Exemplo n.º 27
0
def main():
    print(pyautogui.size())
    x, y = pyautogui.size()

    pyautogui.moveTo(0.5 * x, 0.99 * y, duration=1)

    pyautogui.click(10, 650)
    time.sleep(2)
    #drawing a square
    pyautogui.moveTo(500, 300, duration=1)
    pyautogui.dragRel(x, 0, duration=1)
    pyautogui.dragRel(0, x, duration=1)
    pyautogui.moveTo(500, 300, duration=1)
    pyautogui.dragRel(0, x, duration=1)  #nie działa -x nie wiem dlaczego?
    pyautogui.dragRel(x, 0, duration=1)
    #saving a work of art
    #pyautogui.hotkey("ctrlleft", "s")
    #pyautogui.click(960, 720)
    print("Kwadrat o boku", x)
Exemplo n.º 28
0
 def input_control(self, count_defects, img_src):
     # update position difference with previous frame (for move mouse)
     d_x, d_y = 0, 0
     if self.preCX is not None:
         d_x = self.ROIx - self.preCX
         d_y = self.ROIy - self.preCY
     
     # checking current command, and filter out unstable hand gesture
     cur_cmd = 0
     if self.cmd_switch:
         if self.last_cmds.count(count_defects) >= self.last_cmds.n_maj:
             cur_cmd = count_defects
             #print 'major command is ', cur_cmd
         else:
             cur_cmd = 0     # self.last_cmds.major()
     else:
         cur_cmd = count_defects
     
     # send mouse input event depend on hand gesture
     if cur_cmd == 1:
         str1 = '2, move mouse dx,dy = ' + str(d_x*3) + ', ' + str(d_y*3)
         cv2.putText(img_src, str1, (50, 50), cv2.FONT_HERSHEY_TRIPLEX, 2, (0, 0, 255), 2)
         if self.cmd_switch:
             pyautogui.moveRel(d_x*3, d_y*3)
             self.last_cmds.push(count_defects)
             #pyautogui.mouseDown(button='left')
             #pyautogui.moveRel(d_x, d_y)
         #else:
         #    pyautogui.mouseUp(button='left')
     elif cur_cmd == 2:
         cv2.putText(img_src, '3 Left (rotate)', (50, 50), cv2.FONT_HERSHEY_TRIPLEX, 2, (0, 0, 255), 2)
         if self.cmd_switch:
             pyautogui.dragRel(d_x, d_y, button='left')
             self.last_cmds.push(count_defects)
             #pyautogui.scroll(d_y,pause=0.2) 
     elif cur_cmd == 3:
         cv2.putText(img_src, '4 middle (zoom)', (50, 50), cv2.FONT_HERSHEY_TRIPLEX, 2, (0, 0, 255), 2)
         if self.cmd_switch:
             pyautogui.dragRel(d_x, d_y, button='middle')
             self.last_cmds.push(count_defects)
     elif cur_cmd == 4:
         cv2.putText(img_src, '5 right (pan)', (50, 50), cv2.FONT_HERSHEY_TRIPLEX, 2, (0, 0, 255), 2)
         if self.cmd_switch:
             pyautogui.dragRel(d_x, d_y, button='right')
             self.last_cmds.push(count_defects)
     elif cur_cmd == 5:
         cv2.putText(img_src, '1 fingertip show up', (50, 50), cv2.FONT_HERSHEY_TRIPLEX, 2, (0, 0, 255), 2)
         if self.cmd_switch:
             self.last_cmds.push(count_defects)
     else:
         cv2.putText(img_src, 'No finger detect!', (50, 50), cv2.FONT_HERSHEY_TRIPLEX, 2, (0, 0, 255), 2)
         if self.cmd_switch:
             self.last_cmds.push(count_defects)  # no finger detect or wrong gesture
Exemplo n.º 29
0
def patternedMovements(config='right'):
   if (((round(100*time.time()))%2)==0):#&(x!=(round(time.time()))):
      x,y=pyautogui.position()
     
      if x>=350:
         pyautogui.dragTo(210, 675)
      pyautogui.dragRel(33,0)

      if x>=480:
         config='left'
      elif x<=250:
         config='right'
      else:
         pass
      
      if config=='left':
         pyautogui.dragRel(-33,0)
      elif config=='right':
         pyautogui.dragRel(33,0)
      else:
         print(config)
      print(config)
      return config







      # pyautogui.dragRel(33,0)
         # print(cposition, " ", round(time.time()))
         
          # if cposition==0:
          #    dragTo(365, 675)
          #    x=round(time.time())
          #    cposition+=1
          #    time.sleep(1)
          # elif cposition==1:
          #    dragTo(543, 675)
          #    x=round(time.time())
          #    cposition+=1
          #    time.sleep(1)
          # elif cposition==2:
          #    dragTo(210, 675)
          #    x=round(time.time())
          #    cposition-=2
          #    time.sleep(1)
          # else:
          #    print("error")
         # print(cposition, " ", round(time.time()))
Exemplo n.º 30
0
def drawthis():
    draw = pyautogui
    time.sleep(5)
    #take your mouse to the program during the 5 seconds delay
    pyautogui.click()

    distance = 200
    while distance > 0:
        draw.dragRel(distance, 0, duration=0.2)  #move right
        distance = distance - 5
        pyautogui.dragRel(0, distance, duration=0.2)  #move down
        pyautogui.dragRel(-distance, 0, duration=0.2)  #move left
        distance = distance - 5
        pyautogui.dragRel(0, -distance, duration=0.2)  #move up
Exemplo n.º 31
0
    def on_touch_down(self, touch):
        with self.canvas:
            touch.ud["line"] = Line(points=(touch.x, touch.y))
            super(DrawInput, self).on_touch_down(touch)
            self.remove_widget(self.b)
            self.add_widget(self.b)

        time.sleep(5)
        pyautogui.click()
        while self.distance > 0:
            print(self.distance)

            pyautogui.dragRel(self.distance, 0, duration=0.2,
                              button='left')   # move right
            self.distance -= 5
            pyautogui.dragRel(0, self.distance, duration=0.2,
                              button='left')   # move down
            pyautogui.dragRel(-self.distance, 0, duration=0.2,
                              button='left')  # move left
            self.distance -= 5
            pyautogui.dragRel(0, -self.distance, duration=0.2,
                              button='left')  # move up
Exemplo n.º 32
0
def mspaint_test():
    # setting fail safes
    pyautogui.FAIL_SAFE = True
    pyautogui.PAUSE = 1

    # open MS paint
    os.system('START "" mspaint')

    # move mouse pointer to center of screen
    screenWidth, screenHeight = pyautogui.size()
    #pyautogui.moveTo(screenWidth/2, screenHeight/2)
    pyautogui.moveTo(screenWidth / 4, screenHeight / 4)

    # drag mouse
    distance = 200
    while distance > 0:
        pyautogui.dragRel(distance, 0, duration=0.1)  # move right
        distance -= 5
        pyautogui.dragRel(0, distance, duration=0.1)  # move down
        pyautogui.dragRel(-distance, 0, duration=0.1)  # move left
        distance -= 5
        pyautogui.dragRel(0, -distance, duration=0.1)  # move up
Exemplo n.º 33
0
def mouseDrag():
    """
    PyAutoGUI的dragTo()和dragRel()函数与moveTo()和moveRel()函数类似。
    另外,他们有一个button参数可以设置成left,middle和right三个键。例如:
    
    :return: 
    """
    #  按住鼠标左键,把鼠标拖拽到(100, 200)位置
    pyautogui.dragTo(100, 200, button='left')
    #  按住鼠标左键,用2秒钟把鼠标拖拽到(300, 400)位置
    pyautogui.dragTo(300, 400, 2, button='left')
    #  按住鼠标右键,用2秒钟把鼠标拖拽到(30,0)位置
    pyautogui.dragTo(30, 0, 2, button='right')

    distance = 200
    while distance > 0:
        pyautogui.dragRel(distance, 0, duration=0.5)  # 向右
        distance -= 5
        pyautogui.dragRel(0, distance, duration=0.5)  # 向下
        pyautogui.dragRel(-distance, 0, duration=0.5)  # 向左
        distance -= 5
        pyautogui.dragRel(0, -distance, duration=0.5)  # 向上
        break
Exemplo n.º 34
0
def main():
    print(pyautogui.size())
    x, y = pyautogui.size()
    print("Wybierz a aby narysowac kwadrat, wybierz b aby zagrać w sapera")
    option = input()
    if option == "a":
        print("Podaj dlugosc boku w pixelach:")
        bok = input()
        pyautogui.hotkey("ctrlleft", "altleft", "t")
        time.sleep(1)
        pyautogui.typewrite("cd Pobrane")
        time.sleep(1)
        pyautogui.hotkey("enter")
        time.sleep(1)
        pyautogui.typewrite("./krita.appimage")
        time.sleep(1)
        pyautogui.hotkey("enter")
        time.sleep(20)
        pyautogui.click(0.7 * x, 0.7 * y)
        time.sleep(1)
        pyautogui.hotkey("ctrlleft", "n")
        time.sleep(1)
        pyautogui.hotkey("enter")
        time.sleep(1)
        pyautogui.hotkey("ctrlleft", "q")  #pełny ekran
        time.sleep(1)
        pyautogui.moveTo(0.2 * x, 0.2 * y, duration=1)
        pyautogui.dragRel(bok, 0, duration=1)
        pyautogui.dragRel(0, bok, duration=1)
        pyautogui.moveTo(0.2 * x, 0.2 * y, duration=1)
        pyautogui.dragRel(0, bok,
                          duration=1)  # nie działa -x nie wiem dlaczego?
        pyautogui.dragRel(bok, 0, duration=1)
    elif option == 2:
        print("W trakcie budowy")
    else:
        print("Wybrano niedozwolony znak")
Exemplo n.º 35
0
 def paint_mouse(self):
     time.sleep(2)
     sub.call('start mspaint', shell=True)
     time.sleep(2)
     screenWidth, screenHeight = py.size()
     currentMouseX, currentMouseY = py.position()
     py.moveTo(100, 150)
     py.click()
     py.moveRel(None, 10)  # move mouse 10 pixels down
     py.doubleClick()
     py.moveTo(
         300, 280, duration=.75, tween=py.easeInOutQuad
     )  # use tweening/easing function to move mouse over 2 seconds.
     py.typewrite('Hello world!', interval=0.25
                  )  # type with quarter-second pause in between each key
     py.press('esc')
     py.keyDown('shift')
     py.press(['left', 'left', 'left', 'left', 'left', 'left'])
     py.keyUp('shift')
     py.hotkey('ctrl', 'c')
     distance = 500
     while distance > 0:
         py.dragRel(distance, 0, duration=0.14)  # move right
         distance -= 10
         py.dragRel(0, distance, duration=0.14)  # move down
         py.dragRel(-distance, 0, duration=0.14)  # move left
         distance -= 15
         py.dragRel(0, -distance, duration=0.14)  # move up
     py.moveTo(1250, 8, 3, py.easeInQuad)
     for i in range(1):
         py.click(1250, 8)
     py.PAUSE = 0.5
     py.typewrite(['tab'])
     py.PAUSE = 2
     py.typewrite(['enter'])
     time.sleep(2)
def sierpinki(sideLength):
    used = False
    if (sideLength <= 10):
        return

    for i in range(sideLength):
        pyg.dragRel(1, 1, duration=moveDuration)
        if (i + sideLength) / 2 < i and not used:
            sierpinki(sideLength // 2)
            used = True
    for i in range(sideLength * 2):
        pyg.dragRel(-1, 0, duration=moveDuration)
    for i in range(sideLength):
        if (i + sideLength) / 2 < i and not used:
            sierpinki(sideLength // 2)
            used = True
        pyg.dragRel(1, -1, duration=moveDuration)
Exemplo n.º 37
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
Exemplo n.º 38
0
def main():
    print('请确保打开百度地图')
    startpos = GetStartPoint()
    endpos = GetEndPoint()
    print('截图张数25张,分布5x5,每张图片大小为:{}x{}'.format(endpos[0]-startpos[0],endpos[1]-startpos[1]))
    print('请确认设置<截图工具>的快捷方式为Ctrl + Alt + ;')
    Au.click(startpos)
    y = 0
    while y < 5:
        x = 0
        while x < 5:
            Au.hotkey('ctrl','altleft',';')
            time.sleep(2)
            Au.click(jietupos)
            time.sleep(2)
            Au.moveTo(startpos,duration=2)
            time.sleep(2)
            Au.dragTo(endpos,duration=2.0)
            time.sleep(4)
            Au.hotkey('ctrl','s')
            time.sleep(2)
            strtemp = 'Line-' + str(y) + 'Colunms-' + str(x)
            Au.typewrite(strtemp)
            time.sleep(2)
            Au.typewrite('\n')
            time.sleep(2)
            Au.hotkey('altleft','f4')
            time.sleep(2)
            Au.moveTo(endpos,duration=2)
            time.sleep(2)
            Au.dragRel(startpos[0]-endpos[0],0,duration=20)
            x+=1
            time.sleep(2)
        x = 0
        while x < 5:
            Au.moveTo(startpos,duration=2)
            time.sleep(2)
            Au.dragRel(1750,0,duration=20)
            time.sleep(2)
            x+=1
        Au.moveTo(endpos,duration=2)
        Au.dragRel(0,startpos[1]-endpos[1],duration=10)
        Au.click(Au.position())
        time.sleep(2)
        y+=1
Exemplo n.º 39
0
import pyautogui

pyautogui.moveTo(pyautogui.locateCenterOnScreen('startmenu.PNG'), duration=1)
pyautogui.sleep(1)
pyautogui.click()
pyautogui.sleep(1)
pyautogui.typewrite('PAINT', interval=1)
pyautogui.sleep(1)
pyautogui.moveTo(pyautogui.locateCenterOnScreen('paint.PNG'), duration=1)
pyautogui.click()
pyautogui.dragRel(400, 0, duration=1)
pyautogui.click()
pyautogui.moveTo(pyautogui.locateCenterOnScreen('brush.PNG'), duration=0.5)
pyautogui.moveTo(pyautogui.locateCenterOnScreen('brush2.PNG'), duration=0.5)
pyautogui.click()
pyautogui.click()
pyautogui.moveRel(-260, 180, duration=0.5)
pyautogui.click()
pyautogui.dragRel(400, 0, duration=0.2)
pyautogui.dragRel(0, 200, duration=0.2)
pyautogui.dragRel(-400, 0, duration=0.2)
pyautogui.dragRel(0, -200, duration=0.2)
pyautogui.moveTo(pyautogui.locateCenterOnScreen('abutton.PNG'), duration=0.5)
pyautogui.click()
pyautogui.moveRel(-104, 280, duration=0.5)
pyautogui.click()
pyautogui.typewrite('BATATA, VAI SE LASCAR', interval=0.2)
pyautogui.moveRel(50, 50, duration=0.3)
pyautogui.click()
# Fail-safe mode (prevent from ou of control)
pyautogui.FAILSAFE = True
pyautogui.PAUSE = 1.0 # pause each pyautogui function 1. sec

# testing screen shot
s = pyautogui.screenshot()
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)
Exemplo n.º 41
0
import math

# pause for 10 seconds
time.sleep(10)  

# coordinates of bottom right corner
end_x, end_y = (pyautogui.size())

start_x, start_y = end_x/2, end_y/2

# set size of cube
cube_size=100

x_dest=cube_size*math.cos(math.pi/6)
y_dest=cube_size*math.sin(math.pi/6)



pyautogui.moveTo(start_x, start_y)
pyautogui.dragRel(0, cube_size)
pyautogui.dragRel(-x_dest, y_dest)
pyautogui.dragRel(-x_dest, -y_dest) 
pyautogui.dragRel(x_dest, -y_dest) 
pyautogui.dragRel(0, -cube_size)    
pyautogui.dragRel(x_dest, y_dest)
pyautogui.dragRel(0, cube_size)
pyautogui.dragRel(-x_dest, -y_dest)
pyautogui.dragRel(-x_dest, y_dest) 
pyautogui.dragRel(0, -cube_size) 
pyautogui.dragRel(x_dest, -y_dest) 
Exemplo n.º 42
0
# With the mouse cursor over the drawing application’s canvas and the Pencil or Brush tool selected

import pyautogui, time
time.sleep(5)
pyautogui.click() # click to put drawing program in focus
distance = 200
while distance > 0:
	
	pyautogui.dragRel(distance, 0, duration=0.2)   # move right
	
	distance = distance - 5
	
	pyautogui.dragRel(0, distance, duration=0.2)   # move down
	
	pyautogui.dragRel(-distance, 0, duration=0.2)  # move left        
	distance = distance - 5
	pyautogui.dragRel(0, -distance, duration=0.2)
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)
Exemplo n.º 44
0
#! /usr/bin/env python3
# coding = utf-8

# spiralDraw.py - draw picture.

import pyautogui
import time

time.sleep(5)
pyautogui.click()

distance = 200
while distance > 0:
    # move right
    pyautogui.dragRel(distance, 0, duration=0.2)
    # move down
    distance = distance - 5
    pyautogui.dragRel(0, distance, duration=0.2)
    # move left
    pyautogui.dragRel(-distance, 0, duration=0.2)
    # move up
    distance = distance - 5
    pyautogui.dragRel(0, -distance, duration=0.2)


Exemplo n.º 45
0
import pyautogui, time

time.sleep(5)
pyautogui.click() # Click to put the program into focus
distance = 300
while distance > 0:
	pyautogui.dragRel(distance, 0, duration=0) # Move right
	distance = distance - 5
	pyautogui.dragRel(0, distance, duration=0) # Move down
	pyautogui.dragRel(-distance, 0, duration=0) # Move left
	distance = distance - 5
	pyautogui.dragRel(0, -distance, duration=0) # Move up
Exemplo n.º 46
0
    def dataReceived(self, data):
        #fetch commands from data
        cmds = data.split(';');
        
        #exec each command
        for cmd in cmds:
            
            # cmd = object : action < :param < :param < :param ... >>>
            # each cmd contains atleast 'object' & 'action'
            splitted = cmd.split(':');
            
            #invalid cmd?
            if (len(splitted)<2):
                continue
            
            #number of params
            params   = len(splitted)-2

            obj = splitted[0]
            act = splitted[1]
            
            if obj == "mouse":   
                
                if act == "click":
                    if params == 0:
                        pyautogui.click()
                    
                    #click provided a parameter: number of clicks!
                    elif params == 1:
                        clicks = int(float(splitted[2]))
                        pyautogui.click(clicks=clicks)
            
                elif act == "doubleclick":
                    pyautogui.doubleClick()

                elif act == "tripleclick":
                    pyautogui.tripleClick()
                                    
                elif act == "rightclick":
                    pyautogui.rightClick()
                
                elif act == "scroll":
                    if params == 2:
                        x = int(float(splitted[2]))
                        y = int(float(splitted[3]))
                        pyautogui.hscroll(x);
                        pyautogui.vscroll(y);
                                    
                elif act == "drag":
                    if params == 1:
                        # indicate that dragging is activated, but not yet started
                        if splitted[2] == "start":
                            self.dragActive = True
                        # indicate that dragging in disactivated
                        elif splitted[2] == "end":
                            self.dragActive = False
                            #stop dragging when active
                            if self.dragStarted:
                                self.dragStarted = False
                                pyautogui.mouseUp()
                        else:
                            print "Unknown value for 'drag':" + splitted[2]

                    elif params == 2:
                        #are we already dragging?
                        if not self.dragStarted:
                            self.dragStarted = True
                            pyautogui.mouseDown()
                        
                        #fetch x/y movement
                        x = int(float(splitted[2]))
                        y = int(float(splitted[3]))
                        pyautogui.dragRel(x,y, mouseDownUp=False)
 
                                    
                elif act == "move":
                    if params == 2:
                        #fetch x/y movement
                        x = int(float(splitted[2]))
                        y = int(float(splitted[3]))
                        
                        #are we dragging?
                        pyautogui.moveRel(x,y)
                            

            elif obj == "key":
                key = splitted[2]
                print("keypress:" + act + " key:" + key)
                if (act == "press"):
                    pyautogui.press(key)
                elif (act == "down"):
                    pyautogui.keyDown(key)
                elif (act == "up"):
                    pyautogui.keyUp(key)