1
如何註冊Windows吐司協議? 在樣品從https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/07/02/adaptive-and-interactive-toast-notifications-for-windows-10/:如何註冊Windows吐司協議?
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Restaurant suggestion...</text>
<text>We noticed that you are near Wasaki. Thomas left a 5 star rating after his last visit, do you want to try it?</text>
</binding>
</visual>
<actions>
<action activationType="foreground" content="Reviews" arguments="reviews" />
<action activationType="protocol" content="Show map" arguments="bingmaps:?q=sushi" />
</actions>
</toast>
他們展現出新的原 「bingmaps」。 如何添加新的協議?
其實我在註冊表中添加這些鍵:
HKEY_CLASSES_ROOT\myProto
(default) = (REG_SZ) "URL:myProto Protocol"
shell/
open/
command = (REG_SZ) "...myExe.exe %1"
HKCU\SOFTWARE\Classes\myProto
(default) = (REG_SZ) "URL:myProto Protocol"
shell/
open/
command = (REG_SZ) "...myExe.exe %1"
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\myProto\UserChoice
ProgId = (REG_SZ) myProto
精確cmd命令:
reg add 'HKEY_CLASSES_ROOT\myProto' /ve /t REG_SZ /d 'URL:myProto Protocol' /f
reg add 'HKEY_CLASSES_ROOT\myProto' /v 'URL Protocol' /f
reg add 'HKEY_CLASSES_ROOT\myProto\shell\open\command' /ve /d '...myExe.exe "%1"' /f
reg add 'HKCU\SOFTWARE\Classes\myProto' /ve /t REG_SZ /d 'URL:myProto Protocol' /f
reg add 'HKCU\SOFTWARE\Classes\myProto' /v 'URL Protocol' /f
reg add 'HKCU\SOFTWARE\Classes\myProto\shell\open\command' /ve /d '...myExe.exe "%1"' /f
reg add 'HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\myProto\UserChoice' /v 'ProgId' /t REG_SZ /d 'myProto' /f
它的工作原理無處不在,除了敬酒......爲什麼呢? 我的吐司:
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Restaurant suggestion...</text>
<text>We noticed that you are near Wasaki. Thomas left a 5 star rating after his last visit, do you want to try it?</text>
</binding>
</visual>
<actions>
<action activationType="foreground" content="Reviews" arguments="reviews" />
<action activationType="protocol" content="Show map" arguments="myProto:test" />
</actions>
</toast>
編輯2017年5月19日
我使用這些參數
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\my-cool-app]
@="URL:my-cool-app"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\my-cool-app\shell\open\command]
@="cmd /c \"echo A > C:\\Users\\Public\\a.log\""
[HKEY_CURRENT_USER\SOFTWARE\Classes\my-cool-app]
@="URL:my-cool-app"
"URL Protocol"=""
[HKEY_CURRENT_USER\SOFTWARE\Classes\my-cool-app\shell\open\command]
@="cmd /c \"echo A > C:\\Users\\Public\\a.log\""
而下面的PS腳本:
$toastXml = @"
<toast launch="my-cool-app:arguments_for_my_app" activationType="protocol">
<visual>
<binding template="ToastGeneric">
<text>My test app using protocol</text>
</binding>
</visual>
</toast>
"@
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime]
[Windows.UI.Notifications.ToastNotification, Windows.UI.Notifications, ContentType = WindowsRuntime]
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml(([xml]$toastXml).OuterXml)
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)
$toast.Tag = "PowerShell"
$toast.Group = "PowerShell"
$toast.ExpirationTime = [DateTimeOffset]::Now.AddMinutes(5)
$notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("PowerShell")
$notifier.Show($toast);
不工作:( 見我的編輯在PowerShell中一個基本的樣本 – ImmortalPC