vault backup: 2026-11-09 09:18:58
This commit is contained in:
1 parent
856d0203da
commit
75072389db
42 files changed
+5994
-37
No files matched your search
@@ -0,0 +1,59 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$Title,
|
||||
[Parameter(Mandatory = $true)][string]$Body,
|
||||
[int]$Sound = 1
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$shown = $false
|
||||
|
||||
try {
|
||||
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
|
||||
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
|
||||
|
||||
$t = [System.Security.SecurityElement]::Escape($Title)
|
||||
$b = [System.Security.SecurityElement]::Escape($Body)
|
||||
$xmlText = @"
|
||||
<toast>
|
||||
<visual>
|
||||
<binding template="ToastGeneric">
|
||||
<text>$t</text>
|
||||
<text>$b</text>
|
||||
<text placement="attribution">Goofish Watcher</text>
|
||||
</binding>
|
||||
</visual>
|
||||
<audio silent="true"/>
|
||||
</toast>
|
||||
"@
|
||||
|
||||
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
|
||||
$xml.LoadXml($xmlText)
|
||||
$toast = New-Object Windows.UI.Notifications.ToastNotification $xml
|
||||
|
||||
$appIds = @(
|
||||
'{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe',
|
||||
'Microsoft.PowerShell',
|
||||
'GoofishWatcher'
|
||||
)
|
||||
foreach ($id in $appIds) {
|
||||
try {
|
||||
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($id).Show($toast)
|
||||
$shown = $true
|
||||
break
|
||||
} catch { }
|
||||
}
|
||||
} catch { }
|
||||
|
||||
if ($Sound -gt 0) {
|
||||
for ($i = 0; $i -lt $Sound; $i++) {
|
||||
try { [System.Media.SystemSounds]::Exclamation.Play() } catch { }
|
||||
if ($i -lt $Sound - 1) { Start-Sleep -Milliseconds 500 }
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $shown) {
|
||||
try {
|
||||
$sh = New-Object -ComObject WScript.Shell
|
||||
$null = $sh.Popup("$Title`n$Body", 8, "Goofish Watcher", 64)
|
||||
} catch { }
|
||||
}
|
||||
Reference in new issue
Block a user