【问题标题】:PyWinAuto: Process not foundPyWinAuto:找不到进程
【发布时间】:2020-09-30 13:16:56
【问题描述】:

我正在尝试自动将每个标签页保存在我打开的浏览器 (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: accessing chrome gui
  • @VasilyRyabov 我实际上发现了问题,这恰好是我程序中全局变量的错误。不过感谢您的努力!
  • 太棒了。请回答您自己的问题并接受它(答案左侧的灰色复选框应该适合您)。在 StackOverflow 上,向其他人展示问题已经解决是正常的方式(已解决的问题在标签提要中为绿色)。
  • @VasilyRyabov,让我告诉你,我很欣赏你的反应能力。现在已经这么多年了。请告诉我,你什么时候会承认你的工具现在是经典,值得用“版本 1 派对”来庆祝? :D
  • 下一个主要版本将是 0.7.0,支持 Linux 和 macOS。然后我们计划在所有操作系统上安装脚本记录器。也许会是 0.8.0 和 0.9.0。

标签: python google-chrome pywinauto python-webbrowser


【解决方案1】:

我发现我必须在连接之前使用位置和 pywinauto 的注册功能注册 chrome。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多