Files
TransPyC/_toast_gen.py
T

20 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""生成并发送 toast 通知"""
import base64, subprocess
ps = (
"Add-Type -AssemblyName System.Runtime.WindowsRuntime\n"
"[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null\n"
"[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null\n"
"$t = 'VectorGenericTest 隐式泛型推断已修复'\n"
"$b = '_infer_generic_ctor_type_arg:CInt(0)/CFloat64T(0) 的 Name 函数名补 strstr 匹配;非类型转换实参(pool)默认 int 被过滤而非 fail-fast(Vector 三处修复已完成)'\n"
"$xml = [Windows.Data.Xml.Dom.XmlDocument]::new()\n"
"$xml.LoadXml('<toast><visual><binding template=\"ToastText02\"><text id=\"1\">' + $t + '</text><text id=\"2\">' + $b + '</text></binding></visual></toast>')\n"
"$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)\n"
"[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('TraeCode').Show($toast)\n"
)
b64 = base64.b64encode(ps.encode('utf-16-le')).decode()
r = subprocess.run(['powershell', '-NoProfile', '-EncodedCommand', b64],
capture_output=True, text=True)
print('rc=', r.returncode)