打开PDF时,Adobe Reader会执行结构检查,如果出现缺陷,会弹出警告。我需要知道弹出窗口是否显示 - 最好使用Powershell - 但不需要捕获其内容。启动Adobe并获取PID(是的,它在安全模式下是两个)很容易。但Adobe的行为有所不同,例如来自Office。弹出窗口我根本找不到任何孩子。
Get-Process AcroRd32 -ErrorAction SilentlyContinue |
Where-Object {$_.Id -eq $Process.ID } |
Where-Object {$_.Responding -eq $true}
每个AcroRd32进程的属性“Responding”为True。总是。弹出或没有弹出窗口。
Get-WmiObject -Class Win32_Process -Filter ("ParentProcessID=" + $Process.ID)
没有孩子。
如何处理此弹出窗口?最好使用Powershell(当前:4.0),也许可以调用.Net来救援?
提前感谢您的帮助。
祝你好运 人
根据以下反馈,代码更新如下并且到目前为止有效:
# Get installed Adobe version from registry
if ((Get-WmiObject Win32_OperatingSystem).OSArchitecture -match "64-bit")
{
$Key = "HKLM:\Software\WOW6432Node"
}
else
{
$Key = "HKLM:\Software"
}
$Key = $Key + "\adobe\Acrobat Reader"
if (Test-Path $Key)
{
$LatestVersion = ((get-childitem $Key) | sort-object -property Name | select-object -last 1).Name
$Path = get-ItemProperty -Path ("Registry::" + $LatestVersion + "\Installer") | Select-Object -ExpandProperty "Path"
# Start Adobe Reader
cd ($Path + "\Reader")
.\AcroRd32.exe $File
# Trying to get the popup
foreach ($Process in (Get-Process AcroRd32))
{
# Takes really a lot of time for the pop-up up to open, 5s is on the safer side
sleep -s 5
if (([User32]::FindWindowByCaption($WindowCaption)).ToInt32() -ne 0)
{
write-host "Pop-up open for file $File"
}
}