PyWinAuto:找不到进程

PyWinAuto: Process not found

我正在尝试在打开的浏览器中自动保存每个选项卡 (Google Chrome)。这段代码以前在命令提示符下运行时可以正常工作,但现在我正在制作一个 GUI 来使用这些功能,但我收到了这个错误。

这里是使用 Application.connect() 的函数。

# saves all current tabs to clipboard and closes browser
    def save_and_close(self):
        global URLS

        # list that contains new URLS for storage
        updated_data = []

        # account for any internet-related disconnections
        try:
            app = Application(backend='uia').connect(path = self.browser_location)
            find_windows(title = "Google Chrome")

            while True:
                try:
                    keyboard.send_keys("{F6}^c")
                    time.sleep(1)
                    updated_data.append(clipboard.GetData())
                    time.sleep(3)
                    keyboard.send_keys("^w")
                    time.sleep(3)

                except KeyboardInterrupt:

                    keyboard.send_keys("^") # undo the keyboard control key
                    break 

            # updates database with new URLS
            with open("bmanager.json", "w") as dw:
                json.dump(updated_data, dw)

            # reloads database for next possible usage
            URLS = json.loads(open("bmanager.json").read())

        except Exception as e:
            print(e)
            print ("[ERROR]: Client is not connected to the internet")  

这里是错误:

Process [browser location] not found!

请注意,[浏览器位置] 只是我浏览器 .exe 文件位置的占位符

我发现我必须在连接到它之前使用位置和 pywinauto 的注册函数注册 chrome。