gpt4 book ai didi

.net - 在 Windows 任务栏 (Powershell) 中显示进度

转载 作者:行者123 更新时间:2023-12-03 01:29:15 27 4
gpt4 key购买 nike

我想弄清楚如何在任务栏上显示进度。通过 PowerShell。

enter image description here

据我了解,我应该使用这样的东西:

$Progress = [System.Windows.Shell.TaskbarItemInfo]::New()

$Progress.ProgressState = 'Normal'
$Progress.ProgressValue = 0.3

但这不起作用。我究竟做错了什么?如何在任务栏上显示进度?谢谢

最佳答案

您可以在 WPF 中执行此操作,因为使用 XAML 创建一个新的窗口对象,我认为您这样做是不可能的。

# Add required assemblies
Add-Type -AssemblyName PresentationFramework, System.Drawing, System.Windows.Forms, WindowsFormsIntegration

# Setup the XAML
[xml]$script:xaml = '<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="MyWindow" Height="240" Width="320" Background="Gray">
<Window.TaskbarItemInfo>
<TaskbarItemInfo/>
</Window.TaskbarItemInfo>
<Grid>
<Image Name="image" Height="64" Width="64"/>
</Grid>
</Window>'

# Create the form and set variables
$script:window = [Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader $xaml))
$xaml.SelectNodes("//*[@Name]") | ForEach-Object { Set-Variable -Name ($_.Name) -Value $window.FindName($_.Name) -Scope Script }



# This is the toolbar icon and description
$window.TaskbarItemInfo.Description = $window.Title
$window.TaskbarItemInfo.ProgressValue = 0.8
$window.TaskbarItemInfo.ProgressState = "Normal"


$window.ShowDialog()

关于.net - 在 Windows 任务栏 (Powershell) 中显示进度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59752494/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com