小编dev*_*eeb的帖子

PowerShell Winform GUI 中的 WebView2

我无法找到任何有关此的信息,所以我不确定它完全可能。我目前正在尝试将 WebView2 控件集成到我的 PowerShell Winform GUI 中。我在调试脚本时可以看到 webView2 控件已创建,但没有加载任何内容。我安装了 WebView2 运行时。

这是我到目前为止所拥有的:

function Show-test-WebView2Control_psf {

#----------------------------------------------
#region Import the Assemblies
#----------------------------------------------
[void][reflection.assembly]::LoadFile('C:\Tests\Assemblies\Debug\Microsoft.Web.WebView2.WinForms.dll')
[void][reflection.assembly]::LoadFile('C:\Tests\Assemblies\Microsoft.Web.WebView2.Core.dll')
[void][reflection.assembly]::LoadFile('C:\Tests\Assemblies\Microsoft.Web.WebView2.Wpf.dll')
[void][reflection.assembly]::Load('System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
[void][reflection.assembly]::Load('System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
#endregion Import Assemblies

#----------------------------------------------
#region Generated Form Objects
#----------------------------------------------
[System.Windows.Forms.Application]::EnableVisualStyles()
$form1 = New-Object 'System.Windows.Forms.Form'
$buttonRefresh = New-Object 'System.Windows.Forms.Button'
$buttonGo = New-Object 'System.Windows.Forms.Button'
$textbox1 = New-Object 'System.Windows.Forms.TextBox'
[Microsoft.Web.WebView2.WinForms.WebView2] $webview = New-Object 'Microsoft.Web.WebView2.WinForms.WebView2'
$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
#endregion Generated Form Objects

#----------------------------------------------
# User Generated Script
#----------------------------------------------

$form1_Load={
    #TODO: Initialize …
Run Code Online (Sandbox Code Playgroud)

powershell scripting winforms webview2

0
推荐指数
1
解决办法
5600
查看次数

标签 统计

powershell ×1

scripting ×1

webview2 ×1

winforms ×1