如何在PowerShell中从Chrome获取URL

时间:2019-07-11 02:23:53

标签: powershell google-chrome

我尝试过:

Add-Type -AssemblyName UIAutomationClient

$chromes = Get-Process -Name chrome

foreach ($chrome in $chromes) {
    if ($chrome.MainWindowHandle -eq [System.IntPtr]::Zero) {
        continue
    } else {
        $chrome.MainWindowHandle
    }

    $element = [System.Windows.Automation.AutomationElement]::FromHandle($chrome.MainWindowHandle)
    $condition = [System.Windows.Automation.PropertyCondition]::New([System.Windows.Automation.AutomationElement]::ClassNameProperty, "Chrome_OmniboxView")

    $edit = $element.FindFirst([System.Windows.Automation.TreeScope]::Subtree, $condition)

    $edit
}

$edit$null

日本的Chrome版本75。

0 个答案:

没有答案