首页 > 解决方案 > python winrt windows Toast通知获取输入作为变量

问题描述

import winrt.windows.ui.notifications as notifications
import winrt.windows.data.xml.dom as dom

#create notifier
nManager = notifications.ToastNotificationManager
notifier = nManager.create_toast_notifier(r"C:\Users\andyy\AppData\Local\Programs\Python\Python37\python.exe")

#define your notification as 

tString = """
<toast>

    <visual>
        <binding template='ToastGeneric'>
            <text>Sample toast</text>
            <text>Sample content</text>
            <text>asdfasdadsfds</text>
        </binding>
    </visual>

    <actions>
        <input id="textBox" type="text" placeHolderContent="Type a reply"/>
        <action
            content="Send"
            arguments="action=reply&amp;convId=9318"
            activationType="background"
            hint-inputId="textBox"/>
    </actions>

</toast>
"""


#convert notification to an XmlDocument
xDoc = dom.XmlDocument()
xDoc.load_xml(tString)

#display notification
notifier.show(notifications.ToastNotification(xDoc))

这是我尝试创建带有输入的 toast 通知,并且它有效。但我想获取用户输入输入的字符串。我该怎么做?

在此处输入图像描述

标签: pythonpython-3.xwindowsnotifications

解决方案


我想你需要在这里注册后台访问

按钮使您的 toast 具有交互性,让用户可以对您的 toast 通知采取快速操作,而不会中断他们当前的工作流程。例如,用户可以直接从 toast 中回复消息,或者删除电子邮件,甚至无需打开电子邮件应用程序。按钮出现在通知的展开部分。

我正在尝试注册但失败了。让我知道它是否有效


推荐阅读