python - PyWinAuto:找不到进程
问题描述
我正在尝试在我打开的浏览器(谷歌浏览器)中自动保存每个选项卡。这段代码以前在命令提示符下运行时可以工作,但现在我正在制作一个 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!
请注意,[browser location] 只是我的浏览器的 .exe 文件位置的占位符
解决方案
我发现在连接到它之前,我必须使用位置和 pywinauto 的注册功能注册 chrome。
推荐阅读
- python - 如果值重叠,则合并 pandas dfs 列,否则分配默认值
- flutter - 仅当用户向下滑动时如何显示小部件?
- blockchain - 通过 WSS 连接到在本地网络上运行的 Polkadot Full Node 失败
- reactjs - rxjs 可观察捕获错误上缺少“body”属性
- lua - “内存分配错误:块太大”做简单的整数除法
- ngx-admin - ngx-admin 卡片填充和边距
- terraform - 我们如何从 terraform gcp 资源 iam 绑定中的变量添加项目编号
- python - 通过阈值使用通用句子编码器的句子相似度
- ruby-on-rails - 即使禁用缓存,Rails 仍会缓存视图/控制器
- c# - C# 解析 JSON 对象