如何点击“文件下载”窗口的“打开”、“保存”按钮?
Dim Phwnd As Long, Hwnd As LongDim hwnd_Open As Long, hwnd_Save As Long, hwnd_Cancel As Long
Phwnd = FindWindowEx(0&, 0&, vbNullString, "文件下载")
Hwnd = FindWindowEx(Phwnd, 0&, vbNullString, "您想打开或保存此文件吗?")
If Hwnd = 0 Then
Phwnd = FindWindowEx(0&, Phwnd, vbNullString, "文件下载")
End If
If Phwnd = 0 Then MsgBox "未找到“文件下载”窗口": Exit Sub
hwnd_Open = FindWindowEx(Phwnd, 0&, "Button", "打开(&O)")
hwnd_Save = FindWindowEx(Phwnd, 0&, "Button", "保存(&S)")
hwnd_Cancel = FindWindowEx(Phwnd, 0&, "Button", "取消")
'以上能正确取到句柄,如果发送WM_CLOSE消息能去除对应按钮
'以下三句执行均无效果,换成SendMessage也不行
' PostMessage hwnd_open, BM_CLICK, 0, 0
' PostMessage hwnd_save, BM_CLICK, 0, 0
PostMessage hwnd_Cancel, BM_CLICK, 0, 0
--------------------编程问答-------------------- 其实你的思路是正确的,建议你用spy++来查阅一下,看看相关信息,再用自己的代码来查找,看看是否一致? --------------------编程问答-------------------- 参考这个
补充:VB , API