Automation 如何编程机器人在保存图像或文档之前请求确认?

Automation 如何编程机器人在保存图像或文档之前请求确认?,automation,rpa,g1ant,Automation,Rpa,G1ant,我已经在我的桌面上有一个名为ABC.png的图像,我正在使用robot从网上下载另一个图像并保存在我的桌面上,但在保存图像之前,我希望robot问“你想替换现有图像吗?”或者干脆问我是否要下载图像。我怎么能做到 ♥image = ♥environment⟦USERPROFILE⟧\Desktop\ABC.png file.download https://static.makeuseof.com/wp-content/uploads/2016/06/PolkaDots2.jpg filename

我已经在我的桌面上有一个名为ABC.png的图像,我正在使用robot从网上下载另一个图像并保存在我的桌面上,但在保存图像之前,我希望robot问“你想替换现有图像吗?”或者干脆问我是否要下载图像。我怎么能做到

♥image = ♥environment⟦USERPROFILE⟧\Desktop\ABC.png
file.download https://static.makeuseof.com/wp-content/uploads/2016/06/PolkaDots2.jpg filename ♥image
image.findrectangles ♥image
dialog ♥result

您可以使用
file.exists
命令。这样,您就可以检查是否存在与
♥图像
存在于现有目录中

以下是一种方法:

♥image = ♥environment⟦USERPROFILE⟧\Desktop\ABC.png
file.exists filename ♥image errorcall downloadFile
dialog.ask message ‴File already exists! Do you want to overwrite the file?‴ result ♥response
if ♥response=="yes"
    call downloadFile 
else if ♥response=="no"
    dialog ‴Operation cancelled, File not downloaded!‴
end

procedure downloadFile
    file.download https://static.makeuseof.com/wp-content/uploads/2016/06/PolkaDots2.jpg filename ♥image
    stop silentmode true
end

基本上,它使用
file.exists
命令检查文件是否存在,如果文件不存在,该命令将抛出错误。在
errorcall
参数中,我们调用
downloadFile
过程,因为我们知道文件不存在,所以我们继续下载它
downloadFile
过程使用
stop
命令结束机器人的执行,因为我们不希望机器人执行任何进一步的代码。(静默模式设置为true,因为我们不想显示“进程在x行中断”对话框)。如果文件确实存在,那么我们继续下一行(因为
file.exists
,没有调用
downloadFile
过程,所以我们打开一个对话框,询问用户是否要下载和覆盖文件。如果输入为“是”,我们通过调用
downloadFile
或在对话框中显示消息“操作已取消,文件未下载!”来下载并覆盖文件

您可以使用
文件.exists
命令。这样,您就可以检查是否存在与
♥图像
存在于现有目录中

以下是一种方法:

♥image = ♥environment⟦USERPROFILE⟧\Desktop\ABC.png
file.exists filename ♥image errorcall downloadFile
dialog.ask message ‴File already exists! Do you want to overwrite the file?‴ result ♥response
if ♥response=="yes"
    call downloadFile 
else if ♥response=="no"
    dialog ‴Operation cancelled, File not downloaded!‴
end

procedure downloadFile
    file.download https://static.makeuseof.com/wp-content/uploads/2016/06/PolkaDots2.jpg filename ♥image
    stop silentmode true
end

基本上,它使用
file.exists
命令检查文件是否存在,如果文件不存在,该命令将抛出错误。在
errorcall
参数中,我们调用
downloadFile
过程,因为我们知道文件不存在,所以我们继续下载它
downloadFile
过程使用
stop
命令结束机器人的执行,因为我们不希望机器人执行任何进一步的代码。(静默模式设置为true,因为我们不想显示“进程在x行中断”对话框)。如果文件确实存在,那么我们继续下一行(因为
file.exists
,没有调用
downloadFile
过程,所以我们打开一个对话框,询问用户是否要下载和覆盖文件。如果输入为“是”,我们通过调用
downloadFile
或在对话框中显示消息“操作已取消,文件未下载!”来下载并覆盖文件

但对于这一点,我应该已经知道我要下载或保存的文件的名称。但是,如果我正在下载的是一个随机文件,并且系统中已经存在一些默认名称,该怎么办呢?即使该文件在网站上有一些随机名称,您仍然可以在
file.download
命令中为该文件设置一个特定名称。但是,我应该已经知道要下载或保存的文件的名称。但是,如果我正在下载的是一个随机文件,并且系统中已经存在一些默认名称,该怎么办?即使该文件在网站上有一些随机名称,您仍然可以在
file.download
命令中为该文件设置特定名称。