Exemplo n.º 1
0
def main():
    minecraft_handle = Application().connect(title_re="Minecraft 1.14.4",
                                             class_name="GLFW30")
    main_window = minecraft_handle.top_window()
    while True:
        main_window.right_click()
        time.sleep(0.1)
Exemplo n.º 2
0
def pr_crack():
    step = {
        0: ["Adobe Acrobat DC", "TsEdit", "Adobe Prelude CC 2015", 'edit', 10],
        1: [
            "V7{}AcrobatCont-12-Win-GM", "TsEdit", "V7{}Prelude-4-Win-GM",
            'edit', 10
        ],
        2: ["15.7.0", "TsEdit", "4.0.0", 'edit', 10],
        3: ["Install", "TButton", 'click', 10],
        4: [
            "", "Edit",
            r"C:\Program Files\Adobe\Adobe Premiere Pro CC 2018\amtlib.dll",
            'edit', 10
        ],
        5: ["打开(&O)", "Button", 'click', 10]
    }

    pr_cra = Application().start(join(getcwd(), "app_pkg", 'PRCC2018',
                                      'crack'))
    for i in range(len(step)):
        next_step = pr_cra.top_window().child_window(
            title=step[i][0], class_name=step[i][1]).wait('ready',
                                                          timeout=step[i][-1])
        if step[i][-2] == 'click':
            next_step.click_input()
            if i in [3, 5]:
                sleep(1)
        elif step[i][-2] == 'edit':
            next_step.set_text(step[i][2])
    pr_cra.kill()
Exemplo n.º 3
0
def uninstall(uninstaller_path):
    # 1. start uninstaller
    run_external(uninstaller_path)
    time.sleep(2)

    # 2. find the installer dialog
    uninstaller = None
    try:
        uninstaller = Application().connect(title=u'2345王牌输入法 卸载程序')
    except Exception as e:
        raise RuntimeError('Cannot find uninstaller, exception: %s' % repr(e))

    # 3. get position of the install button and note the installed path
    # can get all handlers by call like this:
    # print(installer.window_(title_re=u'2345王牌输入法 v[0-9]+\.[0-9]+ 安装').print_control_identifiers())
    uninstall_dlg = uninstaller.window_(title=u'2345王牌输入法 卸载程序')
    print(uninstall_dlg.print_control_identifiers())

    l, r, t, b = uninstall_dlg.Rectangle().left, uninstall_dlg.Rectangle().right, \
                 uninstall_dlg.Rectangle().top, uninstall_dlg.Rectangle().bottom
    pos = (int(l + (r - l) * 0.713), int(t + (b - t) * 0.923))
    print('Move mouse to button(%d, %d)' % (pos[0], pos[1]))
    uninstall_dlg.click_input(coords=pos, absolute=True)
    resolve_confirm_dlg(title_re=u'2345王牌输入法卸载程序')

    # 4. wait for finish
    confirm_pos = (int(l + (r - l) * 0.9), int(t + (b - t) * 0.9))
    while uninstall_dlg.exists():
        uninstall_dlg.click_input(coords=confirm_pos, absolute=True)
        time.sleep(5)
Exemplo n.º 4
0
 def restart(self):
     self.spec.set_focus()
     rect = self.spec.rectangle()
     print(rect)
     loc = find_image(IMG_LOC + "/exit.png", rect=rect)
     if loc is not None:
         x_left = self.spec.rectangle().left
         y_top = self.spec.rectangle().top
         while x_left < -10 or y_top < -10:
             x_left = self.spec.rectangle().left
             y_top = self.spec.rectangle().top
             time.sleep(0.25)
         x = loc[0] + x_left
         y = loc[1] + y_top
         mouse.click(coords=(x, y))
         print("clicked x")
         time.sleep(0.5)
         keyboard.send_keys("{ENTER}")
         time.sleep(10)
         self.app = Application().start(self.RS3_loc)
         self.spec = None
         self.spec_connected = False
         self.spec = self.app.ThunderRT6Form
         self.spec.draw_outline()
         self.pid = self.app.process
         self.menu = RS3Menu(self.app)
     else:
         print("Error: Failed to restart RS3")
Exemplo n.º 5
0
    def __init__(self, binary_path=r'C:\bb\bbw.exe', try_connect=True):
        self.biab_version = _get_exe_version(binary_path)
        if self.biab_version != self._TARGET_VERSION:
            print('This code was written for Band-in-a-Box {}, your version is {}. '
                  'Proceed with caution.'
                  .format(self._TARGET_VERSION, self.biab_version), file=sys.stderr)

        self._app = Application(backend='win32')
        if try_connect:
            try:
                self._app.connect(path=binary_path)
            except ProcessNotFoundError:
                try_connect = False
        if not try_connect:
            self._app.start(binary_path)
            self._app.wait_cpu_usage_lower(threshold=5)

        def get_ready():
            rb_window = self._app.window(class_name='TBandWindow')
            if rb_window.exists() and rb_window.is_visible() and rb_window.is_enabled():
                return

            raise TimeoutError()

        wait_until_passes(func=get_ready,
                          exceptions=(ElementNotFoundError, TimeoutError),
                          timeout=15, retry_interval=1)
Exemplo n.º 6
0
    def foreGroundDiscord(
            self):  # it will make discord window top of all other windows

        windows = Desktop(backend="uia").windows()

        title = ""
        for w in windows:
            if "Discord" in str(w.window_text):
                title = str(w.window_text).split("'")[1]
                break

        app = None
        try:
            app = Application().connect(title_re=title)

        except (__import__("re").error,
                pywinauto.findwindows.ElementAmbiguousError):
            raise GuiDoesNotExists
            return

        hwin = app.top_window()

        hwin.set_focus()

        sleep(0.9)
Exemplo n.º 7
0
def init_sv_login(event, sv_app, menu_names):
    """
    function to get the label that is clicked
    and launch the sv application
    """
    # Launch the application
    evt_id = event.GetId() - 1
    app = Application(backend='uia').start(sv_app)

    # get the Dialogue Handler
    dlg = app.window(title_re='Singleview Convergent Billing.*')

    db_pane = dlg.child_window(title="Database", control_type="Pane")

    # set variables from the clicked menu
    keys_list = list(menu_names.keys())
    db = menu_names[keys_list[evt_id]][0]
    uname = menu_names[keys_list[evt_id]][1]
    passwd = menu_names[keys_list[evt_id]][2]
    # set database name
    db_edit = db_pane.Edit0
    db_edit.set_text(db)

    # set user name
    uname_edit = db_pane.Edit3
    uname_edit.set_text(uname)

    # set password name
    pass_edit = db_pane.Edit2
    pass_edit.set_text(passwd)

    dlg.Ok.click()
Exemplo n.º 8
0
def init_weixin():

    # app = Application().connect(
    #     path=r"C:\Program Files (x86)\Tencent\WeChat\WeChat.exe")
    #
    # if not app.windows():
    #     app = Application().connect(
    #         path=r"C:\Program Files (x86)\Tencent\WeChat\WeChat.exe")
    #
    #
    #
    # dlg = app.window(title=u"微信", class_name="WeChatMainWndForPC")
    # dlg.move_window(0, 0)
    # dlg.maximize()
    # dlg.set_focus()

    dlgs = []
    rets = pywinauto.findwindows.find_windows(class_name="WeChatMainWndForPC")
    for ret in rets:
        app = Application().connect(handle=ret)
        dlg = app.window(title=u"微信", class_name="WeChatMainWndForPC")
        dlg.move_window(0, 0)
        dlg.maximize()
        dlg.set_focus()
        dlgs.append(dlg)
        time.sleep(1)

    return dlgs
Exemplo n.º 9
0
def open_chrome():
    # path to chrome
    chrome_dir = r'"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"'

    # open chrome maximized and allow access to pywinauto
    chrome = Application(backend='uia')
    chrome.start(chrome_dir +
                 ' --force-renderer-accessibility --start-maximized')

    # sleep for random time to allow page to load and go to zoominfo.com
    time.sleep(float(decimal.Decimal(random.randrange(50, 150)) / 100))

    send_keys("zoominfo.com {ENTER 2}")

    # sleep for enough time for me to move mouse to the 'login' button to get coordinates
    time.sleep(float(decimal.Decimal(random.randrange(150, 300)) / 100))
    time.sleep(7)

    # print coordinates of mouse over the login button
    position = pyautogui.position()
    print(position)

    # move mouse to and click on the login button
    pywinauto.mouse.click(button='left', coords=(1737, 104))

    time.sleep(float(decimal.Decimal(random.randrange(150, 300)) / 100))
Exemplo n.º 10
0
    def connect_to_solis(self):
        """

        Attaches a pywinauto controller to the Andor Window.

        The connection times out after 3 seconds.

        It then creates the variable 'self.soliswin' which will be used by
        the script later.

        """

        prompt("Attempting to Connect to SOLIS")
        try:
            self.solis = Application().connect(title_re="Andor SOLIS",
                                               timeout=3)
            self.soliswin = self.solis.window(title_re="Andor SOLIS",
                                              found_index=0)
            self.view()
        except TimeoutError:
            msg = "Connection to SOLIS Timed Out."
            self.test.append(msg)
            error_prompt(msg)
        except MenuItemNotEnabled:
            msg = "Connection to the Camera Failed."
            self.test.append(msg)
            error_prompt(msg)
Exemplo n.º 11
0
class Converter:
    def __init__(self):
        self.exe = "C://Program Files (x86)/Auntec/嗨格式PDF转换器/HiPdfConvert.exe"
        self.app = Application(backend="uia")
        # self.app.start(self.exe)
        self.app.connect(path=self.exe)

        # time.sleep(8)
    def windows(self):
        s1 = self.app.window(best_match='嗨格式PDF转换器1.0')
        s2 = s1["pdf转文件"]
        s2.print_control_identifiers()
        s3 = s2.child_window(title="文件名称", control_type="Text")
        s3.type_keys("afda")

        s4 = s2.child_window(title="开始转换", control_type="Text")
        s4.type_keys("{ENTER}")

    def open(self):
        auto.hotkey("alt", "tab")
        # auto.moveTo(x=980, y=990)
        # auto.click()
        auto.moveTo(x=580, y=251)
        auto.click()
        f = "D://mygit/cpa_std/cpa_std/vehicle_insurance/data/pdf/eacd2c918f264f568096f4cea0e698f0.pdf"
        f = os.path.abspath(f)
        auto.typewrite(message=f)
        auto.press("enter")
        auto.moveTo(x=1400, y=911)
        auto.click()
        auto.moveTo(x=700, y=611)
        auto.click()
    def connectToHndlFetchPossibleUrl(self, win_hndl):
        app = Application(backend='uia')

        try:
            app.connect(handle=win_hndl)
            dlgs = app.windows(
            )  # for some reason when we fetch the list of opens windows for a given app, urls seems to be fetched 'always' correctly, when we use app.top_window() sometimes url element is empty
            # when we handle list of windows; then top window is always first on the list; and during checking url validation whe always stop after getting the first url
            # hacky, but seems to work now
        except RuntimeError:
            print('Couldnt connect to last application :(')
            fetched_url = ''
        else:
            potential_urls = self.__findPotentialUrlsFromBrowser(dlgs)
            fetched_url = self.__findUrlInStringList(potential_urls)

            # XTODO: Think of a way to fix this brutal way; possibly dlg.wait() could be useful, need to play with it's
            # parameters, so this wait wouldnt fail
            # doesnt seem to necessary anymore
            # if fetched_url == '':
            #     time.sleep(1)
            #     potential_urls = self.__findPotentialUrlsFromBrowser(dlgs)
            #     fetched_url = self.__findUrlInStringList(potential_urls)

        return fetched_url
Exemplo n.º 13
0
def auto_login(steamid, name, lock):
    eel.info("使用快取登入", "使用者名稱:" + name + "\nsteamid:" + steamid, "console")
    key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, "SOFTWARE\Valve\Steam", 0,
                         winreg.KEY_ALL_ACCESS)
    winreg.SetValueEx(key, "AutoLoginUser", 0, winreg.REG_SZ, name)
    winreg.SetValueEx(key, "RememberPassword", 0, winreg.REG_DWORD, 0x00000001)
    exe, t = winreg.QueryValueEx(key, "SteamExe")
    winreg.CloseKey(key)

    si = subprocess.STARTUPINFO()
    si.dwFlags |= subprocess.STARTF_USESHOWWINDOW

    eel.info("關閉Steam", "", "console")
    close_steam(exe, si)

    eel.info("啟動steam", "", "console")
    app = APP().start(exe)
    login_gui = app.window(title_re='Steam [^Guard].*',
                           class_name='vguiPopupWindow')

    eel.info("等待 '主頁面'", "", "console")
    wait_time = app_setting("wait_steam_start")
    eel.info("容許等待時間" + wait_time, "", "console")
    eel.sleep(int(wait_time))
    try:
        login_gui.wait_not("ready", wait_time)  #等待介面
    except:
        eel.info("注意!", "無法使用快取登入\n將使用模擬登入", "console")
        login(steamid, lock, app, True)
    else:
        del app
        lock.release()
        eel.info("登入成功", "", "console")
Exemplo n.º 14
0
def tm_init():
    if (os.path.exists(r"E:\TCMS_LIVE\Client Suite")):
        templa_file = r"E:\TCMS_LIVE\Client Suite\TemplaCMS32.exe"
        app = Application(backend='uia').connect(path=templa_file)
        templa = app.window(title_re='TemplaCMS*')
        return [templa, app]
    else:
        return None
Exemplo n.º 15
0
def notepad():
    notepad = Application().start('notepad.exe')

    yield notepad

    # Clear Notepad's contents to prevent any save prompts.
    notepad.UntitledNotepad.Edit.type_keys('^A{DEL}')
    notepad.kill()
Exemplo n.º 16
0
 def start_app(self):
     try:
         app = Application().connect(path=self.EXE_NAME)  #连接已经启动的应用
         print("连接已经启动的应用")
     except:  #如果没有已经启动的应用则启动应用
         app = Application().start(self.EXE_NAME)  # 打开程序
         print("新启动应用")
     return app
Exemplo n.º 17
0
def todo():
    app = Application(backend='uia')
    app.connect(title_re=".*Chrome.*")
    dlg = app.top_window()
    url = dlg.child_window(title="Address and search bar",
                           control_type="Edit").get_value()
    site = url.split('/')[0]
    print(site)
Exemplo n.º 18
0
def startCalcDialog() -> Application():
    "This method just returns a Calculator dialog"
    app = Application(backend='uia').start('calc.exe')
    # needed since the application spaws additional processes
    # windows = Desktop(backend='uia').windows()
    # for w in windows:
    #     print(w.window_text())
    return Desktop(backend='uia').Calculator
Exemplo n.º 19
0
def wowForFront():
    print('Searching for WoW process..')
    for pid in psutil.pids():
        if psutil.Process(pid).name().lower() == 'wow.exe':
            print('Found WoW')
            app = Application().connect(process=pid)
            app.top_window().set_focus()
            pyautogui.moveTo(960, 540, duration=1)
Exemplo n.º 20
0
    def find_deltagen_viewer_widget(self):
        """ Find the DeltaGen viewer window inside window controls """
        if not self.has_handle():
            return None

        if not self._app:
            try:
                self._app = Application().connect(handle=self._handle)
            except Exception as e:
                LOGGER.error(e, exc_info=1)
                return None

        try:
            dg_win = self._app.window(title_re='DELTAGEN *',
                                      depth=1,
                                      found_index=0)
        except Exception as e:
            LOGGER.error(e, exc_info=1)
            return None

        dg_version = self._read_dg_version(dg_win)
        viewer = None

        try:
            if dg_version == 2018:
                workspace = dg_win.child_window(title_re='workspace*', depth=1)
                viewer = workspace.child_window(title='pGLWidgetWindow',
                                                depth=2,
                                                found_index=0)
            else:
                workspace = dg_win.child_window(title='workspace', depth=1)
                viewer_window = workspace.child_window(title='untitled',
                                                       depth=1,
                                                       class_name='QWidget',
                                                       found_index=0)
                search_terms = (
                    'pGLWidget',  # DeltaGen > 2017x
                    ''  # DeltaGen 12.2
                )
                for term in search_terms:
                    if viewer_window.child_window(title=term,
                                                  depth=1,
                                                  class_name='QWidget',
                                                  found_index=0).exists():
                        viewer = viewer_window.child_window(
                            title=term,
                            depth=1,
                            class_name='QWidget',
                            found_index=0)
                        break

            if not viewer:
                return
        except Exception as e:
            LOGGER.error(e, exc_info=1)
            return None

        return viewer
Exemplo n.º 21
0
    def __init__(self, handle):
        self.handle = handle  # ウィンドウハンドル
        self.app = Application().connect(handle=handle)
        self.navwin = self.app.window(handle=handle)

        self.w_aspect = 16
        self.h_aspect = 9

        self.RefreshWindowSize()
Exemplo n.º 22
0
Arquivo: check.py Projeto: nkpc14/ARYA
 def exitApp(self, param):
     if param == "sublime":
         self.app = Application().connect(title_re=".*Notepad",
                                          class_name="Notepad")
         self.app.notepad.menu_select("File->Exit")
     elif param == "notepad":
         self.app = Application().connect(title_re=".*Notepad",
                                          class_name="Notepad")
         self.app.notepad.menu_select("File->Exit")
Exemplo n.º 23
0
class Application:
    def __init__(self, target):
        self.application = WinApplication(backend="win32").start(target)
        self.main_window = self.application.window(title="Free Address Book")
        self.main_window.wait("visible")
        self.groups = GH(self)

    def destroy(self):
        self.application.window(title="Free Address Book").close()
Exemplo n.º 24
0
    def __init__(self, main):
        self.main = main
        keystroke(main, F6)  # 切换到双向委托
        wait_a_second()  # 可调整区间值(0.01~0.5)

        # 打新快捷键554

        self.buff = ctypes.create_unicode_buffer(32)
        #            代码,价格,数量,买入,代码,价格,数量,卖出,全撤, 撤买, 撤卖
        id_members = 1032, 1033, 1034, 1006, 1035, 1058, 1039, 1008, 30001, 30002, 30003, \
                     32790, 1038, 1047, 2053, 30022, 1019  # 刷新,余额、表格、最后一笔、撤相同
        self.path_grid = 1047, 200, 1047
        self.ipo_grid_path = 0xe900, -1, 0x417, 0xc8, 0x417
        self.tree_path = 0xe900, 0xe900, 0x81, 0xc8, 0x81
        self.two_way = reduce(op.GetDlgItem, (59648, 59649), main)
        self.members = {i: op.GetDlgItem(self.two_way, i) for i in id_members}
        self.grid = reduce(op.GetDlgItem, self.path_grid, self.two_way)

        self.ipo_btn_path = 0xe900, 0xe901, 0x3ee
        self.ipo_btn_handle = reduce(op.GetDlgItem, self.ipo_btn_path, main)
        self.screen_width = op.GetSystemMetrics(0)
        self.screen_height = op.GetSystemMetrics(1)

        self.tree_handle = reduce(op.GetDlgItem, self.tree_path, main)
        self.ipo_grid_handle = reduce(op.GetDlgItem, self.ipo_grid_path, main)
        print_time(ctypes.WinError())
        print_time("tree_handle:%d ipo_grid_handle:%d" %
                   (self.tree_handle, self.ipo_grid_handle))
        print_time("members:")
        print_time(self.members)
        # 获取登录账号
        self.account = reduce(op.GetDlgItem, (59392, 0, 1711), main)
        op.SendMessageW(self.account, WM_GETTEXT, 32, self.buff)
        self.account = self.buff.value

        print_time("account:")
        print_time(self.account)

        # 撤单工具条
        self.id_toolbar = {'全选': 1098, \
                           '撤单': 1099, \
                           '全撤': 30001, \
                           '撤买': 30002, \
                           '撤卖': 30003, \
                           '填单': 3348, \
                           '查单': 3349}  # '撤尾单': 2053, '撤相同': 30022}    # 华泰独有

        op.SendMessageW(main, WM_COMMAND, 163, 0)  # 切换到撤单操作台
        wait_a_second()
        self.cancel_panel = reduce(op.GetDlgItem, (59648, 59649), main)
        self.cancel_toolbar = {
            k: op.GetDlgItem(self.cancel_panel, v)
            for k, v in self.id_toolbar.items()
        }
        keystroke(main, F6)  # 切换到双向委托
        self._app = Application().connect(handle=self.main)
Exemplo n.º 25
0
def WindowInFront(processpath):
    #Bring window in front
    app = Application().connect(path=processpath)
    w = app.top_window()

    #bring window into foreground
    if w.HasStyle(win32defines.WS_MINIMIZE):  # if minimized
        ShowWindow(w.wrapper_object(), 9)  # restore window state
    else:
        SetForegroundWindow(w.wrapper_object())  #bring to front
Exemplo n.º 26
0
 def startSublime(self):
     app = Application().Start(
         cmd_line=u'"C:\\Program Files\\Sublime Text 3\\sublime_text.exe"')
     app = Application().Connect(
         title=u'untitled (demo) - Sublime Text (UNREGISTERED)',
         class_name='PX_WINDOW_CLASS')
     self.pxwindowclass = app.PX_WINDOW_CLASS
     self.pxwindowclass.Wait('ready')
     menu_item2 = self.pxwindowclass.MenuItem(u'&File->&New File\tCtrl+N')
     menu_item2.ClickInput()
Exemplo n.º 27
0
Arquivo: check.py Projeto: nkpc14/ARYA
 def paste(self, param):
     if (param == "sublime"):
         self.app = Application().connect(title_re=".*Notepad",
                                          class_name="Notepad")
         self.app.notepad.menu_select("File->SaveAs")
     elif param == "notepad":
         self.app = Application().connect(title_re=".*Notepad",
                                          class_name="Notepad")
         menu_item2 = self.app.notepad.menu_select("Edit->Paste\tCtrl+V")
         menu_item2.ClickInput()
Exemplo n.º 28
0
 def auto_input_writer(self):
     try:
         app = Application().connect(path='nvcontainer.exe')
         dialog = app.top_window()
         if dialog.is_visible():
             dialog.Edit.type_keys('1111')
             dialog.Button.click()
             self.state = 'reserved'
     except Exception:
         print(Exception)
Exemplo n.º 29
0
def kill_window():
    try:
        for handle in findwindows.find_windows(title_re="(Dropbox Preferences|Preferencias de Dropbox)"):
            app = Application.connect(Application(), handle=handle)
            for window in app.windows_(title_re="(Dropbox Preferences|Preferencias de Dropbox)"):
                logger.warning('Configuration window for Dropbox detected')
                window.Close()
                logger.warning('Configuration window for Dropbox closed')
    except findwindows.WindowNotFoundError:
        pass
Exemplo n.º 30
0
    def __init__(self, barrier=None):
        super().__init__()

        self.app = Application().start(GONIOTOOL_EXE)
        input('Enter password and press <ENTER> to continue...'
              )  # delay for password, TODO: automate
        self.startup()

        if barrier:
            barrier.wait()
Exemplo n.º 31
0
 def sync(self):
     try:
         if self._fime_app is None:
             self._fime_app = Application(backend='uia').connect(title_re='EVA*')
             self._fime_app_mainwin = self._fime_app.window(title_re='EVAL*')
             self._fime_app_mainwin.print_control_identifiers(depth=3, filename='_fime_app_mainwin.txt')
     except Exception as e:
         self.exception(e)
         return False
     return True
Exemplo n.º 32
0
class FimeIntegriHelper(XObject):
    def __init__(self):
        super(FimeIntegriHelper, self).__init__()
        self._fime_app = None
        self._fime_app_mainwin = None

    def sync(self):
        try:
            if self._fime_app is None:
                self._fime_app = Application(backend='uia').connect(title_re='EVA*')
                self._fime_app_mainwin = self._fime_app.window(title_re='EVAL*')
                self._fime_app_mainwin.print_control_identifiers(depth=3, filename='_fime_app_mainwin.txt')
        except Exception as e:
            self.exception(e)
            return False
        return True

    def _click(self, ui_object):
        local = ui_object.element_info.rectangle
        ui_object.set_focus()
        pywinauto.mouse.click(coords=(local.left + 5, local.top + 5))

    def handle_pop_message(self):
        try:

            dlg_pop_message = self._fime_app_mainwin.window(title='POP Message', class_name='ThunderRT6UserControlDC')
            dlg_pop_message.wait('ready', timeout=20)
            self.info('dlg_pop_message 1')
            PassButton = self._fime_app_mainwin.window(title='Pass', control_type="Button", class_name='ThunderRT6CommandButton')
            self._click(PassButton.wrapper_object())
        except Exception as e:
            self.exception(e)
            self.info('Can not find window(POP Message)')
        else:
            try:
                PassButton = dlg_pop_message.window(title='Pass', control_type="Button")
                self._click(PassButton.wrapper_object())
            except Exception as e:
                self.exception(e)
                self.info('Can not click Pass Button')
# encoding: utf-8
from os import path
from pywinauto import Desktop, Application

chrome_dir = r'"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"'
tab_log_in = u'Meet Google Drive - One place for all your files (Incognito)'
tab_drive = 'My Drive - Google Drive (Incognito)'

# # start google chrome
chrome = Application(backend='uia')
chrome.start(chrome_dir + ' --force-renderer-accessibility --incognito --start-maximized '
             'https://accounts.google.com/ServiceLogin?service=wise&passive=1209600&continue=https:'
             '//drive.google.com/?urp%3Dhttps://www.google.ru/_/chrome/newtab?espv%253D2%2526ie%253DUT%23&followup='
             'https://drive.google.com/?urp%3Dhttps://www.google.ru/_/chrome/newtab?espv%253D2%2526ie%253DUT'
             '&ltmpl=drive&emr=1#identifier')

# wait while a page is loading
chrome[tab_log_in].child_window(title_re='Reload.*', control_type='Button').wait('visible', timeout=10)
ch_window = chrome[tab_drive].child_window(title="Google Chrome", control_type="Custom")

# log in
chrome.window().type_keys('TestPywinauto{ENTER}')  # username
chrome[tab_log_in].child_window(title="Google Chrome", control_type="Custom").\
    child_window(title="Back", control_type="Image").wait(wait_for='visible', timeout=10)

chrome.window().type_keys('testpywinauto123{ENTER}')  # password
ch_window.child_window(title="Getting started PDF", control_type="ListItem").wait(wait_for='visible')

# start explorer in the current path
dir_path = path.join(path.dirname(path.realpath(__file__)), 'UIA_Drive')
explorer = Application().start('explorer.exe ' + dir_path)
Exemplo n.º 34
0
from pywinauto import Application
import  time
app = Application()
app.start('notepad.exe')
#app.UntitledNotepad.MenuItem('Edit -> Paste').Select()
app.Notepad.MenuItem('Edit -> Paste').Select()
app.notepad.TypeKeys('Hello World')

time.sleep(1)
app.notepad.TypeKeys('^+{ENTER}')

time.sleep(1)
app.Notepad.MenuItem('File -> Exit').Select()
#OK = 'Cancel'
#about_dlg[OK].Click()
app['Notepad']['Cancel'].Click()


Exemplo n.º 35
0
from __future__ import print_function
import logging
from pywinauto import actionlogger
from pywinauto import Application

import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--log", help = "enable logging", type=str, required = False)
args = parser.parse_args()

actionlogger.enable()
logger = logging.getLogger('pywinauto')
if args.log:
    logger.handlers[0] = logging.FileHandler(args.log)

app = Application(backend='uia').start(r'mspaint.exe')
dlg = app.window(title_re='.* - Paint')

# File->Open menu selection
dlg.File_tab.click()
dlg.child_window(title='Open', control_type='MenuItem', found_index=0).invoke()

# handle Open dialog
file_name_edit = dlg.Open.child_window(title="File name:", control_type="Edit")
file_name_edit.set_text('walter_cat.jpg')
# There are 2 Open buttons:
# dlg.Open.Open.click() will call drop down list of the file name combo box.
# The child_window statement is just copied from print_control_identifiers().
dlg.Open.child_window(title="Open", auto_id="1", control_type="Button").click()

dlg.ResizeButton.click()
Exemplo n.º 36
0
Example script for listing installed updates on Windows 10

Requirements:
  - Windows 10 (may work on Win7+)
  - pywinauto 0.6.1+

This example opens "Control Panel", navigates to "Installed Updates" page
and lists all updates (for all apps) as well as OS Windows updates only.
"""

from __future__ import print_function
from pywinauto import Application

# Open "Control Panel"
Application().start('control.exe')
app = Application(backend='uia').connect(path='explorer.exe', title='Control Panel')

# Go to "Programs"
app.window(title='Control Panel').ProgramsHyperlink.invoke()
app.wait_cpu_usage_lower(threshold=0.5, timeout=30, usage_interval=1.0)

# Go to "Installed Updates"
app.window(title='Programs').child_window(title='View installed updates', control_type='Hyperlink').invoke()
app.wait_cpu_usage_lower(threshold=0.5, timeout=30, usage_interval=1.0)

list_box = app.InstalledUpdates.FolderViewListBox

# list all updates
items = list_box.descendants(control_type='ListItem')
all_updates = [item.window_text() for item in items]
print('\nAll updates ({}):\n'.format(len(all_updates)))