Example #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
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
Example #3
0
		def action_dragPointer():
			if echo: print("Drag To:\t{}".format(self.location))
			try:
				tween = float(self.text)
			except:
				tween = 1
			pyautogui.dragTo(self.location[0],self.location[1], tween)
Example #4
0
    def drag_to(self, name, loader=_imageLoader, offset=(0, 0)):
        if GameStatus().game_stage == GameStage.Stopped:
            return
        self.log('try drag' + name)
        p = loader.get(name)
        max_val = 0
        x, y = 0, 0
        while max_val < 0.8:
            if GameStatus().game_stage == GameStage.Stopped:
                return

            self.capture()
            res = cv2.matchTemplate(self.screen, p, cv2.TM_CCOEFF_NORMED)
            min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
            self.log(name + ' ' + str(max_val))
            x, y = max_loc
            time.sleep(self._delay)

        m, n, q = p.shape

        x += n / 2
        y += m / 2

        pyautogui.moveTo(x, y, 0)
        pyautogui.dragTo(0, 200)
def address_scrape():
    dob = pyperclip.copy('na')
    pya.moveTo(600, 175, duration=0.1)
    pya.click(button='right')
    pya.moveRel(55, 65)
    pya.click()
    dob = pyperclip.paste()
    
    street = pyperclip.copy('na')
    pya.moveTo(500, 240, duration=0.1)
    pya.click(button='right')
    pya.moveRel(55, 65)
    pya.click()
    street = pyperclip.paste()
    
    suburb = pyperclip.copy('na')
    pya.moveTo(330, 285, duration=0.1)
    pya.click(button='right')
    pya.moveRel(55, 65)
    pya.click()
    suburb = pyperclip.paste()
    
    postcode = pyperclip.copy('na')
    pya.moveTo(474, 285, duration=0.1)
    pya.dragTo(450, 285, duration=0.1)
    pya.moveTo(474, 285, duration=0.1)
    pya.click(button='right')
    pya.moveRel(55, 65)
    pya.click()
    postcode = pyperclip.paste()

    address = street + ' ' + suburb + ' ' + postcode

    return (address, dob)
Example #6
0
    def drag_screen_region_to_screen_region(self, start_screen_region=None, end_screen_region=None, duration=1, offset=(0, 0), game=None):
        start_screen_region_coordinates = self._extract_screen_region_coordinates(start_screen_region, game=game)
        end_screen_region_coordinates = self._extract_screen_region_coordinates(end_screen_region, game=game)

        pyautogui.moveTo(*start_screen_region_coordinates)

        coordinates = (end_screen_region_coordinates[0] + offset[0], end_screen_region_coordinates[1] + offset[1])
        pyautogui.dragTo(*coordinates, duration=duration)
Example #7
0
def fight_rate():
    on_news()
    p.moveTo(100, 100)
    sleep(0.01)
    begin = cv2_match(IMAGE["fight_rate"])[0]
    end = cv2_match(IMAGE["fight_slave"], 0.5)[0]
    p.moveTo(begin)
    p.click()
    p.dragTo(end)
 def hero_attack(self, board_size, minion):
     p.click(self.left + 5, self.top + 5)    # ensure HS is active window
     p.moveTo(self.cx, self.hero_y, duration = 0.25)
     if minion == 0:
         p.dragTo(self.cx, self.enemy_y, duration = 0.25)
     else:
         minion_x, minion_y = self.target(board_size, minion, True)
         p.dragTo(minion_x, minion_y, duration = 0.25)
     time.sleep(0.75)
Example #9
0
def my_script(image,drawable,text_value,int_value):
    # pdb.gimp_message( "Hello from python")
    gimp.set_foreground(50,0,150)
    pdb.gimp_context_set_brush('Oils 01')

    gui.typewrite('p') # open brush
    gui.moveTo(500,500)
    gui.dragTo(550,550,.1)
    return
Example #10
0
def make_mouse_move(from_sq, to_sq, orient=True):
    print "Moving from square %d to square %d" % (from_sq, to_sq)
    # click on from square
    x = board_lu[orient][from_sq][0] + sq/4*np.random.random_sample()
    y = board_lu[orient][from_sq][1] + sq/4*np.random.random_sample()
    pyautogui.moveTo(x, y, duration=0.1 + np.random.random_sample())
    # click on to square
    x = board_lu[orient][to_sq][0] + sq/4*np.random.random_sample()
    y = board_lu[orient][to_sq][1] + sq/4*np.random.random_sample()
    pyautogui.dragTo(x, y, duration=0.1 + np.random.random_sample())
Example #11
0
def v_scroll_on_android(scroll_value=20, locate_first_on_center = True, scrollDown = True):
    # Locate the mouse on screen center
    if(locate_first_on_center is True):
        locate_on_center()
    # Simulate drag and drop
    # pyautogui.mouseDown();
    x, y = pyautogui.position()[0], pyautogui.position()[1]
    if(scrollDown is True):
        y = y - scroll_value;
    else:
        y = y + scroll_value;
    pyautogui.dragTo(x, y)
def episode_get_fund_number():
    # get fund number
    fund_number = pyperclip.copy('na')
    pya.moveTo(646, 545, duration=0.1)
    pya.dragTo(543, 545, duration=0.1)
    pya.moveTo(646, 545, duration=0.1)
    pya.click(button='right')
    pya.moveTo(692, 392, duration=0.1)
    pya.click()
    fund_number = pyperclip.paste()
    if fund_number == 'na':
        fund_number = pya.prompt(
            text='Please enter fund number!', title='Fund Number', default='')
    return fund_number
    def minion_attack(self, board_size, minion, enemy_board_size, enemy_minion):
        """
        Similar concept to targeting with hero power. We find the location of
        our minion and the enemy minion (or hero) and we make the attack.
        """
        p.click(self.left + 5, self.top + 5)    # ensure HS is active window
        minion_x, minion_y = self.target(board_size, minion, False)
        p.moveTo(minion_x, minion_y)

        if enemy_minion == 0:
            p.dragTo(self.cx, self.enemy_y, duration = 0.25)
        else:
            enemy_x, enemy_y = self.target(enemy_board_size,
                                                    enemy_minion, True)
            p.dragTo(enemy_x, enemy_y, duration = 0.25)
        time.sleep(1)
def episode_get_fund_name():
    # get fund name
    fund = pyperclip.copy('na')
    pya.moveTo(696, 508, duration=0.1)
    pya.dragTo(543, 508, duration=0.1)
    pya.moveTo(696, 508, duration=0.1)
    pya.click(button='right')
    pya.moveTo(717, 579, duration=0.1)
    pya.click()
    fund = pyperclip.paste()
    if 'United' in fund:
        fund = 'Grand United Corporate Health'
    if fund == 'na':
        fund = pya.prompt(
            text='Please enter Fund name', title='Fund Name', default='')
    return fund
def copyVerCode():
	pyautogui.click(1275,730)
	time.sleep(1)
	pyautogui.click(820,370)
	time.sleep(1)
	pyautogui.click(500,150)
	time.sleep(1)
	pyautogui.mouseDown(500, 150, button='left')
	time.sleep(1.5)
	pyautogui.mouseUp(500, 150, button='left')
	time.sleep(1)
	pyautogui.click(500,390)
	time.sleep(1)
	pyautogui.click(500,680)
	time.sleep(1)
	pyautogui.hotkey('ctrl', 'v')
	time.sleep(1)
	pyautogui.doubleClick(500,680)
	time.sleep(1)
	pyautogui.click(520,710)
	pyautogui.dragTo(540, 715, duration=0.5)
Example #16
0
def barbecue():
    current_orders = get_order()
    get_key(current_orders.keys())
    for x in current_orders.values():
        if x == BIITORO:
            pyautogui.moveTo(BIITORO_COORDS)
        elif x == TORIKAWA:
            pyautogui.moveTo(TORIKAWA_COORDS)
        elif x == TAN:
            pyautogui.moveTo(TAN_COORDS)
        elif x == NEGIMA:
            pyautogui.moveTo(NEGIMA_COORDS)
        elif x == SUNAGIMO:
            pyautogui.moveTo(SUNAGIMO_COORDS)
        elif x == KASHIRA:
            pyautogui.moveTo(KASHIRA_COORDS)
        elif x == ERINGI:
            pyautogui.moveTo(ERINGI_COORDS)
        y = free_stick()
        z1 = stick_postion(y)
        pyautogui.dragTo(z1)
        stick[y] = True
Example #17
0
    def sign():

        try:
            a, b = pyautogui.locateCenterOnScreen('sign.png',
                                                  grayscale=True,
                                                  confidence=0.6)
            pyautogui.leftClick(x=a / 2, y=b / 2)
        except TypeError:
            a, b = pyautogui.locateCenterOnScreen('sign.png',
                                                  grayscale=True,
                                                  confidence=0.8)
            pyautogui.leftClick(x=a / 2, y=b / 2)
        sleep(.5)
        a, b = pyautogui.locateCenterOnScreen('DING.png',
                                              grayscale=False,
                                              confidence=0.9)
        pyautogui.leftClick(a / 2, b / 2 + 70)
        pyautogui.dragTo(a / 2 - 100, b / 2 + 70, button='left')
        pyautogui.dragTo(a / 2 - 200, b / 2 + 70, button='left')
        a, b = pyautogui.locateCenterOnScreen('signin.png',
                                              grayscale=False,
                                              confidence=0.9)
        pyautogui.leftClick(x=a / 2, y=b / 2)
        sleep(3)

        try:
            a, b = pyautogui.locateCenterOnScreen('donotsign.png',
                                                  grayscale=False,
                                                  confidence=0.6)
            pyautogui.leftClick(x=a / 2, y=b / 2)
        except TypeError:
            pass
        a, b = pyautogui.locateCenterOnScreen('final_sign.png',
                                              grayscale=False,
                                              confidence=0.9)
        pyautogui.moveTo(x=a / 2, y=b / 2)
        pyautogui.leftClick(x=a / 2, y=b / 2)
        sleep(1)
        quit()
Example #18
0
def loot(frame, image, tierList, defaultPos, window):
    itemPickupWindow = cutWindowItemPickup(frame)
    playerItemWindow = cutWindowPlayerItems(frame)
    playerItems = matchTieredItem(playerItemWindow, image, Utils.playerItemsPos, window, tierList, defaultPos)
    foundItems = matchTieredItem(itemPickupWindow, image, Utils.lootPos, window, tierList, [0, 0])


    wepPosX = Utils.playerWeaponPos[0]
    wepPosY = Utils.playerWeaponPos[1]
    wepPosX += window[0]
    wepPosY += window[1]

    if not len(foundItems) == 0:
        if not len(playerItems) == 0:
            foundItems.sort(reverse=True, key=sorter)
            playerItems.sort(reverse=True, key=sorter)
            maxTierItem = foundItems[0]
            if maxTierItem[0] > playerItems[0][0]:
                pyautogui.moveTo(maxTierItem[1])
                pyautogui.dragTo(playerItems[0][1][0], playerItems[0][1][1], .5)
    print("Player item tier =", playerItems)
    print("Loot item tier = ", foundItems)
Example #19
0
def func():
    p.moveTo(1507, 532)
    p.dragTo(1507, 532, button='left')
    #p.click(1097,395)
    p.dragTo(1370, 395, button='left')
    #p.moveTo(1234,532)
    #p.click(1234,532)
    p.dragTo(1234, 532, button='left')
Example #20
0
    def move_item(self, item, move_to, offset=(5, 5)):
        """
            Move an item to a different location in the backpack. The search
            for the item will always exclude a 5 pixel margin around the
            destination so the same item isn't moved repeatedly.
            """
        # Move mouse to a neutral position that won't obstruct template matching
        pyautogui.moveTo(400, 400)

        # Get the player's backpack
        backpack, backpack_loc = self.get_backpack()

        # Find all instances of the item in the backpack
        res = cv2.matchTemplate(backpack, self.item_templates[item],
                                cv2.TM_CCORR_NORMED)

        # Only consider high confidence matches
        threshold = 0.9
        loc = np.where(res >= threshold)

        # For each match, move it if it isn't already in the correct area
        for item_loc in zip(*loc[::-1]):
            # Skip items already in the correct area
            if move_to[0] - 12 < item_loc[0] < move_to[0] + 14 and move_to[
                    1] - 12 < item_loc[1] < move_to[1] + 14:
                continue

            # Drag and drop the item to the correct area
            pyautogui.moveTo((backpack_loc[0] + item_loc[0] + offset[0]),
                             (backpack_loc[1] + item_loc[1] + offset[1]), 0.15)
            pyautogui.dragTo((backpack_loc[0] + move_to[0]),
                             (backpack_loc[1] + move_to[1]),
                             2,
                             pyautogui.easeOutQuad,
                             button='left')

        # Move mouse to a neutral position that won't obstruct template matching
        pyautogui.moveTo(400, 400)
Example #21
0
def perform_events():
    # Global variable declaration
    global counter

    # Iterate counter
    counter += 1

    # Initialize event anim list
    anim_events = 0

    # Iterate over each command in
    for command in events:
        # Animate events in console
        perform_event_anim(events, anim_events)
        anim_events += 1

        # Confirmation event --> ask for input
        if (command == "INPUT"):
            input("Press enter to confirm edit...")

        # Click event --> left click mouse
        elif (command == "click"):
            pyautogui.click()

        # Array parsing
        else:
            # Check if first element is string --> type in as key input
            if (type(command[0]) is str):
                pyautogui.typewrite(command, interval=key_duration)

            # Check if list and length is 4 --> click and drag
            elif (type(command) is list and len(command) == 4):
                pyautogui.moveTo(command[0], command[1], mouse_duration)
                pyautogui.dragTo(command[2], command[3], mouse_duration)

            # Anything else (list) --> move mouse
            else:
                pyautogui.moveTo(command[0], command[1], mouse_duration)
Example #22
0
def script_execute():

    mouse_position = pg.position()
    print("現在のマウス位置は X= " + str(mouse_position.x) + "Y= " + str(mouse_position.y))

    print("マウスを移動します")
    #マウスを0.5秒かけてx=1000, y=200に移動する
    pg.moveTo(1200, 600, duration=2)
    #目標の座標に向けてマウスをドラッグする
    pg.dragTo(300, 300, duration=2)

    pg.moveTo(1700, 900, duration=2)
    print("マウスクリックします")
    #10回左クリックをする
    pg.click(clicks=10, button='left')

    print("キーを入力します")
    # インターバル0.5秒でshiftを2回押す
    pg.press('shift', presses=2, interval=0.5)# インターバル0.5秒でshiftを2回押す
    pg.typewrite("hello! PyAutoGUIs!")
    pg.click(clicks=2, button='left')  # 2回クリックする

    print("スクリーンショットを取ります(ホットキーでも全然可能)")

    #画像を使った繊維、
    #Youtubeのロゴを認識してそこの座標を取得する
    x, y = pg.locateCenterOnScreen("pyAutoGUIScript/home.png")

    print("ロゴの画像の位置は x=" + str(x) + "y=" + str(y))
    pg.moveTo(x, y, duration=2)
    pg.moveRel(0, 80, duration=2) #相対座標
    pg.click(clicks=1, button='left')  # 2回クリックする
    pg.PAUSE = 2 #2秒待つ
    #ホットキーを使ったスクショ
    pg.hotkey('winleft', 'prtsc')
    #座標指定スクショ
    pg.screenshot("C:\screenShot\myscshot.png", region=(1, 1, 1000, 1000))
    print
def start_and_open():
    """Summary.

    Function to open LISE++ GUI from the icon logo that is on
    your desktop (very specific at the moment).
    """

    isotope_start = iso_start
    isotope_end = iso_end

    wedge_range_list = np.arange(int(wedge_start), int(wedge_end) + 100, 100)
    print(wedge_range_list)
    try:
        # find the image of the LISE++ icon,return coordinates for the cetner
        x, y = pag.center(pag.locateOnScreen("images/LISE++.png"))
        pag.moveTo(x, y)
    except TypeError:
        # if the app. has been clicked before
        x, y = pag.center(pag.locateOnScreen("images/LISE++_2.png"))
        pag.moveTo(x, y)
    pag.doubleClick()
    time.sleep(5)
    pag.moveTo(18, 44)  # file
    pag.doubleClick()
    pag.dragTo(112, 257, .5)  # configuration
    pag.click(interval=1)
    pag.moveTo(825, 251)  # load
    pag.click(interval=1)
    pag.moveTo(154, 326)  # textbox
    pag.click(interval=1)
    pag.write("NSCL")
    pag.moveTo(471, 323)  # Open button
    pag.click(interval=1)
    pag.moveTo(95, 213)  # A1900 file
    pag.click(interval=1)
    pag.moveTo(471, 323)  # Open button
    pag.click()
    return FP_slit_width, isotope_start, isotope_end, wedge_range_list
Example #24
0
    def imageToLines(imageArray: np.array, offset: int, rsleep: int,
                     lsleep: int) -> None:
        startPosX, startPosY = pyautogui.position()

        for row in imageArray:
            xoffset = 0
            isDrawing = False
            for value in row:
                if value == False:  # Don't draw
                    if isDrawing == True:
                        xoffset += offset
                    else:
                        startLine = startPosX + xoffset
                        isDrawing = True
                        xoffset += offset
                if value == True:
                    if isDrawing == False:
                        xoffset += offset
                    else:
                        pyautogui.moveTo(startLine, startPosY)
                        pyautogui.dragTo(startPosX + xoffset,
                                         startPosY,
                                         duration=lsleep,
                                         button="left")
                        time.sleep(lsleep)
                        isDrawing = False
                        xoffset += offset
            if value == False:
                if isDrawing == True:
                    pyautogui.moveTo(startLine, startPosY)
                    pyautogui.dragTo(startPosX + xoffset,
                                     startPosY,
                                     duration=lsleep,
                                     button="left")
                    time.sleep(lsleep)
                    xoffset += offset
            startPosY += offset
            time.sleep(rsleep)
Example #25
0
 def level_skill(self):
     """
     Input: none
     output: none
     """
     event.search_click(image.rewind_menu.value)
     index = self.skill_index
     array = self.skill_list
     skill_image_path = array[index]
     #make sure to scroll for skills below default view
     if 'scroll' in skill_image_path:
         pyautogui.moveTo(1234, 267)
         pyautogui.dragTo(1234, 365, 0.5, button='left')
     event.search_click_offset(skill_image_path, 470, 25)
     event.search_click(image.ok_button.value)
     #increment array to select next skill
     if index == len(array) - 1:
         index = 0
     else:
         index += 1
     #return array back to self
     self.skill_index = index
     return
Example #26
0
def run(repeat):

    for x in range(repeat):
        if random.randint(0, 100) > 90:
            pickColor()
        if random.randint(0, 100) > 95:
            pickSize()
        #if random.randint(0,100) > 75:
        #    curve()
        #print(x)
        going = False
        startX = random.randint(0 + canvasOrigin[0], width + canvasOrigin[0])
        startY = random.randint(0 + canvasOrigin[1], height + canvasOrigin[1])
        pyautogui.moveTo(startX, startY)
        while not going:
            if getDestination():
                going = True
        #print('from ' +str(startX)+',' +str(startY)+' to '+str(moveX)+','+str(moveY))
        pyautogui.dragTo(moveX, moveY, button='left')
        going = False
        if x % 100 == 0:
            print(x)
    showMenu()
Example #27
0
 def dragSrcToDest(self, s, d, btn='left'):
     #pyautogui.press('winleft')
     self.openLauncher()
     launcher = findWindow('dde-launcher')
     if launcher != None:
         apps = self.getLauncherAllApps()
         src = apps[s]
         dest = apps[d]
         src_size = self.getAppSize(src)
         dest_size = self.getAppSize(dest)
         src_position = self.launcherObj.child(src).position
         dest_position = self.launcherObj.child(dest).position
         src_x = src_position[0] + src_size[0] / 2
         src_y = src_position[1] + src_size[1] / 2
         dest_x = dest_position[0] + dest_size[0] / 2
         dest_y = dest_position[1] + dest_size[1] / 2
         if src_y < 0:
             pyautogui.scroll(30)
         pyautogui.mouseDown(src_x, src_y, button=btn, pause=1)
         if d > 27:
             pyautogui.scroll(-30)
             pyautogui.dragTo(dest_x, dest_y, duration=6, button=btn)
         pyautogui.dragTo(dest_x, dest_y, duration=2, button=btn)
Example #28
0
def main():
  click(539, 362)
  while True:
    try:
      if keyboard.is_pressed('q'):
        print("closing program")
        return
      else:
        click(700, 650)  # Place Bet
        wait(1)
        click(400, 250)  # Click Horse 1
        wait(1)
        for x in range(1, 7):
          click(777, 400)  # Click Left arrow 7 times
          wait(0.5)
        wait(1)
        click(777, 400)  # Click Left arrow 1 more time
        gui.dragTo(700, 600, 40)  # drags to place bet
        wait(1)
        gui.click(button="right")
        wait(1)
    except:
      return
Example #29
0
def put_life_ring_on(use_life_rings):
    if use_life_rings is False:
        return

    life_ring_pos = pyautogui.locateOnScreen('images/life_ring.png')
    empty_ring_slot_pos = pyautogui.locateOnScreen('images/empty_ring_slot.png')

    if life_ring_pos is not None:
        life_ring_pos_list = list(life_ring_pos)
        life_ring_x, life_ring_y = life_ring_pos_list[0], life_ring_pos_list[1]
        logging.info("Found a life ring at " + str(life_ring_x) + " " + str(life_ring_y))

        if empty_ring_slot_pos is not None:
            empty_ring_slot_pos_list = list(empty_ring_slot_pos)
            empty_ring_slot_x, empty_ring_slot_y = empty_ring_slot_pos_list[0], empty_ring_slot_pos_list[1]
            logging.info("Ring slot vacant at " + str(empty_ring_slot_x) + " " + str(
                empty_ring_slot_y) + ", moving life ring to ring slot")
            pyautogui.click(life_ring_x, life_ring_y, button='left', duration=random.uniform(0.2, 1.2))
            pyautogui.dragTo(empty_ring_slot_x, empty_ring_slot_y, duration=random.uniform(0.2, 1.2), button='left')
        else:
            logging.info("Ring slot already in use")
    else:
        logging.info("No life ring found")
Example #30
0
    def play_move(self):
        engine_move = self.engine.evaluate(self.board.internal_board)
        self.board.play_move(engine_move)

        move_from, move_to, promotion = engine_move.from_square, engine_move.to_square, engine_move.promotion

        # Internal repr is mirrored from the official repr
        # Hence the get_true_* methods which mirror first

        start_x, start_y = self.square_centers[
            Chessboard.get_true_rank(move_from, self.board.color), Chessboard.get_true_file(move_from, self.board.color)
        ]
        to_x, to_y = self.square_centers[
            Chessboard.get_true_rank(move_to, self.board.color), Chessboard.get_true_file(move_to, self.board.color)
        ]
        pyautogui.moveTo(start_x, start_y)

        drag_time = round(random.uniform(0.7, 1.2), 1)
        # drag_time = 0.5
        pyautogui.dragTo(to_x, to_y - self.board.square_height // 4, drag_time, button='left')

        if promotion is not None:
            self.attempt_promotion(promotion)
Example #31
0
    def moveUntil(self, screen):
        if screen == 4:
            pyautogui.moveTo(x=1755, y=15, duration=1.0)
            pyautogui.dragTo(x=4800, y=100, duration=3.0)

        if screen == 6:
            pyautogui.moveTo(x=1755, y=15, duration=1.0)
            pyautogui.dragTo(x=4800, y=1620, duration=3.0)

        if screen == 7:
            pyautogui.moveTo(x=1755, y=15, duration=1.0)
            pyautogui.dragTo(x=6720, y=1620, duration=3.0)

        if screen == 8:
            pyautogui.moveTo(x=1755, y=15, duration=1.0)
            pyautogui.dragTo(x=6720, y=100, duration=3.0)
Example #32
0
def swipe(x1,y1,x2,y2,delay=0.5,x1Offset=0, y1Offset=0,delay2=0,delay3=0.5,button='left'):
    """
    用鼠标,从x1,y1 拖动到 x2,y2
    :param x1: 起点x坐标
    :param y1: 起点y坐标
    :param delay: 鼠标移动到起始坐标的时间延时
    :param x1Offset: 起始坐标的x偏移
    :param y1Offset: 起始坐标的y偏移
    :param delay2:  进行偏移移动的时间延时
    :param x2: 终点坐标
    :param y2: 终点y坐标
    :param delay3: 拖动过程中的延时
    :param button: 用鼠标哪个键 可以设置成left,middle和right三个键
    :return:
    tween:
        pyautogui.easeInQuad光标移动呈现先慢后快的效果,整个过程的时间还是和原来一样。
        pyautogui.easeOutQuad函数的效果相反:光标开始移动很快,然后慢慢减速。
        pyautogui.easeOutElastic是弹簧效果,首先越过终点,然后再反弹回来
    """

    pyautogui.moveTo(x1, y1, duration=delay,tween=pyautogui.easeInQuad)
    pyautogui.moveRel(x1Offset, y1Offset, duration=delay2)
    pyautogui.dragTo(x2, y2,duration=delay3,button=button)
Example #33
0
def CopyText(nextline=0):
    
    #############################Line1####################
    #ใช้เมาส์คลิกไผยังตำแหน่งที่ต้องการก๊อปปี้ (ด้านหน้า)
    time.sleep(1) #รอ1วินาที
    start_point = (1050, 254 + nextline)
    pg.click(start_point)

    #ลากไปให้สุดบรรทัด
    time.sleep(1)
    end_point = (1400, 254 + nextline)
    pg.dragTo(end_point, duration = 1)

    #กดปุ่ม Ctrl+C
    pg.hotkey('ctrl', 'c')

    #ขยับเมาส์ไปทางด้านซ้าย
    left_box2 = (650, 254 + nextline)
    pg.click(left_box2)

    #กดปุ่ม Ctrl+V เพื่อวาง แล้วกด Enter
    pg.hotkey('ctrl', 'v')
    pg.press('enter')
Example #34
0
    def windows():
        """
		Automate Windows
		"""
        time.sleep(2)
        app = Application().start('explorer.exe')
        time.sleep(2)
        w_handle = pywinauto.findwindows.find_windows(
            title=u'File Explorer', class_name='CabinetWClass')[0]
        window = app.window(handle=w_handle)
        window.set_focus()
        ctrl = window['9']
        ctrl.set_focus()
        ctrl = window['9']
        ctrl.click_input()
        keyboard.SendKeys(os.getcwd() + "{ENTER} {SPACE} {DOWN} {DOWN}")
        if pyautogui.locateOnScreen(os.getcwd() +
                                    '\\Screenshots\\folder\\IT395folder2.PNG',
                                    confidence=.6) is not None:
            pyautogui.moveTo(
                pyautogui.locateCenterOnScreen(
                    os.getcwd() + '\\Screenshots\\folder\\IT395folder2.PNG',
                    confidence=.6))
            if pyautogui.locateOnScreen(
                    os.getcwd() + '\\Screenshots\\website\\DROParea7.PNG',
                    confidence=.6) is not None:
                pyautogui.dragTo(pyautogui.locateCenterOnScreen(
                    os.getcwd() + '\\Screenshots\\website\\DROParea7.PNG',
                    confidence=.6),
                                 duration=3.0,
                                 button='left')
            else:
                print("Could not locate drop area! Exiting...")
                sys.exit()
        else:
            print("Could not locate folder! Exiting...")
            sys.exit()
Example #35
0
def address_scrape():
    """Scrape address and dob from blue chip.
    Used if billing anaesthetist.
    """
    dob = pyperclip.copy('na')
    pya.moveTo(600, 175, duration=0.1)
    pya.click(button='right')
    pya.moveRel(55, 65)
    pya.click()
    dob = pyperclip.paste()
    
    street = pyperclip.copy('na')
    pya.moveTo(500, 240, duration=0.1)
    pya.click(button='right')
    pya.moveRel(55, 65)
    pya.click()
    street = pyperclip.paste()
    
    suburb = pyperclip.copy('na')
    pya.moveTo(330, 285, duration=0.1)
    pya.click(button='right')
    pya.moveRel(55, 65)
    pya.click()
    suburb = pyperclip.paste()
    
    postcode = pyperclip.copy('na')
    pya.moveTo(474, 285, duration=0.1)
    pya.dragTo(450, 285, duration=0.1)
    pya.moveTo(474, 285, duration=0.1)
    pya.click(button='right')
    pya.moveRel(55, 65)
    pya.click()
    postcode = pyperclip.paste()

    address = street + ' ' + suburb + ' ' + postcode

    return (address, dob)
def checkforGold():
    More, loc, max = checkTemplate((356, 757, 461, 870), MoreTemp, .8)
    if More:
        clickPoint(418, 818)  #click more button
        time.sleep(.5)

        #clickDrag(430,713,430,306)
        x0, y0 = win32api.GetCursorPos()
        pyautogui.moveTo(430, 309, duration=0.1)

        pyautogui.dragTo(430, 150, duration=.2)
        win32api.SetCursorPos((x0, y0))
        time.sleep(.5)
        #time.sleep(1.5)
        Treasury, loc, max = checkTemplate((23, 200, 450, 750), TreasuryTemp,
                                           .8)
        if Treasury:
            clickPoint(loc[0] + 23, loc[1] + 200)
            time.sleep(1)
            collectGold, locC, maxC = checkTemplate((0, 640, 466, 740),
                                                    CollectGoldTemp, .8)
            depositGold, locD, maxD = checkTemplate((0, 640, 466, 740),
                                                    DepositGoldTemp, .8)
            #withdrawGold, locW , maxW= checkTemplate((0,640,466,740),WithdrawGoldTemp,
            #.9)

            if collectGold:
                clickPoint(269, 687)
                time.sleep(1.7)
                depositGold = True
            if depositGold:
                clickPoint(278, 691)
                time.sleep(.8)
        else:
            clickDrag(340, 620, 340, 299)
        clickPoint(43, 812)
    CheckEmpireScreen()
Example #37
0
 def imgLines(image_array: numpy.array, offset: int, rowsleep: int,
              lowsleep: int) -> None:
     positionx, positiony = pyautogui.position()
     for row in image_array:
         xoffset = 0
         drawing = False
         for value in row:
             if not value.all():
                 if drawing == True:
                     xoffset += offset
                 else:
                     start = positionx + xoffset
                     drawing = True
                     xoffset += offset
             if value.all():
                 if drawing == False:
                     xoffset += offset
                 else:
                     pyautogui.moveTo(start, positiony)
                     pyautogui.dragTo(positionx + xoffset,
                                      positiony,
                                      duration=lowsleep,
                                      button='left')
                     time.sleep(lowsleep)
                     drawing = False
                     xoffset += offset
         if not value.all():
             if drawing == True:
                 pyautogui.moveTo(start, positiony)
                 pyautogui.dragTo(positionx + xoffset,
                                  positiony,
                                  duration=lowsleep,
                                  button='left')
                 time.sleep(lowsleep)
                 xoffset += offset
         positiony += offset
         time.sleep(rowsleep)
Example #38
0
def capture_screen_data():
    #Click Name of Mushroom
    pyautogui.click(43, 84, duration=0.3)
    #High light text

    pyautogui.moveTo(492, 57, duration=0.3)
    pyautogui.dragTo(1426, 818, button='left', duration=0.3)

    #Copy
    pyautogui.hotkey('ctrl', 'c')

    #Click Close
    pyautogui.click(1400, 819, duration=0.3)

    #Scroll down
    pyautogui.click(468, 805, duration=0.3)

    #paste
    text = pyperclip.paste()

    #Write text to file
    mushroomData = open('mushroom_data.txt', 'a')
    mushroomData.write(text)
    mushroomData.close()
Example #39
0
def draw_by_sequence(coornidations):
    threshold = 10

    auto.PAUSE = 9 / len(coornidations)

    def distance(x1, y1, x2, y2):
        return euclidean((x1, y1), (x2, y2))

    start_position = coornidations[0]
    move_and_click(start_position)

    for i in tqdm(range(1, len(coornidations)), total=len(coornidations)):
        # if i % 10 != 0: continue
        if coornidations[i - 1] is None or coornidations[i] is None: break
        dis = distance(*coornidations[i - 1], *coornidations[i])
        # print(dis)
        if dis > threshold:
            # print('move: {}'.format(coornidations[i]))
            move_and_click(coornidations[i])
        else:
            # print('drag: {}'.format(coornidations[i]))
            K = 50
            duration = distance(*coornidations[i - 1], *coornidations[i]) / K
            auto.dragTo(*coornidations[i], duration, button='left')
def post_to_Twitter():
    click_Twitter_tab()
    click_Twit_button()

    # paste Quake Forecast from clipboard
    pyautogui.hotkey('ctrl', 'v')

    # darg analysis file 1 to Twitter
    x = 160
    y = 70
    pyautogui.moveTo(x, y)
    time.sleep(1)
    pyautogui.click()
    time.sleep(1)
    
    pyautogui.dragTo(1068, 466, 2)
    pyautogui.click()
    time.sleep(1)

    for i in range(0, 6):
        pyautogui.press('tab')
    pyautogui.press('enter')
    
    time.sleep(3)
Example #41
0
def on_screenshot():
    contrs.debug = False
    #for i in range(6):
    screen = pyautogui.screenshot()
    img = np.array(screen)
    img = cv.cvtColor(img, cv.COLOR_RGB2BGR)
    #img = cv.imread('filter_empty.png')
    #img = cv.imread('filter_2.png')
    #img = cv.imread('ast.png')
    #centers = contrs.test(img)
    for i in range(10):
        screen = pyautogui.screenshot()
        img = np.array(screen)
        img = cv.cvtColor(img, cv.COLOR_RGB2BGR)
        #img = cv.imread('filter_empty.png')
        #img = cv.imread('ast.png')
        centers = contrs.test(img)
        if len(centers) == 0:
            return
        x,y= centers
        #for (x,y) in centers:
        pyautogui.moveTo(x, y) 
        #pyautogui.dragTo(860, 514, duration = 0.15) 
        pyautogui.dragTo(300, 388, duration = 0.3) 
Example #42
0
def draw_vectors():  # vector method

    WIDTH = 36
    HEIGHT = 28
    FRAMES = 4382
    FPS = 24

    img = cv2.imread('sample.jpg', 0)
    edges = cv2.Canny(img, 100, 255)

    indices = np.where(edges != [0])
    coords = list(zip(indices[1], indices[0]))

    # coords = []

    # for x in range(HEIGHT):
    #     for y in range(WIDTH):
    #         cod = frame_matrix[x][y]
    #         if cod == 1 and (
    #             (x-1 >= 0 and frame_matrix[x-1][y] != cod) or
    #             (x+1 < HEIGHT and frame_matrix[x+1][y] != cod) or
    #             (y-1 >=0 and frame_matrix[x][y-1] != cod) or
    #             (y+1 < WIDTH and frame_matrix[x][y+1] != cod)):
    #             coords.append((y, x))

    for c1 in coords:
        for c2 in coords:
            if c1 == c2:
                break
            if abs(c1[0] - c2[0]) <= 1 and abs(c1[1] - c2[1]) <= 1:
                gui.moveTo(int(c1[0] * 2.25), int(c1[1] * 1.55) + 180)
                gui.dragTo(int(c2[0] * 2.25), int(c2[1] * 1.55) + 180)

    gui.hotkey('ctrl', 'a')
    gui.press('del')
    select_brush()
Example #43
0
def makeMoveOnScreen(moveCoord, offset, PromoteMove=False):

    mouseClick(BoardDelimitationBox, offset)
    sleep(random() / 2)
    # duplicate moveCoord array so it can be reused in case of failing to move piece on screen.
    moveCoord = copy(moveCoord)
    for x in range(2):
        moveCoord[x] = generateSquareBox(moveCoord[x])
        moveCoord[x] = randomCoordInsideBox(moveCoord[x])

        moveCoord[x][0] += offset[0]
        moveCoord[x][1] += offset[1]

    DragTime = random() / 4 + 0.2
    pyautogui.moveTo(moveCoord[0][0], moveCoord[0][1])
    pyautogui.dragTo(moveCoord[1][0], moveCoord[1][1], DragTime, button='left')

    if PromoteMove:
        sleep(1.0)
        pyautogui.click(x=moveCoord[1][0], y=moveCoord[1][1])
    # to avoid resting the mouse where the button key to new game sits would appear,
    # breaking new game detection.
    pyautogui.moveTo(BoardDelimitationBox[2] + randrange(50),
                     BoardDelimitationBox[3] - randrange(50))
Example #44
0
def makeCircle(x,y):
    openPinta()
    c = 1
    while c <= times:
        cx, cy = x, y
        radius = 100
        angle = 0
        omega = 0.3

        pag.moveTo(x, y, duration=1)
        # parametric equation of circle
        x = cx + radius * math.cos(angle)
        y = cy + radius * math.sin(angle)
        pag.click(x, y)

        while 2 * math.pi - angle >= 0.001:
            angle += omega
            x += radius * omega * math.cos(angle + math.pi / 2)
            y += radius * omega * math.sin(angle + math.pi / 2)
            pag.dragTo(x, y, duration=0.2)

        x += 10
        y += 10
        c += 1
def drag_bottom_to_top(x=None, y=None):  # Drag from bottom of screen to top
    if x and y:
        ptg.leftClick(x, y)
        ptg.dragTo(x, 255, .6, button='left')
    if x and not y:
        ptg.moveTo(x, 996)
        ptg.dragTo(x, 255, .6, button='left')
    if not x and not y:
        ptg.moveTo(930, 996)
        ptg.dragTo(928, 255, 1, button='left')
    def play_next_move(self):
        #This function calculates the next best move with the engine, and play it (by moving the mouse)
        print("\nUs to play: Calculating next move")
        self.engine.position(self.board)
        engine_process = self.engine.go(
            movetime=200)  #random.randint(200,400))

        best_move = engine_process.bestmove
        best_move_string = best_move.uci()
        #print("Play next move")

        #print(bestMove)
        origin_square = best_move_string[0:2]
        destination_square = best_move_string[2:4]

        # I added custom oppenings because I was very annoyed to always see e2e4, feel free to comment or change this
        #Potentially, we could even start the bot after N moves allowing the user to see the games he want
        #Custom white openning:
        #if len(moveHistory) == 0:
        #    origin_square = "b1"
        #   destination_square = "c3"
        #if len(moveHistory) == 2 :
        #    origin_square = "c3"
        #    destination_square = "b1"
        #Custom black openning:
        #if len(moveHistory) == 1 :
        #    origin_square = "g8"
        #    destination_square = "f6"
        #if len(moveHistory) == 3 :
        #    origin_square = "f6"
        #    destination_square = "g8"

        #From the move we get the positions:
        centerXOrigin, centerYOrigin = self.get_square_center(origin_square)
        centerXDest, centerYDest = self.get_square_center(destination_square)

        #Having the positions we can drag the piece:
        pyautogui.moveTo(centerXOrigin, centerYOrigin, 0.01)
        pyautogui.dragTo(
            centerXOrigin, centerYOrigin + 1, button='left', duration=0.01
        )  #This small click is used to get the focus back on the browser window
        pyautogui.dragTo(centerXDest, centerYDest, button='left', duration=0.3)

        if best_move.promotion != None:
            print("Promoting to a queen")
            #Deal with queen promotion:
            cv2.waitKey(100)
            pyautogui.dragTo(centerXDest,
                             centerYDest + 1,
                             button='left',
                             duration=0.1)  #Always promoting to a queen

        print("Done playing move", origin_square, destination_square)
        self.moves_to_detect_before_use_engine = 2
        return
    def play_card(self, hand_size, card, card_type, loc = None, target = []):
        """
        Plays a specific card from the hand with location designated by first
        the hand_size and then the number of the card (index starts at 1).
        card_type specifies whether or not the card to be played is a spell
        or minion, with a location specified in a target list.

        target = [ board_size , minion , enemy ]

        The information in target list is sent to target function to determine
        location of the specified target.

        loc = [ board_size , position ]

        loc is only used when a monster is to be played. The monster will
        either be played on the ends or in between 2 other minions specified
        by position.

        For example: if we have 3 minions on the board

                     [1]    |1|    [2]    |2|    [3]    |3|    [4]

            designated by | |, we have 3+1 positions available to place the
            minion (designated by [ ])
        """
        p.click(self.left + 5, self.top + 5)    # ensure HS is active window
        card_x = self.cards_loc[hand_size][card]/29.5 * self.width + self.left

        if card_type == 'spell':
            p.moveTo(card_x, self.hand_y)
            if target != []:
                x, y = self.target(target[0], target[1], target[2])
                p.dragTo(x, y, duration = 0.25)
            else:
                p.dragTo(self.cx, self.cy, duration = 0.25)
            
                
        elif card_type == 'minion':
            p.moveTo(card_x, self.hand_y)

            board_size, position = loc
            if position == board_size + 1:
                loc_x = self.target(board_size, board_size, False)[0] + \
                        self.minion_width/2
            else:
                loc_x = self.target(board_size, position, False)[0] - \
                        self.minion_width/2
            p.dragTo(loc_x, self.cy, duration = 0.25)
            if target != []:
                x, y = self.target(target[0], target[1], target[2])
                p.moveTo(x, y, duration = 0.25)
                p.click()
        time.sleep(0.75)
Example #48
0
def run_bot(games):
    game_count, concedes = 0, 0
    
    # Click Tavern Brawl
    pyautogui.click(950,560)
    time.sleep(5)

    # Record brawl menu colors to check game status later.
    menu = '(223, 197, 136)'

    for game in range(games):
        # Click Brawl
        pyautogui.click(1500,800)
        time.sleep(50)

        # If hero is Ragnaros, concede the game.
        screen = pyautogui.screenshot()
        portrait = str(screen.getpixel((957, 755)))
        if portrait == '(47, 51, 48)':
            pyautogui.click(1861, 1028)
            pyautogui.click(966, 444)
            time.sleep(10)
            concedes += 1
        
        else:
            # Confirm hand, wait 25 seconds
            pyautogui.click(968, 839)
            time.sleep(25)

            screen = pyautogui.screenshot()
            game_status = str(screen .getpixel((894, 890)))
            while game_status != menu:
                # Wait for my turn
                screen = pyautogui.screenshot()
                turn_status = str(screen.getpixel((1527, 479)))
                my_turn = '(255, 216, 2)'
                while turn_status != my_turn:
                    time.sleep(5)
                    screen = pyautogui.screenshot()
                    turn_status = str(screen.getpixel((1527, 479)))
                
                # Place card(s) onto the board
                hand_location = 620
                for x in range(8):
                    pyautogui.moveTo(hand_location, 966)
                    pyautogui.dragTo(978, 590, duration=0.5)
                    hand_location += 80
                
                # Select cards to attack face
                attacker_location = 600
                taunt_location = 600
                for x in range(8):
                    pyautogui.moveTo(attacker_location, 580)
                    pyautogui.dragTo(taunt_location, 410, duration=1.0) # Taunt minions
                    pyautogui.moveTo(attacker_location, 580, duration=0.3)
                    pyautogui.dragTo(954, 217) # Enemy face
                    time.sleep(1)
                    attacker_location += 80
                    taunt_location += 80

                # End turn, wait for enemy turn
                pyautogui.click(1508, 493)
                
                # Check game status.
                screen = pyautogui.screenshot()
                game_status = str(screen.getpixel((894, 890)))
                
            game_count += 1
            pyautogui.click(1000, 1000) # click to continue
    print('Concedes: '+str(concedes))
Example #49
0
print('当前鼠标移动到 0,0')

c=pg.position() #获取鼠标位置

print(c)
#pg.doubleClick(button='left')#双击  左键 #方便的可以pg.rightClick()双击右键 pg.middleClick()双击中建  
#pg.mouseDown(button='right') #点下  右键
#pg.mouseUp( button='middle')#放开鼠标 中建

pg.click(c)
pg.click(10,10,button='right')

pg.moveTo(1166,50,duration=0.25)

time.sleep(1)
pg.dragTo(1400,50,duration=1)
#pg.dragRel()  #以当前位置拖动

#############
#import pyperclip  # 这个可以把数据保存到剪贴板
#import functools
#a=functools.reduce(lambda x,y:str(x)+'\n'+str(y),[ i for i in range(500)])
#pyperclip.copy(a) #这里已经保存到剪贴板 可用notpad++黏贴 win自带文本不行》
#这里都是为 scroll 做准备  scroll 向上 scroll(负数) 向下滚动

#pg.click();time.sleep(3);pg.scroll(250)

##############屏幕处理
imagetest =pg.screenshot()
rgb = imagetest.getpixel( (400,200) ) #这里传入元祖 得到一个R G B 元组
print(rgb)
            for pt in points_to_remove2:
                if pt in points2:
                    points2.remove(pt)
                    
            points_to_remove = []
            for x in range(len(points2)):
                for pt in points:
                    if (points2[x][0] == pt[0]+1 or points2[x][0] == pt[0]-1 or points2[x][0] == pt[0]) and (points2[x][1] == pt[1]+1 or points2[x][1] == pt[1]-1 or points2[x][1] == pt[1]):
                        points_to_remove.append(pt)
            for pt in points_to_remove:
                if pt in points:
                    points.remove(pt)
            #END OF STONE PURGE
        
        #print out how many stones were found in the end
        print("Stones found: %d" % (len(points)))
        
        #this is where we use pyautogui to simulate mouse clicks/drags
        for pt in range(0, len(points)-1, 2):
            if pt+1 <= len(points):
                print("Starting at point: ", points[pt])
                pyautogui.moveTo(points[pt][0]+25+x_offset, points[pt][1]+25+y_offset)
                print("Moved to point: ", points[pt+1])
				#x coord + 25 (since the width of the inventory space is around 50px) + xoffset, same for y
                pyautogui.dragTo(points[pt+1][0]+25+x_offset,points[pt+1][1]+25+y_offset, 2, pyautogui.easeInQuad,button='left')
                pyautogui.moveTo(5,5)

                

        time.sleep(1.5)
Example #51
0
def draw_list(the_list):
    for pt in the_list:
        pyautogui.dragTo(pt[0],pt[1])
Example #52
0
def drag(mouv):
    pyautogui.moveTo(mouv.tabMouvementDoigts[0][0][0],mouv.tabMouvementDoigts[0][0][1])
    pyautogui.dragTo(mouv.tabMouvementDoigts[0][-1][0],mouv.tabMouvementDoigts[0][-1][1])
def click(amount):
    for x in range(amount):
        pyautogui.click()

for game in range(100):
    for x in range(15):
        person_height = 750 
        drop_height = 320
        width = 1050

        for y in range(14):
            pyautogui.moveTo(width, height, duration=0.1)
            defender_width -= 5
            defender_height -= 5
            pyautogui.dragTo(width, drop_height, duration=0.1) # Drag to top

    # Click "OK"
    pyautogui.moveTo(1100, 755)
    pyautogui.click()

    # Repair
    pyautogui.moveTo(900, 500)
    click(4)

    # Fortify walls
    pyautogui.moveTo(900, 600)
    click(4)

    # Buy archers
    pyautogui.moveTo(1100, 520)
Example #54
0
 def _drag(self, point1, point2, smooth=False, **kwargs):
   self._moveto(point1, smooth=smooth)
   gui.dragTo(point2[0], point2[1], 1 if smooth else 0)
def front_scrape():
    def get_title():
        pya.hotkey('alt', 't')
        title = pyperclip.copy('na')
        pya.moveTo(190, 135, duration=0.1)
        pya.click(button='right')
        pya.moveRel(55, 65)
        pya.click()
        title = pyperclip.paste()
        return title

    pya.click(50, 450)
    title = get_title()
    
    if title == 'na':
        pya.press('alt')
        pya.press('b')
        pya.press('c')
#        pya.press('down')
#        pya.press('enter')
        title = get_title()
    
    if title == 'na':
        pya.alert('Error reading Blue Chip.')
        raise BillingException

    for i in range(4):
        first_name = pyperclip.copy('na')
        pya.moveTo(290, 135, duration=0.1)
        pya.click(button='right')
        pya.moveRel(55, 65)
        pya.click()
        first_name = pyperclip.paste()
        if first_name != 'na':
            break
        if first_name == 'na':
            first_name = pya.prompt(text='Please enter patient first name',
                              title='First Name',
                              default='')

    for i in range(4):
        last_name = pyperclip.copy('na')
        pya.moveTo(450, 135, duration=0.1)
        pya.click(button='right')
        pya.moveRel(55, 65)
        pya.click()
        last_name = pyperclip.paste()
        if last_name != 'na':
            break
        if last_name == 'na':
            last_name = pya.prompt(text='Please enter patient surname',
                              title='Surame',
                              default='')
 
    print_name = title + ' ' + first_name + ' ' + last_name

    mrn = pyperclip.copy('na')
    pya.moveTo(570, 250, duration=0.1)
    pya.dragTo(535, 250, duration=0.1)
    pya.moveTo(570, 250, duration=0.1)
    pya.click(button='right')
    pya.moveRel(55, 65)
    pya.click()
    mrn = pyperclip.paste()
    if not mrn.isdigit():
        mrn = pya.prompt("Please enter this patient's MRN")
    
    return (mrn, print_name)