如何为 Windows toast 注册协议?

2024-05-20

如何注册 Windows toast 协议? 样本中来自https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/07/02/adaptive-and-interactive-toast-notifications-for-windows-10/ https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/07/02/adaptive-and-interactive-toast-notifications-for-windows-10/:

<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-05-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);

尝试使用(default) = (REG_SZ) "URL:myProto"代替(default) = (REG_SZ) "URL:myProto Protocol"

您可能想查看我的文章如何做到这一点:https://www.codeproject.com/Articles/1187127/Windows-toast-notifications-without-a-COM-server?msg=5395948#xx5395948xx https://www.codeproject.com/Articles/1187127/Windows-toast-notifications-without-a-COM-server?msg=5395948#xx5395948xx

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何为 Windows toast 注册协议? 的相关文章

  • 在 Windows 2008 上将 myprogram.exe 作为服务运行时出现问题

    MyProgram exe 是用来侦听来自管道的请求并使用命令提示符使其工作完美 但我尝试使用 Windows 服务来工作但没有成功我在 Windows Server 2008 Enterprise 上尝试了以下步骤 gt sc creat
  • 关于WinRT的演讲

    WinRT 中是否提供语音 api 如 Windows Phone 8 我可以使用第三方语音 API 来代替吗 我想在我的 Windows 8 WinRT 应用程序中实现 TTS 有人有建议吗 WinRT 现已支持语音 http msdn
  • Python 无法在 git bash 命令行中工作

    Python 不会在 git bash Windows 中运行 当我在命令行中输入 python 时 它会将我带到一个空行 而不会像在 Powershell 中一样显示它已输入 python 2 7 10 它没有给我错误消息 但 pytho
  • 批处理文件 FOR /f 标记

    任何人都可以逐行准确解释以下代码是如何工作的 我真的迷路了 我一直在尝试学习如何使用 FOR 命令 但我不明白这一点 echo off for f tokens delims f in myfile do set line f call p
  • Windows7上python3.5无法安装BeautifulSoup4

    我已经从下载了 beautifulsoup4 4 5 3 tar gzhttps www crummy com software BeautifulSoup bs4 download 4 5 https www crummy com sof
  • 如何从任何进程关闭 Windows 上的套接字(ipv4 和 ipv6)连接?

    如何在 Windows 上关闭 tcp v4 和 tcp v6 连接 我不想终止具有开放连接的整个进程 因为这显然会将其他人踢出该进程 我需要从一个单独的进程执行此操作 因此无法访问套接字句柄等 我正在使用 Windows API 来获取
  • 嵌入清单文件以要求具有 mingw32 的管理员执行级别

    我正在 ubuntu 下使用 i586 mingw32msvc 交叉编译应用程序 我很难理解如何嵌入清单文件以要求 mingw32 具有管理员执行级别 对于我的例子 我使用了这个hello c int main return 0 这个资源文
  • 用于验证 IIS 设置的 Powershell 脚本

    是否可以使用 Power Shell 脚本获取 IIS 设置 我希望使用脚本获取 检查以下信息 检查 Windows 身份验证提供程序是否正确列出 协商 NTLM 检查是否启用了 Windows 身份验证 Windows 身份验证高级设置
  • 如何解决内存碎片

    我们偶尔会遇到这样的问题 长时间运行的服务器进程 在 Windows Server 2003 上运行 由于内存分配失败而引发异常 我们怀疑这些分配由于内存碎片而失败 因此 我们一直在寻找一些可能对我们有帮助的替代内存分配机制 我希望有人能告
  • 由于图形处理单元配置,不支持 Windows Phone 模拟器(Mac 上的 Windows 7)

    启动 Windows Phone 模拟器时出现错误 不支持 Windows Phone 模拟器 因为您的计算机没有所需的图形处理单元配置 如果没有图形处理单元 XNA 框架页面将无法运行 您想继续启动模拟器吗 当我尝试访问网页 任何网页 时
  • 本地推送通知到在应用程序内运行 JS 代码的 Win8 Live Tile

    我正在尝试将更新发送到我的应用程序的磁贴 当应用程序运行时 这可以正常工作 例如 当用户单击按钮时 我可以轻松地将磁贴更新通知发送到磁贴 我无法解决的是当应用程序无法运行时如何更新磁贴 我找到的唯一选择是使用以下命令从远程 Web 服务器拉
  • 如何使用来自 Microsoft-Windows-NDIS-PacketCapture 提供程序的实时 ETW 事件?

    更大的问题是一般如何使用实时 ETW 网络堆栈事件 但我特别感兴趣Microsoft Windows NDIS PacketCapture 提供程序 所有其他网络堆栈提供程序都部分工作 但 NDIS PacketCapture NDIS P
  • 如何在批处理文件中回显换行符?

    如何从批处理文件输出中插入换行符 我想做类似的事情 echo hello nworld 这会输出 hello world Use echo hello echo echo world
  • 为什么我只能用管理员权限才能导入Python中的某些模块?

    我正在努力解决 Python 2 7 中的一些奇怪问题 我写了一个很长的工具 在其中导入不同的模块 我必须首先使用它安装pip 该工具将在公司内部共享 不同的用户在其特定机器上拥有不同的权限 当另一个用户登录我的计算机 我在那里拥有管理员权
  • 在哪里可以获得 PHP 5.3+ 的 runkit DLL 扩展?

    这是一个简单的问题 我在哪里可以获得 PHP 5 3 版本的 runkit 扩展 它的手册 http php net manual en book runkit php http php net manual en book runkit
  • Windows C++ 中的键盘钩子还是什么?

    我希望构建自己的应用程序 它可以将键盘命令 消息 发送到 Windows 操作系统 例如 当我按下组合键 ctrl shift n 时 我希望启动 notepad exe 我怎样才能做到这一点 您对所使用的概念有什么建议吗 我读过 何时使用
  • 一次显示两条Toast消息?

    我希望在一个位置显示一条 Toast 消息 并在另一位置同时显示另一条 Toast 消息 多个 Toast 消息似乎总是按顺序排队和显示 是否可以同时显示两条消息 是否有一种解决方法至少可以提供这种外观并且不涉及扰乱活动布局 Edit 看来
  • Windows 目录永远不会包含临时文件的非 ASCII 字符?

    在 Windows 上使用 MinGW 7 3 0 由于 Windows 限制 Hunspell 无法从包含非 ASCII 字符的位置加载字典文件 我已经尝试了所有方法 1 现在我将文件复制到没有 ASCII 字符的路径 然后再将其交给 H
  • 关闭有效句柄时,AppVerifier 报告“无效句柄 - 代码 c0000008”

    我有一个简单的测试程序 在运行时会失败并出现异常AppVerifier 程序重复STD INPUT HANDLE然后尝试使用关闭它CloseHandle 该程序运行良好 无需AppVerifier返回TRUE for CloseHandle
  • 用于创建计划任务的 VBScript

    我正在尝试创建一个 VBScript 它创建一个批处理文件 然后创建一个计划任务来运行该批处理文件 到目前为止 我尝试过的所有操作都创建了批处理文件 但没有创建计划任务 并且我没有收到任何错误 这是我到目前为止所拥有的 Option Exp

随机推荐