示例#1
0
 def Recapture():
     global WaitingForClick, Ring
     WaitingForClick = True
     Ring = NameRing.get()
     AutoRingWindow = pygetwindow.getWindowsWithTitle(
         "Module: Auto Ring")[0]
     TibiaAuto = pygetwindow.getWindowsWithTitle("TibiaAuto V12")[0]
     RootWindowX = root.winfo_x()
     RootWindowY = root.winfo_y()
     AutoRingWindowX = self.AutoRing.PositionOfWindow('X')
     AutoRingWindowY = self.AutoRing.PositionOfWindow('Y')
     time.sleep(0.1)
     TibiaAuto.minimize()
     AutoRingWindow.minimize()
     Invisible = GUI('InvisibleWindow', 'InvisibleWindow')
     Invisible.InvisibleWindow('Recapture')
     while WaitingForClick:
         X, Y = GetPosition()
         if keyboard.is_pressed("c"):
             sX, sY = GetPosition()
             time.sleep(0.03)
             pyautogui.screenshot('images/Rings/' + Ring + '.png',
                                  region=(sX - 5, sY - 5, 12, 12))
             WaitingForClick = False
             Invisible.destroyWindow()
             TibiaAuto.maximize()
             TibiaAuto.moveTo(RootWindowX, RootWindowY)
             time.sleep(0.04)
             AutoRingWindow.maximize()
             AutoRingWindow.moveTo(AutoRingWindowX, AutoRingWindowY)
             break
         Invisible.UpdateWindow(X, Y)
示例#2
0
 def restore_win(self, title='Untitled'):
     try:
         gw.getWindowsWithTitle(title)[0].restore()
         if notepadWindo.resotre():
             print(title + ' <-> RESTORE WINDOW', '\n')
     except:
         print('...', '\n')
示例#3
0
 def ReturnGetPosition():
     global WaitingForClick
     WaitingForClick = True
     AutoSSAWindow = pygetwindow.getWindowsWithTitle(
         "Module: Auto SSA")[0]
     TibiaAuto = pygetwindow.getWindowsWithTitle("TibiaAuto V12")[0]
     AutoSSAWindowX = self.AutoSSA.PositionOfWindow('X')
     AutoSSAWindowY = self.AutoSSA.PositionOfWindow('Y')
     time.sleep(0.1)
     TibiaAuto.minimize()
     AutoSSAWindow.minimize()
     Invisible = GUI('InvisibleWindow', 'InvisibleWindow')
     Invisible.InvisibleWindow('GetPosition')
     while WaitingForClick:
         X, Y = GetPosition()
         if keyboard.is_pressed("c"):
             X, Y = GetPosition()
             WaitingForClick = False
             print(f"Your Click Is Located In: [X: {X}, Y: {Y}]")
             TextEntryX.set(X)
             TextEntryY.set(Y)
             Invisible.destroyWindow()
             TibiaAuto.maximize()
             time.sleep(0.08)
             AutoSSAWindow.maximize()
             AutoSSAWindow.moveTo(AutoSSAWindowX, AutoSSAWindowY)
             break
         Invisible.UpdateWindow(X, Y)
示例#4
0
    def run(self, inp, out):
        global windowRegion
        self.st = time.time()
        cnt = 0
        while (True):
            if self.useCam == True:

                windowRegion = (0, 0, self.W, self.H)
            frame = np.array(pyautogui.screenshot(
                region=windowRegion), dtype="uint8")
            frame = imutils.resize(frame, width=480)
            frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
            cv2.imshow("Preview", frame)
            rt = relativedelta(seconds=time.time()-self.st)
            st = ('{:02d}:{:02d}:{:02d}'.format(
                int(rt.hours), int(rt.minutes), int(rt.seconds)))
            self.pushButton.setText('Stop Recording: '+st)
            if cv2.waitKey(1) == 27:
                try:
                    w = gw.getWindowsWithTitle('Windows PowerShell')[0]
                    w.close()
                except:
                    w = gw.getWindowsWithTitle('Command Prompt')[0]
                    w.close()
                cv2.destroyAllWindows()
                break
示例#5
0
 def Recapture():
     global WaitingForClick, Amulet
     WaitingForClick = True
     Amulet = NameAmulet.get()
     AutoSSAWindow = pygetwindow.getWindowsWithTitle(
         "Module: Auto SSA")[0]
     TibiaAuto = pygetwindow.getWindowsWithTitle("TibiaAuto V12")[0]
     AutoSSAWindowX = self.AutoSSA.PositionOfWindow('X')
     AutoSSAWindowY = self.AutoSSA.PositionOfWindow('Y')
     time.sleep(0.1)
     TibiaAuto.minimize()
     AutoSSAWindow.minimize()
     Invisible = GUI('InvisibleWindow', 'InvisibleWindow')
     Invisible.InvisibleWindow('Recapture')
     while WaitingForClick:
         X, Y = GetPosition()
         if keyboard.is_pressed("c"):
             sX, sY = GetPosition()
             time.sleep(0.03)
             from Core.HookWindow import SaveImage
             SaveImage(ItemsPath + 'Amulets/' + Amulet + '.png',
                       Region=(sX - 6, sY - 28, sX + 6, sY - 16))
             WaitingForClick = False
             Invisible.destroyWindow()
             TibiaAuto.maximize()
             time.sleep(0.04)
             AutoSSAWindow.maximize()
             AutoSSAWindow.moveTo(AutoSSAWindowX, AutoSSAWindowY)
             break
         Invisible.UpdateWindow(X, Y)
示例#6
0
def callback(
    *argv
):  #lista wartości współczynnika x od których rozpoczyna się kolejny monitor zaczynając od pierwszego oraz szerokości monitora
    rect = win32gui.GetWindowRect(win32gui.GetForegroundWindow())
    y = rect[1]
    x = rect[0]
    h1 = (rect[3] - y)

    if len(argv[1]) == 1 or x + rect[2] / 2 < argv[1][0]:
        actualWindow = gw.getWindowsWithTitle(
            win32gui.GetWindowText(win32gui.GetForegroundWindow()))[0]
        win32gui.SetWindowPos(win32gui.GetForegroundWindow(),
                              win32con.HWND_TOP, argv[0][0] - 14, int(y),
                              argv[0][1] + 14, int(h1),
                              0)  #zmienia szerokość okna

        a = wysokosc()
        actualWindow.moveRel(
            5, 0
        )  #zmiana pierwszej wartości w nawiasie pozwala na przesunięcie okna
        b = wysokosc()
        actualWindow.resizeRel(0, int((a - b) * 1.60))

        #print('2188?\t',c)
        #printuj_staty_kurwo()
        #print(c-a)

    else:
        actualWindow = gw.getWindowsWithTitle(
            win32gui.GetWindowText(win32gui.GetForegroundWindow()))[0]
        win32gui.SetWindowPos(win32gui.GetForegroundWindow(),
                              win32con.HWND_TOP, argv[1][0], int(y),
                              argv[1][1], int(h1), 0)
        actualWindow.moveRel(-10, 0)
示例#7
0
def startMovie(videoLoc):
    startfile(videoLoc)
    sleep(0.5)
    getWindowsWithTitle(videoLoc)[0].activate()
    press_and_release('space')
    click(1000, 500)
    click(1000, 500)
    press_and_release("space")
示例#8
0
def __resize__(prog):
    #print(prog[0])
    #print(len(prog))

    if len(prog) == 0:
        print("No Windows Open")

    if len(prog) == 1:
        prog0 = str(prog[0])
        print(prog0)
        window = gw.getWindowsWithTitle(str(prog[0]))[0]
        window.maximize()
    if len(prog) == 2:
        prog0 = gw.getWindowsWithTitle(str(prog[0]))[0]
        prog0.restore()
        prog0.resizeTo(976, 1050)
        prog0.moveTo(-7, 0)

        prog1 = gw.getWindowsWithTitle(str(prog[1]))[0]
        prog1.restore()
        prog1.resizeTo(976, 1050)
        prog1.moveTo(960, 0)
    if len(prog) == 3:
        prog0 = gw.getWindowsWithTitle(str(prog[0]))[0]
        prog0.restore()
        prog0.resizeTo(976, 532)
        prog0.moveTo(-7, 0)

        prog1 = gw.getWindowsWithTitle(str(prog[1]))[0]
        prog1.restore()
        prog1.resizeTo(976, 1080)
        prog1.moveTo(960, 0)

        prog2 = gw.getWindowsWithTitle(str(prog[2]))[0]
        prog2.restore()
        prog2.resizeTo(976, 532)
        prog2.moveTo(-7, 525)
    if len(prog) == 4:
        prog0 = gw.getWindowsWithTitle(str(prog[0]))[0]
        prog0.restore()
        prog0.resizeTo(976, 532)
        prog0.moveTo(-7, 0)

        prog1 = gw.getWindowsWithTitle(str(prog[1]))[0]
        prog1.restore()
        prog1.resizeTo(976, 532)
        prog1.moveTo(960, 0)

        prog2 = gw.getWindowsWithTitle(str(prog[2]))[0]
        prog2.restore()
        prog2.resizeTo(976, 532)
        prog2.moveTo(-7, 525)

        prog3 = gw.getWindowsWithTitle(str(prog[3]))[0]
        prog3.restore()
        prog3.resizeTo(976, 532)
        prog3.moveTo(960, 525)
示例#9
0
def focus_to(windowname):
    """
    focuses on window
    example : focus_to("Notepad")
    """
    try:
        gw.getWindowsWithTitle(windowname)[0].activate()
        return True
    except:
        return False
示例#10
0
def restoreWhatsApp():
    if hasWhatsAppOpen():
        gw.getWindowsWithTitle(appName)[0].activate()
        gw.getWindowsWithTitle(appName)[0].maximize()
        OPEN_WHATSAPP_FLAG = False
    else:
        OPEN_WHATSAPP_FLAG = True
        if OPEN_WHATSAPP_FLAG == True:
            subprocess.Popen([routeApp])
            OPEN_WHATSAPP_FLAG = False
def leave_custom_game(sct):
    try:
        gw.getWindowsWithTitle('League of Legends (TM) Client')[0]
    except IndexError:
        raise RuntimeError('League of Legends client not running')

    PressKeyPynput(DIK_ESCAPE)
    ReleaseKeyPynput(DIK_ESCAPE)
    time.sleep(1)
    options_screen_exit_game(sct, sct.monitors[1])
    exit_game_popup_leave_game(sct, sct.monitors[1])
示例#12
0
def start_em():
    #os.startfile('C:\\Program Files (x86)\\Microvirt\\MEmu\\MEmu.exe')
    #time.sleep(25)
    memu = gw.getWindowsWithTitle('MEmu')[0]
    # Has an add portion with the same name
    if len(gw.getWindowsWithTitle('MEmu')) == 2:
        memu.activate()
        memu.close()
        memu = gw.getWindowsWithTitle('MEmu')[0]

    memu.activate()
    memu.resizeTo(850, 520)
    memu.moveTo(0, 0)
示例#13
0
def to_center(windowname):
    """
    change position of windowname to the center
    example : to_center("Media Player")
    """
    try:
        x = int(pgui.size()[0] / 2) - int(size_of(windowname)[0] / 2)
        y = int(pgui.size()[1] / 2) - int(size_of(windowname)[1] / 2)

        gw.getWindowsWithTitle(windowname)[0].moveTo(x, y)
        return True
    except:
        return False
def game_image():
    """
    Obtains a screenshot of the current game state.
    :return: image of the game.
    :raise: if there is no game raise exceptions.GameNotFoundException()
    """
    time.sleep(3)
    current_window = gw.getActiveWindow()
    for title in gw.getAllTitles():
        if "Colonist: Play" in title:
            game_window = gw.getWindowsWithTitle(title)[0]
            game_window.minimize()
            game_window.maximize()
            time.sleep(0.4)

            # Screen capture
            image = ImageGrab.grab()
            image = np.array(image)

            # Removing boarder
            h, w, *_ = image.shape
            image = image[10:h - 10, 10: w - 10]

            image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
            game_window.minimize()
            current_window.maximize()
            return image
    else:
        raise exceptions.GameNotFoundException()
示例#15
0
    def getDataFromMeet(self, meetLink):
        self.log.write("Getting Data from Meet: " + meetLink + ", Please wait")
        time.sleep(2)

        meetWindow = gw.getWindowsWithTitle("Google Chrome")[0]
        meetWindow.activate()
        meetWindow.maximize()
        max_X, max_Y = pyautogui.size()

        #pyautogui.click(max_X*(1050/1366), max_Y*(100/768))
        self.driver.find_element_by_css_selector(
            ".uArJ5e.UQuaGc.kCyAyd.QU4Gid.foXzLb.IeuGXd.M9Bg4d").click()
        #self.driver.find_element_by_css_selector('div[jsname="VyLmyb"]').click()
        time.sleep(2)
        participants = self.driver.find_elements_by_class_name("ZjFb7c")

        prepdList = []
        self.log.write("Preparing final data")
        for i in participants:
            eachName = i.get_attribute("innerText").lower().split()
            for a in eachName:
                prepdList.append(a)

        self.log.write("Data successfully obtained from Google Meet")
        return prepdList
示例#16
0
def is_len_small() -> bool:
    """
    Determines if user has opened meeting window or not
    :return: bool
    """
    return False if len(
        gw.getWindowsWithTitle('Microsoft Teams')) > 1 else True
def compute_distance(image,x,y,w,h):
    ''' This function calculates the distance between the object and camera'''
    
    #Step 1- Display coordinates of the face    
    center_x = x+w//2
    center_y = y+h//2

    #Step 2- Find the area of the face
    area = w*h
    dist = int(4390.0*(area**(-0.406)))
    
    print("Distance in cm: {}".format(dist))
    
    image_dist = cv2.putText(image,"Distance: "+str(dist)+"cm",(x-w,y),cv2.FONT_HERSHEY_SIMPLEX,1,(0, 0, 0),2)
    
    cv2.imshow("Image",image_dist)
    cv2.waitKey(1)    
        
    window = pgw.getWindowsWithTitle('Spyder (Python 3.8)')[0]
        
    if dist<65:
        window.minimize()
    else: 
        if window.isMinimized:
           window.maximize() 
           
    if 0xFF == ord('q'):
        exit()
示例#18
0
def rlTabSwitch(tab):
    screenshot = wincap.get_screenshot()
    points = findClickPositions('assets/util/rl-settings.png',
                                screenshot,
                                threshold=0.95)
    rl = gw.getWindowsWithTitle('RuneLite')[0]
    x_off, y_off = rl.topleft
    if points:
        x, y = points.pop(0)
        pag.moveTo(x + x_off, y + y_off, duration=random.uniform(0.1, 0.3))
        pag.click()
    else:
        points = findClickPositions('assets/util/rl-search-icon.png',
                                    screenshot,
                                    threshold=0.95)
        if points:
            x, y = points.pop(0)
            pag.moveTo(x + x_off + 30,
                       y + y_off,
                       duration=random.uniform(0.1, 0.3))
            pag.click()
            pag.keyDown('ctrl')
            pag.press('a')
            pag.keyUp('ctrl')
            pag.press('backspace')
        else:
            print('try restarting with a runelite tab open')
示例#19
0
def logout():
    img = wincap.get_screenshot()
    rl = gw.getWindowsWithTitle('RuneLite')[0]
    x_off, y_off = rl.topleft
    tabSwitch('assets/util/logout.png', img)
    needle = 'assets/util/clickheretologout.png'
    screenshot = wincap.get_screenshot()
    points = findClickPositions(needle, screenshot, threshold=0.99)
    # if the logout tab is not on the world switcher page, click the logout button
    if points:
        x, y = points.pop(0)
        pag.moveTo(x + x_off, y + y_off)
        pag.click()
    # if the logout tab is on the world switcher page, exit the page and then click the logout button
    else:
        needle = 'assets/util/x.png'
        screenshot = wincap.get_screenshot()
        points = findClickPositions(needle, screenshot, threshold=0.99)
        x_x, x_y = points.pop(0)
        pag.moveTo(x_x + x_off, x_y + y_off)
        pag.click()
        time.sleep(1)
        needle = 'assets/util/clickheretologout.png'
        screenshot = wincap.get_screenshot()
        points = findClickPositions(needle, screenshot, threshold=0.99)
        x, y = points.pop(0)
        pag.moveTo(x + x_off, y + y_off)
        pag.click()
    def play_song(self, *args, **kwargs):
        client_id = ""
        client_secret = ""

        def connect_to_spotify():
            client_credentials_manager = SpotifyClientCredentials(
                client_id=client_id, client_secret=client_secret)
            sp = spotipy.Spotify(
                client_credentials_manager=client_credentials_manager)
            return sp

        def search_track(search_query: str):
            conn = connect_to_spotify()
            result = conn.search(search_query, type="track")
            found_songs = {}
            for set in result["tracks"]["items"]:
                found_songs[set["name"].lower()] = set["uri"]
            return found_songs

        if client_id and client_secret:
            songs = search_track(args[0])
            os.system("start {}".format(songs.get(list(songs.keys())[0])))
            window = pygetwindow.getWindowsWithTitle("spotify")
            window[0].activate()
            time.sleep(0.5)
            loc = pyautogui.locateOnScreen(
                "assets/images/highlighted_song.png", confidence=.9)
            if loc:
                pyautogui.click(loc.left,
                                int(loc.top + (loc.height / 2)),
                                clicks=2)
示例#21
0
def activate_window(title=XTU_WINDOW_NAME, retry_count=5):
    """Grab and active the window with title

    Args:
        title (str): Window of the window to be grab and activate
        retry_count (int, optional): Number of attempt to grab the window. Defaults to 5.
    """
    window_found = False
    count = 0
    while window_found is False:
        try:
            xtu_window = gw.getWindowsWithTitle(XTU_WINDOW_NAME)[0]
            logger.info(f'XTU window found!')
            logger.info(f'Window: {xtu_window}')
            xtu_window.activate()
            time.sleep(1)
            window_found = True
            return xtu_window
        except IndexError:
            logger.info(
                f"Grabbing XTU window with title '{XTU_WINDOW_NAME}', retry in 5 seconds ({count}/5)"
            )
            count += 1
            time.sleep(5)
            continue
示例#22
0
    def screen_record(self):
        self.flag = 0

        self.tomin = gw.getWindowsWithTitle('MainWindow')[0]
        self.tomin.minimize()
        time.sleep(1)

        self.SCREEN_SIZE = pyautogui.size()
        fourcc = cv2.VideoWriter_fourcc(*"XVID")

        self.path_1 = os.path.dirname(os.path.abspath(__file__))
        self.store_1 = os.path.join(self.path_1, "ScreenRecording")
        j = 0
        if os.path.isdir(self.store_1):
            while os.path.exists(self.store_1 + "\\output%s.avi" % j):
                j += 1
            self.out = cv2.VideoWriter(self.store_1 + "\\output%s.avi" % j,
                                       fourcc, 24.0, (self.SCREEN_SIZE))
        else:
            os.mkdir(self.store_1)
            self.out = cv2.VideoWriter(self.store_1 + "\\output%s.avi" % j,
                                       fourcc, 24.0, (self.SCREEN_SIZE))

        self.x = threading.Thread(target=self.do_work, args=(1, ))
        self.x.start()
示例#23
0
 def fullscreen(self):
     if self.has_modules:
         scrcpy_window = getWindowsWithTitle("scrcpy")[0]
         scrcpy_window.focus()
         auto.hotkey("alt", "f")
     else:
         wmctrl_xdotool_linux_send_key("f")
示例#24
0
 def copy_pc2dev(self):
     if self.has_modules:
         scrcpywindow = getWindowsWithTitle("scrcpy")[0]
         scrcpywindow.focus()
         auto.hotkey("alt", "shift", "c")
     else:
         wmctrl_xdotool_linux_send_key("shift+c")
示例#25
0
 def find_target_window_by_search_str(self):
     self.set_output_file()
     window_titles = gw.getAllTitles()
     while True:
         try:
             print(
                 f'Searching For Windows With The Title | {self.search_str}'
             )
             self.target_window = gw.getWindowsWithTitle([
                 _ for _ in window_titles
                 if self.search_str.lower() in _.lower()
             ][0])[0]
             self.window_found = True
             break
         except Exception as e:
             self.window_found = False
             if sg.PopupYesNo(
                     f'No Window With The Title {self.search_str} Was Found.\n\nSearch Again?',
                     keep_on_top=True,
                     no_titlebar=True) == 'Yes':
                 self.search_str = sg.PopupGetText('Enter The Search Word:',
                                                   keep_on_top=True,
                                                   no_titlebar=True,
                                                   default_text='project')
                 continue
             else:
                 raise (e)
示例#26
0
def __job__():
     # Gets all open windows, runs through the list of excluded programs and sorts by visibility
     windows = Desktop(backend="uia").windows()
     windowList = ([w.window_text() for w in windows])
     ExcludeFromList.__remove__(windowList)
     Visibility.__notMinimized__(windowList)

     # Checks for ammount of monitors

     monitorLen = len(monitors)

     # Checks if a new window has been opened or a window has been closed
     if len(windowList) == numWindow and len(monitors) == monitorLen:
          #null = 'null'
          print('Number of window stays the same')
     else:
          numWindow = len(windowList) # Updates the number of open windows
          print("List length: " + str(len(windowList)))
          # Additional checks when running in IDE
          for program in windowList:
               Window = gw.getWindowsWithTitle(program)[0]
               print(Window)
          windowList = tuple(windowList)

          # Arranges windows depending on number of connected monitors
          count = 0
          while count <= 3:
               if monitorLen == 1:
                    ResizeSingle.__resize__(windowList)
                    count += 1
               if monitorLen == 2:
                    ResizeDual.__resize__(windowList)
                    count += 1
示例#27
0
    def _get_window(self):
        windows = gw.getWindowsWithTitle(LEAGUE_GAME_WINDOW_TITLE)

        if len(windows) < 1:
            self.hwnd = None
        else:
            self.hwnd = windows[0]
示例#28
0
    def _new_mode(self):

        for transaction in gui.getAllTitles():
            if transaction.startswith('ZLPC'):
                continue
            elif transaction.startswith(titles_tuple):
                temp_transaction = gui.getWindowsWithTitle(str(transaction))[0]
                temp_transaction.activate()
                print(temp_transaction)
                hotkey(transaction_names['new_mode'], (410, 30, 575, 60),
                       'ctrl', 'n')
                while gui.getActiveWindowTitle == temp_transaction:
                    print(gui.getActiveWindowTitle)
                    gui.sleep(0.25)
                print('test')
                if 'Information' in gui.getAllTitles():
                    dialog = gui.confirm(text='Много окошек. Закрываю одно',
                                         title='Limit of tabs',
                                         buttons=['OK', 'Cancel'])
                    if dialog == 'OK':
                        information = gw.getWindowsWithTitle('Information')[
                            0]  # ЗАКРЫВАЕТ ВСЕ ОКНА
                        print(information)
                        gui.press('esc')
                        print(temp_transaction)
                        temp_transaction.close()
                        continue
                    else:
                        exit()
                elif gui.locateOnScreen(transaction_names['sap_easy_access'],
                                        region=names_region):
                    break
示例#29
0
        def getScreenOutputModel(self, width = None, height = None):
            """Get a generator that returns a numpy array of screen captures of the application.\n
            \nCalling next on the generator while the application window is not visible will render the generator inert -- stopIteration will be thrown."""
            with mss() as sct:
                window = None
                try:
                    window = gw.getWindowsWithTitle(self.windowTitle)[0]
                except IndexError:
                    raise Exception("The window with title " + self.windowTitle + " does not exist")
                window.restore()
                window.show()
                window.activate()
                if(width != None and height != None):
                    window.resizeTo(width, height)
                    self.width = width
                    self.height = height
                else:
                    self.width = window.width
                    self.height = window.height
                window.moveTo(0,0)
                self.x = 0
                self.y = 0
                screenWidth, screenHeight = pyautogui.size()
                pyautogui.moveTo(int(screenWidth),int(screenHeight))
                mon = sct.monitors[self.monitor_number]
                self.monitor = {'top': mon["top"] + window.top, 'left': mon["left"] + window.left + 10, "width": window.width - 20, "height": window.height - 10, "mon": self.monitor_number}

                while True:
                    if window.visible:
                        yield numpy.array(sct.grab(self.monitor))
                    else:
                        return
示例#30
0
def login(username, password):
    img = wincap.get_screenshot()
    rl = gw.getWindowsWithTitle('RuneLite')[0]
    x_off, y_off = rl.topleft
    # clicks the "existing user" button, enters the user credentials
    needle = 'assets/util/existing.png'
    points = findClickPositions(needle, img, threshold=0.99)
    coords = points.pop(0)
    x, y = coords
    pag.moveTo(x + x_off, y + y_off)
    pag.click()
    pag.write(user.getLogin())
    pag.press('tab')
    pag.write(user.getPassword())
    pag.press('enter')
    # sleep between logging in and looking for the next button because of server lag
    time.sleep(7)
    # find and click the "click here to play button"
    needle = 'assets/util/clickheretoplay.png'
    screenshot = wincap.get_screenshot()
    points = findClickPositions(needle, screenshot, threshold=0.99)
    coords = points.pop(0)
    x, y = coords
    pag.moveTo(x + x_off, y + y_off)
    pag.click()
示例#31
0
def test_basic_win32():
    subprocess.Popen('notepad')
    time.sleep(0.5)

    testWindows = pygetwindow.getWindowsWithTitle('Untitled - Notepad')
    assert len(testWindows) == 1

    npw = testWindows[0] # testWindows[0] is the notepad window

    # Test maximize/minimize/restore.
    if npw.isMaximized: # Make sure it starts un-maximized
        npw.restore()

    assert not npw.isMaximized

    npw.maximize()
    assert npw.isMaximized
    npw.restore()
    assert not npw.isMaximized
    npw.minimize()
    assert npw.isMinimized
    npw.restore()

    # Test resizing
    npw.resizeTo(300, 200)
    time.sleep(0.5)
    assert npw.size == (300, 200)
    assert npw.width == 300
    assert npw.height == 200

    npw.resizeRel(10, 20)
    time.sleep(0.5)
    assert npw.size == (310, 220)
    assert npw.width == 310
    assert npw.height == 220

    # Test moving
    npw.moveTo(10, 20)
    assert npw.topleft == (10, 20)
    assert npw.left == 10
    assert npw.top == 20
    assert npw.right == 320
    assert npw.bottom == 240
    assert npw.bottomright == (320, 240)
    assert npw.bottomleft == (10, 240)
    assert npw.topright == (320, 20)

    npw.moveRel(1, 2)
    assert npw.topleft == (11, 22)
    assert npw.left == 11
    assert npw.top == 22
    assert npw.right == 321
    assert npw.bottom == 242
    assert npw.bottomright == (321, 242)
    assert npw.bottomleft == (11, 242)
    assert npw.topright == (321, 22)

    # Move via the properties
    npw.resizeTo(301, 201)
    npw.moveTo(11, 21)

    npw.left = 200
    assert npw.left == 200

    npw.right = 200
    assert npw.right == 200

    npw.top = 200
    assert npw.top == 200

    npw.bottom = 200
    assert npw.bottom == 200

    npw.topleft = (300, 400)
    assert npw.topleft == (300, 400)

    npw.topright = (300, 400)
    assert npw.topright == (300, 400)

    npw.bottomleft = (300, 400)
    assert npw.bottomleft == (300, 400)

    npw.bottomright = (300, 400)
    assert npw.bottomright == (300, 400)

    npw.midleft = (300, 400)
    assert npw.midleft == (300, 400)

    npw.midright = (300, 400)
    assert npw.midright == (300, 400)

    npw.midtop = (300, 400)
    assert npw.midtop == (300, 400)

    npw.midbottom = (300, 400)
    assert npw.midbottom == (300, 400)

    npw.center = (300, 400)
    assert npw.center == (300, 400)

    npw.centerx = 1000
    assert npw.centerx == 1000

    npw.centery = 1000
    assert npw.centery == 1000

    npw.width = 300
    assert npw.width == 300

    npw.height = 200
    assert npw.height == 200

    npw.size = (301, 201)
    assert npw.size == (301, 201)


    # Test closing
    npw.close()