# -*- 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 = 'GenericOopTest 测试源修复'\n" "$b = 'TPV 设计遵循找不到 fast-fail,不支持 __init__ 未注解 self 成员推断;GenericOopTest 4 个泛型类缺字段注解(a/first/second/val/value/flag),已补齐(a: T 等),重跑测试即可'\n" "$xml = [Windows.Data.Xml.Dom.XmlDocument]::new()\n" "$xml.LoadXml('' + $t + '' + $b + '')\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)