def RestartProductions():
    thing = pyautogui.locateOnScreen("building sleeping.png", confidence=0.6)
    if thing is None:
        return False
    while thing is not None:
        pos = pyautogui.center(thing) + (0, 40)
        goClick(pos)
        pyautogui.move(-300, -300)
        time.sleep(0.5)
        try:
            findClick("5 min production.png")
        except LZException:
            print("5 min not there")
        time.sleep(1.5)
        thing = pyautogui.locateOnScreen("building sleeping.png",
                                         confidence=0.5)
    return True
def startClicking():
    """Performs the clicks to navigate form the start screen (where the PLAY button is visible) to the beginning of the first level."""
    # Click on everything needed to get past the menus at the start of the game.

    # click on Play
    while True:
        logging.info('Looking for Next button...')
        posnext = pyautogui.locateCenterOnScreen(
            imPath('idle_master_autoclicker_next.png'))
        posicon = pyautogui.locateCenterOnScreen(imPath('icon.png'))
        if posnext is not None:
            pyautogui.click(posnext, duration=0.25)
            logging.info('Clicked on Next button.')
            pyautogui.move(posicon, duration=0.25)
        else:
            logging.info("Next button don't found.")
        time.sleep(10)
Exemple #3
0
def doSell():
    global sellIndex
    global status
    if sellIndex < len(sellPos):
        pyautogui.move(sellPos[sellIndex][0]*90,sellPos[sellIndex][1]*90)
        pyautogui.click()
        time.sleep(0.5)
        toPngPos("sellall.png")
        time.sleep(1)
        sellIndex = sellIndex + 1
        if sellIndex >= len(sellPos):
            if toPngPos("sellexit.png",True):
                sellIndex = 0
                status = Status.SWITCHTOMAP
    else:
        if toPngPos("sellexit.png",True):
            sellIndex = 0
            status = Status.SWITCHTOMAP
Exemple #4
0
def find_share_name(y_point):
    xyp2("namu_app_name", "click", "False", 0.95)
    sell_img_drag()
    pya.move(0, 50)
    # pya.scroll(70)
    xyp2("avg_img", "move", "False", 0.95)
    # pya.move(0, 469)
    pya.hscroll(-70)
    # sell_img_scroll()
    # xyp2("namu_app_name", "click", "False", 0.95)
    xyp2("share_lists", "move", "False", 0.95)
    pya.move(80, y_point)
    x, y = pya.position()
    pya.screenshot('img/var/stock_name.png',
                   region=((x*2)-100, (y*2)-30, 150, 50))
    pya.screenshot('img/var/stock_info.png',
                   region=((x*2)+150, (y*2)-100, 500, 120))
    return x, y
Exemple #5
0
    def mouse_move(self):
        while True:
            time.sleep(0.01)
            lock = threading.Lock()
            lock.acquire()

            if not self.m_cmps:
                lock.release()
                break

            vx, vy = [sum(x) for x in zip(*self.m_cmps)]
            lock.release()
            mag = math.sqrt(vx * vx +
                            vy * vy) / 6 / (1 + 4 *
                                            ("F13" not in self.curr_mods))

            if mag > 0:
                pyautogui.move(vx / mag, vy / mag)
Exemple #6
0
 def start_game(self):
     """
     Find and click start button twice (first time to focus on window), set
     up sample location, and return first tetromino.
     """
     self.play_button_location = pyautogui.locateCenterOnScreen(
                                 self.PLAY_BUTTON_IMAGE_PATH)
     if self.play_button_location is None:
         raise Exception('Could not find play button')
     pyautogui.click(self.play_button_location, clicks=2, interval=0.1)
     pyautogui.move(self.PLAY_BUTTON_TO_SAMPLE_OFFSET)
     self.pixel_sample_location = pyautogui.position()
     # Wait for game to start
     while self.next_sample not in Tetromino.SHAPES:
         self.get_sample()
     time.sleep(3)
     # Return first tetromino
     return self.get_next_tetromino()
def guiThread():
    global stackIn, stackOut
    while True:
        try:
            if not stackOut:
                while stackIn:
                    stackOut.append(stackIn.pop())
            # read
            mouseBias = [0, 0]
            mouseClick = False
            str = None
            while stackOut:
                query = stackOut.pop()
                args = query.split()
                if args[0] == "m":
                    dx, dy = map(int, args[1:])
                    mouseBias[0] += dx
                    mouseBias[1] += dy
                elif args[0] == "c":
                    mouseClick = True
                elif args[0] == "t":
                    str = " ".join(args[1:])
                elif args[0] == "h":
                    gui.hotkey(*tuple(args[1:]))
                elif args[0] == "sv":
                    gui.vscroll(int(args[1]))
                elif args[0] == "sh":
                    gui.hscroll(int(args[1]))
                elif args[0] == "ss":
                    gui.screenshot("screenshot.png")
                else:
                    print("What is '{}'".format(query))
            # excute
            gui.move(mouseBias[0], mouseBias[1])
            if mouseClick:
                gui.mouseDown()
                time.sleep(0.01)
                gui.mouseUp()
                mouseClick = False
            if str != None:
                gui.typewrite(str)
        except Exception as e:
            print(e)
            continue
Exemple #8
0
def moveMouse(ordinate, value):
    if ordinate=='x':
        if value <0:
            pyautogui.move(0,10)
        else:
            pyautogui.move(0,-10)
    if ordinate=='y':
        if value <0:
            pyautogui.move(-10,0)
        else:
            pyautogui.move(10,0)
def load_workshop(name,
                  folders=[],
                  additive=False,
                  wait_for_loading=IMAGE_TIMEOUT):
    if additive:
        click_image("res/menu/games.png")
    click_image("res/menu/workshop.png")
    goto_folder(folders, "game")
    if additive:
        goto_image(f"res/game/{name}.png")
        ui.move(45, -55)
        ui.click()
        click_image("res/button/additive_load.png")
        click_image("res/button/load.png")
        time.sleep(5)
    else:
        click_image(f"res/game/{name}.png")
        click_image("res/button/load.png")
        wait_for_image("res/chat/loading_complete.png", wait_for_loading)
Exemple #10
0
    def getState(self):  # idle=0, start=1, catch=2
        self.window.move_to_foreground()

        self.stream_img = self.window.grab_frame()
        stream_gray = cv.cvtColor(self.stream_img, cv.COLOR_BGR2GRAY)

        method = cv.TM_SQDIFF
        result = cv.matchTemplate(self.comp_img, stream_gray, method)
        mn, _, mnLoc, _ = cv.minMaxLoc(result)
        MPx, MPy = mnLoc
        print("x: " + str(MPx) + ", y: " + str(MPy))

        status = 0

        if (MPx > start_target_x - target_thresh
                and MPx < start_target_x + target_thresh
                and MPy > start_target_y - target_thresh
                and MPy < start_target_y + target_thresh):
            if (self.reel_state == 2):
                self.reel_state = 1
                spaces_folder = spaces_folder_cast
            else:
                self.reel_state = 2
                spaces_folder = spaces_folder_reel
            if output_spaces:
                if not os.path.exists(spaces_folder):
                    os.makedirs(spaces_folder)
                for i in range(10):
                    pyautogui.move(random.gauss(0, 50),
                                   random.gauss(0, 5),
                                   duration=random.gauss(0.1, .01))
                    cv.imwrite(
                        os.path.join(spaces_folder,
                                     str(uuid.uuid4()) + '.jpg'),
                        self.window.grab_frame())
            return self.reel_state
        elif (MPx > catch_target_x - target_thresh
              and MPx < catch_target_x + target_thresh
              and MPy > catch_target_y - target_thresh
              and MPy < catch_target_y + target_thresh):
            return 2
        else:
            return 0
Exemple #11
0
def weixin_display_date():

    time.sleep(2)
    # pyautogui.move(yOffset=-16)  # 放到文章标题上
    # time.sleep(1)
    pyautogui.move(xOffset=-260, yOffset=30)  # 移动到日期“日”字右边
    pyautogui.mouseDown()  # 按下鼠标左键
    time.sleep(1)
    pyautogui.dragRel(xOffset=-100, duration=1)  # 向左边拖动鼠标
    # pyautogui.move(xOffset=-100)  # 移动到日期“2”字左边
    pyautogui.hotkey('command', 'c')
    time.sleep(1)
    # pyautogui.mouseUp()  # 放开鼠标左键
    article_date = pyperclip.paste()
    print("文章发表的日期是:" + article_date)
    # 再返回文章标题位置
    time.sleep(1)
    pyautogui.move(xOffset=360, yOffset=-30)
    return article_date
Exemple #12
0
def main():
    run = True
    while (run):
        gameAccept()
        pyautogui.move(0, -300)
        while (True):
            iptal = isCancelled()
            if iptal:
                print("Oyun iptal edildi. Tekrar deneniyor...")
                break

            csResult = isChampSelect()

            if csResult:
                print("Program kapatılıyor...")
                run = False
                break

            time.sleep(1)
Exemple #13
0
def checkbounds(x, y):
    if x > 30 and x < widthh:
        if y > 30 and y < heightt:
            return (True)
        elif y < 30:
            pag.move(0, 30)
        else:
            pag.move(0, -30)
    elif x < 30:
        pag.move(30)
    else:
        pag.move(-30)
def message_received(client, server, message):
    if debug: 
        global serverReady
        Sec,MilSec = int(time.time()-serverReady), int(100*(time.time()-serverReady))%100
        print("{}:{} -> {}".format(Sec, MilSec, message))

    # moving the cursor as told by the client
    if message in ["CLICK","DOUBLE_CLICK"]:
        pyautogui.click()
    elif message == "START_DRAG":
        pyautogui.mouseDown()
    elif message[:6] == "SCROLL":
        pyautogui.scroll(int(message.split('.')[1]))
    elif message[:4] in ["DRAG","MOVI"]:
        pyautogui.move(int(message.split('.')[1]),int(message.split('.')[2]))
    elif message == "DROP":
        pyautogui.mouseUp()
    elif message == "RIGHT":
        pyautogui.rightClick()
Exemple #15
0
def get_message():
    global x, y

    position = position1 = pt.locateOnScreen("whatsapp/smiley_paperclip.png",
                                             confidence=.6)
    x = position[0]
    y = position[1]
    pt.move(x, y,
            duration=.05)  #duration es para MAC pero por las dudas para ubuntu
    pt.moveTo(x, y, duration=.5)
    pt.moveTo(x + 70, y - 40, duration=.5)
    pt.tripleClick()
    pt.rightClick()
    pt.moveRel(12, 15)
    pt.click()
    whatsapp_message = pyperclip.paste()
    pt.click()
    print("Message: " + whatsapp_message)
    return whatsapp_message
    def moveRelative(self, direction):

        print("DIRECTION = " + str(direction))
        # Direction Index = ['left', 'right', 'up', 'down']
        if (direction == 0):
            pyautogui.move(-20, 0)
        elif (direction == 1):
            pyautogui.move(20, 0)
        elif (direction == 2):
            pyautogui.move(0, -20)
        elif (direction == 3):
            pyautogui.move(0, 20)
def selectlane(givenlane):
    mousepos = pyautogui.position()
    if givenlane == 'MID':
        pyautogui.move(0,-90)
        pyautogui.click()
    if givenlane == 'JNGL':
        pyautogui.move(-70,-75)
        pyautogui.click()
    if givenlane == 'TOP':
        pyautogui.move(-90,0)
        pyautogui.click()
    if givenlane == 'ADC':
        pyautogui.move(70,-75)
        pyautogui.click()
    if givenlane == 'SUPP':
        pyautogui.move(90,0)
        pyautogui.click()

    pyautogui.moveTo(mousepos)
    def Checkbutton(self):
        print('\nCheck button is clicked')
        print('\n[system] : 출석체크 자동 매크로를 시작합니다.')

        # -----------------------------------------------------
        time.sleep(2)
        while True:
            m.moveTo(954, 185)  # 새 글 피드 버튼 위치로 이동
            x, y = m.position()
            RGB = m.screenshot().getpixel((x, y))  # 색깔 잡기
            if RGB == (46, 204, 113):  # 새 글 피드 버튼이 생기면
                m.click(x, y)  # 버튼 누르기
                print('\n[system] : 새 글 확인 버튼을 눌렀습니다.')
                break
            else:
                time.sleep(10)  # 없으면 10초 기다리기
        # -----------------------------------------------------
        time.sleep(2)
        m.moveTo(704, 400)  # 출석체크 아이콘 버튼의 x좌표로 이동
        while True:
            x, y = m.position()
            RGB = m.screenshot().getpixel((x, y))  # 색깔 잡기
            if RGB == (52, 204, 108):  # 출석체크 아이콘 버튼의 색깔을 찾으면
                x, y = m.position()
                m.click(x, y)  # 클릭해서 출석체크 창으로 이동
                print('\n[system] : 출석체크 창으로 이동했습니다.')
                break
            else:  # 그 색깔이 아니면
                m.move(0, +1)  # y축 방향으로 -1 만큼 이동
        # -----------------------------------------------------
        time.sleep(2)
        m.moveTo(1149, 350)  # 출석체크 체크 버튼의 x좌표로 이동
        while True:
            x, y = m.position()
            RGB = m.screenshot().getpixel((x, y))  # 색깔 잡기
            if RGB == (205, 205, 205):
                x, y = m.position()
                m.click(x, y)  # 클릭해서 출석체크
                print('\n[system] : 출석체크를 완료했습니다.')
                break
            else:  # 그 색깔이 아니면
                m.move(0, +1)  # y축 방향으로 -1 만큼 이동
Exemple #19
0
def fullfil_invoice(f_seller_invoice_number, f_invoice_date, f_bank_account,
                    f_total_amount, f_payment_type):
    "fullfilling invoice page"
    pyautogui.screenshot()
    (x, y) = pyautogui.center(
        pyautogui.locateOnScreen("original_invoice_number_position.png",
                                 confidence=0.8))
    pyautogui.moveTo(x, y, 0.5, pyautogui.easeOutQuad)
    pyautogui.move(100, 0)
    pyautogui.doubleClick()
    pyautogui.typewrite(f_seller_invoice_number, interval=0.15)
    pyautogui.press('enter')
    pyautogui.typewrite(f_invoice_date, interval=0.15)
    pyautogui.press('enter')
    pyautogui.typewrite(f_invoice_date, interval=0.15)
    pyautogui.press('enter')
    pyautogui.press('enter')
    time.sleep(1)
    if bank_account != "0":
        pyautogui.typewrite(f_bank_account, interval=0.15)
        pyautogui.press('enter')
    else:
        locate_move_and_click("bank_account_position.png", 215, 0)
        time.sleep(2)
        pyautogui.press('down')
        check_bank_account()
        pyautogui.press('enter')
        time.sleep(1)
    locate_move_and_click("payment_type.png", 90, 0)
    pyautogui.typewrite(payment_type_dict[f_payment_type], interval=0.15)
    time.sleep(1)
    pyautogui.press('enter')
    locate_move_and_click("bar_position.png", 0, 0)
    pyautogui.dragRel(760, 0, duration=1)
    locate_move_and_click("change_number.png", 0, 0)
    time.sleep(2)
    pyautogui.move(0, 100)
    locate_move_and_click("total_amount.png", 0, 20)
    pyautogui.doubleClick()
    pyautogui.typewrite(f_total_amount, interval=0.15)
    pyautogui.hotkey('ctrl', 's')
    time.sleep(2)
Exemple #20
0
def Jump1():
    f=ImageGrab.grab()
    x = pq.position().x
    y = pq.position().y
    z = pq.pixel(x, y)
    c=True
    print(f.getpixel((x, y)))
    for i in range(0,160,5):
        if f.getpixel((x - i, y))[0] < 90:
            if c:
                pq.keyDown('space')
                c=False
    for i in range(-30,120, 10):
        if f.getpixel((x - i, y-30))[0] < 90:
            pq.keyDown('space')
    #pq.keyUp('space')
    s+=0.01
    if s==1:
        pq.move(f,0)
        s=0
Exemple #21
0
def Mouse_act(cmd):
    if cmd == "L":
        ptg.move(-30, 0)
    elif cmd == "R":
        ptg.move(30, 0)
    elif cmd == "U":
        ptg.move(0, 30)
    elif cmd == "D":
        ptg.move(0, -30)
    elif cmd == "C":
        ptg.click()

    return "command send: {}".format(cmd)
def chop_down_tree(local_area):
    if (local_area) > 100000:
        pydirectinput.mouseDown()
        time.sleep(2)
        pydirectinput.mouseUp()
        pyautogui.move(0, 180, 0)
        pydirectinput.mouseDown()
        time.sleep(2)
        pydirectinput.mouseUp()
        pyautogui.move(0, -320, 0)
        pydirectinput.mouseDown()
        time.sleep(2)
        pydirectinput.mouseUp()
        pyautogui.move(0, 180, 0)

    k = random.randint(0, 1)
    if (k == 1):
        pyautogui.move(60, 0, 0)
    else:
        pyautogui.move(-60, 0, 0)
Exemple #23
0
def order(orderIterations):
    try:
        for i in range(orderIterations):
            pyautogui.click(x=1000, y=400)  # Click Salad button
            pyautogui.click(x=800, y=275)  # Click top most salad in column
            for i in range(
                    6
            ):  # Iterate through all the rest of the salads. Each button is 113 pixels apart.
                pyautogui.move(
                    0, 113
                )  # Move mouse down 113 pixels from current position to hit next button in column
                pyautogui.click()  # Click
            pyautogui.click(x=2400, y=1300)  # Pay / close order
            pyautogui.click(x=1600, y=400)  # Exact Cash button
            # sleep(1) # 1 second sleep while punchh does its thing
            pyautogui.click(x=1600, y=400)
    except TypeError:
        print(
            'Oops! That was an invalid number for the "orderSalads" function. Please try again.'
        )
Exemple #24
0
    def dragMouseToRandomPosition(self,
                                  directionX,
                                  directionY,
                                  duration=0.2,
                                  interval=0.0):
        moveX = round(
            directionX * random.uniform(0.3, 0.6) * self.__windowWidth, 4)
        moveY = round(
            directionY * random.uniform(0.3, 0.6) * self.__windowHeight, 4)

        self.GUIAcquire()

        pyautogui.mouseDown()
        time.sleep(interval)
        pyautogui.move(moveX, moveY, duration, pyautogui.easeInOutQuad)
        time.sleep(interval)
        pyautogui.mouseUp()
        #self.__lastOperationTime=time.time()

        self.GUIRelease()
Exemple #25
0
    def movement(self):

        # The movement of the cursor based on whether only the index finger or both the index
        # and middle finger are raised. Calculated via the current coords - the previous coords and
        # put through a smoothening filter.
        current_x = self.mcp_mx['x'][1]
        current_y = self.mcp_mx['y'][1]
        move_x = current_x - self.previous_x
        move_y = current_y - self.previous_y
        fmove_x, fmove_y = self.filterMov(move_x, move_y)
        if np.all(
            (self.tip_mx['y'][1:] < self.mcp_mx['y'][1:]) == [1, 0, 0, 0]):
            pag.move(fmove_x * self.dist / 5, fmove_y * self.dist / 4)
        elif np.all(
            (self.tip_mx['y'][1:] < self.mcp_mx['y'][1:]) == [1, 1, 0, 0]):
            pag.move(fmove_x * self.dist, fmove_y * self.dist)
        else:
            self.filter_x = []
            self.filter_y = []
        self.previous_x = current_x
        self.previous_y = current_y
Exemple #26
0
def shift(data):
    try:
        SHIFT = 20
        xOffset = 0
        yOffset = 0
        if 'direction' in data:
            if data['direction'] == 'выше':
                yOffset = -SHIFT
            if data['direction'] == 'ниже':
                yOffset = SHIFT
            if data['direction'] == 'левее':
                xOffset = -SHIFT
            if data['direction'] == 'правее':
                xOffset = SHIFT
            pyautogui.move(xOffset, yOffset)
            data['xy'] = pyautogui.position()
        else:
            data['error'] = "Требуется аргумент 'direction'"
    except Exception as e:
        data['error'] = str(e)
    return data
def click():
    if request.is_json:
        req = request.get_json()
        #print(req)

        value = (req.get('value'))
        if (value == 1):
            pyautogui.click(button='left')
        elif (value == 2):
            pyautogui.click(button='right')
        elif (value == 3):
            x, y = pyautogui.position()
            #print(x,y, sep=" ")
            pyautogui.move(int(req.get('xVelocity')),
                           int(req.get('yVelocity')))

        return jsonify({"message": "JSON"})
        #return make_response(jsonify({"message": "JSON"}), 200)
        #return "valid-200"
    else:
        return jsonify({"message": "NOT JSON"})
Exemple #28
0
def updateMouse(dX, dY, buttonPressed):

    if (buttonPressed):
        pyautogui.click()
        return

    screenDim = pyautogui.size()
    #xMultiplier = (screenDim[0] / 224)
    #yMultiplier = (screenDim[1] / 171)
    xMultiplier = 0.5 * ((screenDim[1] / 171) + (screenDim[0] / 224))
    yMultiplier = xMultiplier

    if (dX * xMultiplier > screenDim[0]) or (dY * yMultiplier > screenDim[1]):
        return

    x, y = pyautogui.position()

    if not (pyautogui.onScreen(x + dX * xMultiplier, y + dY * yMultiplier)):
        return

    pyautogui.move(dX * xMultiplier, dY * yMultiplier)
Exemple #29
0
def muteAudio(mute):
    global direction
    gui.move(direction, 0)
    if (mute):
        try:
            audio_button = browser.find_element_by_xpath(
                "//button[@class='touchable PlayerControls--control-element nfp-button-control default-control-button button-volumeMax']"
            )
            # class ="touchable PlayerControls--control-element nfp-button-control default-control-button button-volumeMax"
            audio_button.click()
            gui.move(direction, 0)
        except:
            print("couldn't find volume Max button")
            # if there is an error, then audio is already muted, couldnt find "volumeMax"
            # pass
    else:
        try:
            audio_button = browser.find_element_by_xpath(
                "//button[@class='touchable PlayerControls--control-element nfp-button-control default-control-button button-volumeMuted']"
            )
            audio_button.click()
            gui.move(direction, 0)
        except:
            print("couldn't find volume mute button")
            # if error, then already unmuted
            # pass
    direction *= -1
def mouse_ver(contours, right_eye):
    for cnt in contours:
        (x, y, w, h) = cv2.boundingRect(cnt)
        cv2.rectangle(right_eye, (x, y), (x + w, y + h), (255, 0, 0), 2)
        cv2.line(right_eye, (x + int(w / 2), 0), (x + int(w / 2), rows),
                 (0, 255, 0), 2)
        cv2.line(right_eye, (0, y + int(h / 2)), (cols, y + int(h / 2)),
                 (0, 255, 0), 2)

        arr.append((int(x) + int(w / 2)))
        if len(arr) == 20:
            a = np.array(arr)
            xx = list(pyautogui.position())
            xxx = xx[0]
            yyy = xx[1]
            #print(xx)
            avg = np.sort(a)

            if (avg[5] > 37):
                pyautogui.move(550, yyy)
            elif (avg[5] <= 35):
                pyautogui.move(650, yyy)
            else:
                pyautogui.move(600, yyy)
            arr.clear()

        break