사실 저는 UWP의 Toast messages API를 사용하여 이와 비슷한 것을 만드는 것에 매우 가깝습니다. 단추 및 텍스트 상자 (또한 Invoke-Command를 사용하여 원격 컴퓨터에서도)로 토스트 메시지를 만들 수 있지만 입력 또는 단추에서 결과를 다시 얻는 데는 실패한 경우가 있습니다 (UWP 설명서를 살펴보면 Powershell에서는 불가능).
샘플 코드 UWP의 토스트 메시지에 대한 자세한 내용은이 버전에서 로컬 또는 원격을 실행할 수 있습니다. 버튼에 XML 콘텐츠가 포함되어 있지는 않지만 마이크로 소프트가 쓴 API 문서를 따라 가면 구현하기 쉽다.) 더 많은 행운을 누릴 수있다. (면책 조항 : 이것은 나의 첫 번째 작업 개념이고, 코드는 아직 최적화되지 않았으며, "로컬"코드에 대한 많은 중복 코드가있다. 및 "원격"버전 등) :
Function Invoke-ToastMessage
{
[CmdletBinding()]
Param
(
[string]$Message,
[string]$Notifier = "Administrators",
[string]$ComputerName = $null
)
[scriptblock]$ToastScriptRemote = {
$Message = $args[0]
$Notifier = $args[1]
# XML Template
[xml]$XmlTemplate = @"
<toast scenario="reminder">
<visual>
<binding template="ToastGeneric">
<text>Admin Notification</text>
<text>$Message</text>
</binding>
</visual>
<actions>
</actions>
</toast>
"@
# fake load the assemblies
[void][Windows.UI.Notifications.ToastNotification,Windows.UI.Notifications,ContentType=WindowsRuntime]
[void][Windows.Data.Xml.Dom.XmlDocument,Windows.Data.Xml.Dom,ContentType=WindowsRuntime]
$FinalXML = [Windows.Data.Xml.Dom.XmlDocument]::new()
$FinalXML.LoadXml($XmlTemplate.OuterXml)
## create the toast
$Toast = [Windows.UI.Notifications.ToastNotification]::new($FinalXML)
## Show the TOAST message
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($Notifier).show($Toast)
}
[scriptblock]$ToastScriptLocal = {
# XML Template
[xml]$XmlTemplate = @"
<toast scenario="reminder">
<visual>
<binding template="ToastGeneric">
<text>Admin Notification</text>
<text>$Message</text>
</binding>
</visual>
<actions>
</actions>
</toast>
"@
# fake load the assemblies
[void][Windows.UI.Notifications.ToastNotification,Windows.UI.Notifications,ContentType=WindowsRuntime]
[void][Windows.Data.Xml.Dom.XmlDocument,Windows.Data.Xml.Dom,ContentType=WindowsRuntime]
$FinalXML = [Windows.Data.Xml.Dom.XmlDocument]::new()
$FinalXML.LoadXml($XmlTemplate.OuterXml)
## create the toast
$Toast = [Windows.UI.Notifications.ToastNotification]::new($FinalXML)
## Show the TOAST message
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($Notifier).show($Toast)
}
if (![string]::IsNullOrEmpty($ComputerName))
{
Invoke-Command -ComputerName $ComputerName -ScriptBlock $ToastScriptRemote -ArgumentList $Message,$Notifier
}
else {$ToastScriptLocal.Invoke()}
}
예약 된 작업을 만들어 대화 형 사용자로 실행하고 즉시 시작할 수 있습니다. 나는 당신이 뭔가를 터뜨릴 수 있는지, 결코 시도하지 않았는지 확실하지 않습니다. 그렇지 않으면 로그온 한 사용자의 컨텍스트에서 실행할 항목을 얻는 것이 약간의 고통입니다. –
@Chris Dent 흥미로운 옵션. 그걸 살펴볼 것입니다, 고마워요. – RockYoClock