墙角那只猫 发表于 2011-11-7 14:41:19

如何判断处理这个弹出框

下载文件已经存在时,弹出如下图小窗口。不存在时,不弹出。

请问:如何判断处理这种情况?

现在的代码片段如下:
Dim $path = "c:/downloadFile"
WinWaitActive("File Download")

Send("!s")

WinWaitActive("Save As")

ControlSetText("Save As","File &name:","Edit1",$path)

Send("!s")

/*
if(弹出了那个文件已经存在的小窗口){
点击小窗口中的yes
}
*/

求助:如何写这个if语句

图片:

fuldho 发表于 2011-11-7 14:45:18

If FileExists("c:/downloadFile") = 1 Then

yikang8888 发表于 2011-11-7 15:20:49

FileExists
--------------------------------------------------------------------------------

检查指定文件或目录是否存在.


FileExists ( "路径" )




参数

路径 要检查的文件或目录的路径.



返回值

成功: 返回值为1.
失败: 返回值为0,说明指定的路径/文件并不存在.



注意/说明

如果指定路径参数为未插入磁盘的软驱则 FileExists 的返回值为0.




相关

FileGetAttrib, DriveStatus


示例/演示


If FileExists("C:\autoexec.bat") Then
    MsgBox(4096, "C:\autoexec.bat 文件", "C:\autoexec.bat 文件存在")
Else
    MsgBox(4096,"C:\autoexec.bat 文件", "C:\autoexec.bat 文件不存在")
EndIf

If FileExists("C:\") Then
    MsgBox(4096, "C:\ 目录 ", "C:\ 目录存在")
Else
    MsgBox(4096,"C:\ 目录" , "C:\ 目录不存在")
EndIf

If FileExists("D:") Then
    MsgBox(4096, "驱动器 D:", "驱动器D:存在")
Else
    MsgBox(4096,"驱动器 D:", "驱动器D:不存在")
EndIf

墙角那只猫 发表于 2011-11-7 16:30:18

非常感谢2楼3楼的帮助,完成了99% 还有一点小问题:

Dim $path = "c:\downloadFile"
WinWaitActive("File Download")
Sleep(2000)
Send("!s")
Sleep(2000)
WinWaitActive("Save As")
Sleep(2000)
ControlSetText("Save As","File &name:","Edit1",$path)
Sleep(2000)
Send("!s")
If FileExists("c:\downloadFile.xls") Then
Send("!y")
Else
Send("!s")
-----------------------------------------------------------------------------------
If FileExists("c:\downloadFile.xls")如果这个文件的后缀名不确定,该怎么办?
页: [1]
查看完整版本: 如何判断处理这个弹出框