首页 > 解决方案 > 如何使用 AutoIT 处理 IE 下载通知栏

问题描述

我想使用 Autoit 从下载通知栏中选择另存为选项,但无法专注于通知栏。如果我手动选择另存为按钮,则 Autoit 脚本的其余部分将起作用。

代码:

WinWait("[Actimize] Item Details - Internet Explorer")

;Option 1: focus on notification bar 
ControlFocus("[Actimize] Item Details - Internet Explorer","","DirectUIHWND1")
; or 
;Option 2: Send alt+n key to focus on navigation bar
Send("!n")

;Send DOWN key to navigate to Save as option
Send("{DOWN}")

;Send A to open the 'Save as' dialog box
Send("{a}")

;Wait for dialog window to open
WinWait("Save As")
$hWnd = WinGetHandle("Save As")

Sleep(2000)

;Set focus on 'Save as' dialog box
ControlFocus($hWnd, "", "[CLASS:Edit; INSTANCE:1]")
;Set text to TEST_FILE.html
ControlSetText($hWnd, "", "[CLASS:Edit; INSTANCE:1]", "Test_File", 1)


;Sleep for 4s
Sleep(4000)

ControlFocus($hWnd, "", "[CLASS:ToolbarWindow32; INSTANCE:3]")
; Right-click inside control to invoke "Edit Address"
ControlClick($hWnd, "", "[CLASS:ToolbarWindow32; INSTANCE:3]", "right")
; Choose the "Edit Address" option
ControlSend($hWnd, "", "[CLASS:ToolbarWindow32; INSTANCE:3]", "e")
Sleep(250)

Send("{DEL}")
Sleep(250)

Send("autoIt\au3_files\IE" & "{ENTER}")
Sleep(250)

ControlClick($hWnd, "", "[CLASS:Button; TEXT:&Save;]")

WinClose($hWnd)

标签: internet-explorerautoit

解决方案


推荐阅读