脚本运行时不出现气球提示

脚本运行时不出现气球提示
[reflection.assembly]::loadwithpartialname("System.Windows.Forms")
[reflection.assembly]::loadwithpartialname("System.Drawing")
# notify.icon type: Information, Warning or Error.
$notify = new-object system.windows.forms.notifyicon
$notify.icon = [System.Drawing.SystemIcons]::Information
$notify.visible = $true
$notify.showballoontip(10,"", "The CPU is hot.",[system.windows.forms.tooltipicon]::None)

当我运行上述代码时,通知区域中只出现一个图标,但没有出现气球提示。脚本有什么问题?我使用的是 Windows 10 版本 1803。

答案1

我从未见过ShowBalloonTip这样使用。这应该有效:

[reflection.assembly]::loadwithpartialname("System.Windows.Forms")
[reflection.assembly]::loadwithpartialname("System.Drawing")
# notify.icon type: Information, Warning or Error.
$notify = new-object system.windows.forms.notifyicon
$notify.icon = [System.Drawing.SystemIcons]::Information
$notify.visible = $true
$notify.BalloonTipIcon = "Warning" 
$notify.BalloonTipText = "The CPU is hot." 
$notify.BalloonTipTitle = "Title"
$notify.ShowBalloonTip(1000)

相关内容