首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >点击internet弹出

点击internet弹出
EN

Stack Overflow用户
提问于 2021-06-09 21:30:36
回答 1查看 394关注 0票数 0

我需要使用PowerShell点击这个弹出窗口关闭,这是我打开互联网浏览器时出现的。按回车键也会关闭弹出。

我试过什么

代码语言:javascript
复制
        [void] [System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms")
        [void] [System.Reflection.Assembly]::LoadWithPartialName("'Microsoft.VisualBasic")

        $ie = new-object -com internetexplorer.application
        $ie.visible = $true
        $ie.navigate('http://website/')
        while ($ie.busy) { Start-Sleep 3 }  
        [Microsoft.VisualBasic.Interaction]::AppActivate("internet explorer")    
     
        [System.Windows.Forms.SendKeys]::Sendwait("{ENTER}");
       
        Start-Sleep 3
        $link = $ie.Document.getElementsByTagName('Button') | where-object { $_.innerText -eq 'Simple Setup' }
        $link.click()
        Start-Sleep 2
        $ie.quit()
EN

回答 1

Stack Overflow用户

发布于 2021-06-10 07:17:54

继续我的评论。

其他人遇到了这个对话框和其他人,正如所述,他们使用Selenium、AutoIT等来处理这个问题;而其他人则尝试了不同的方法。

For Example:

代码语言:javascript
复制
# using the process handle of that dialog
$ws = New-Object -ComObject WScript.Shell
$ld = (gps iex* | where {$_.MainWindowTitle }).id

if($ld.Count -gt 1)
{
  $ws.AppActivate($ld[1])
  $ws.sendkeys("{ENTER}")
}

# Using the WASP module 
# (note - though the code for this module is still available, the DLL is not. So, you have to compile that yourself.)
Import-Module WASP
while ($true) {
  [System.Threading.Thread]::Sleep(200) 
  $confirmation = Select-Window iexplore 
  if ($confirmation -ne $null) 
  {
    Select-ChildWindow  -Window $confirmation | 
    Select-Control -title "OK" -recurse | 
    Send-Click
  }
}

顺便说一句。

“按回车键也关闭弹出”

..。这是因为模态对话框总是集中注意力,直到它们被排除。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67911949

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档