【发布时间】:2019-06-19 03:54:13
【问题描述】:
我正在研究程序自动化(名为 SEO indexer 的程序)。我使用 python 的库名称 pywinauto 编写了自动化。 当我通过与服务器的 RDP 连接运行自动化时,一切都很好。但是当我试图离开程序并断开与 RDP 的连接时,“另存为”窗口没有启动并且程序崩溃了......
有人知道我该如何解决吗?
负责保存文件的代码是 -
def run(self, process_id, link):
controls = self._app[u'TForm1']
text_box = controls.Edit
text_box.set_text(link)
button = controls.ToolBar1
windows = Desktop(backend="uia")
button.click()
self.wait_for_finish(process_id)
result_box = controls.TVirtualStringTree
result_box.RightClick()
sleep(1)
windows_list = windows.windows()
context_menu = windows.window(best_match = "Context")
save_all_button = context_menu.children()[2]
save_all_button.select()
save_as = windows.window(best_match = "save_as")
properties_section = save_as.children()[0]
file_name = "C:\\Windows\\Temp\\indexer_" + str(randint(0, 10000))
file_name_label = properties_section.children()[4].children()[0]
file_name_label.set_text(file_name)
save_button = save_as.children()[2]
save_button.click()
sleep(2)
yes_no_dialog = windows.window(best_match = "GSA SEO Indexer v2.34")
yes_no_dialog.children()[0].click()
return file_name
它在 -
save_as = windows.window(best_match = "save_as")
即使没有屏幕,是否有办法强制它打开另存为对话框?
更新:
我只是注意到问题不在于未创建 Save as 面板,问题在于当我没有屏幕并尝试从上下文菜单(已创建)中进行选择时 - 仅选择了文本,没有点击它
【问题讨论】:
标签: python automation pywinauto