Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
11
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

updated at

[powershell]トースト通知を行う。

powershellでトースト通知を行う。

15分おきにトースト通知を行って
無為に時間が経過するのを防ぎたかった。

環境

PSVersion 5.1.16299.248
PSEdition Desktop

コード

[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
[Windows.UI.Notifications.ToastNotification, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null

$app = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'

$template = @"
<toast duration="long">
    <visual>
        <binding template="ToastText02">
            <text id="1">test Title</text>
            <text id="2">test content</text>
        </binding>
    </visual>
  <actions>
  <input id="snoozeTime" type="selection" defaultInput="15">
    #5つまで
    <selection id="3" content="3 minutes" />
    <selection id="5" content="5 minutes" />
    <selection id="10" content="10 minutes" />
    <selection id="15" content="15 minutes" />
    <selection id="30" content="30 minutes" />
  </input>
  <action activationType="system" arguments="snooze" hint-inputId="snoozeTime" content=""/>
  <action activationType="system" arguments="dismiss" content=""/>
  </actions>
</toast>
"@

$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($template)
$toast = New-Object Windows.UI.Notifications.ToastNotification $xml
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($app).Show($toast )

参考URL

https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/toast-xml-schema
https://steemit.com/powershell/@esoso/fun-with-toast-notifications-in-powershell
https://qiita.com/akiqsinco/items/0c0d5ae4abc756a594b3

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
11
Help us understand the problem. What are the problem?