我有PowerShell脚本,它将打开网页(Selenium)并将焦点设置在"消息"框中.现在,我想模拟Ctrl+ V从剪贴板粘贴我的数据.有没有办法在纯PowerShell中做到这一点?可以在powershell函数中使用的C#代码也很棒.
我尝试了以下方法:
$edge = New-Object -com microsoft-edge.application
$edge.visible = $true
$edge.FullScreen = $true
Run Code Online (Sandbox Code Playgroud)
但我得到错误:
New-Object : Retrieving the COM class factory for component with CLSID
{00000000-0000-0000-0000-000000000000} failed
due to the following error: 80040154 Class not registered (Exception from
HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At line:1 char:9
+ $edge = New-Object -com microsoft-edge.application
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [New-Object], COMException
+ FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么吗?
编辑 17/07/2019 - 我已更改为以下内容:
$edge = Start-Process -FilePath ($Env:WinDir + "\explorer.exe")
-ArgumentList
"shell:Appsfolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge"
$edge.visible = $true
$edge.FullScreen …Run Code Online (Sandbox Code Playgroud)