{"id":10020977,"date":"2025-08-27T21:23:20","date_gmt":"2025-08-27T13:23:20","guid":{"rendered":"https:\/\/itmax.cn\/?p=10020977"},"modified":"2025-08-27T21:23:20","modified_gmt":"2025-08-27T13:23:20","slug":"%e5%be%ae%e4%bf%a1%e7%94%b5%e8%84%91%e7%89%884-x%e6%96%b0%e7%89%88%e8%8e%b7%e5%8f%96%e7%be%a4%e6%b6%88%e6%81%af%e7%9a%84%e8%87%aa%e5%8a%a8%e5%8c%96%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10020977","title":{"rendered":"\u5fae\u4fe1\u7535\u8111\u72484.X\u65b0\u7248\u83b7\u53d6\u7fa4\u6d88\u606f\u7684\u81ea\u52a8\u5316\u811a\u672c"},"content":{"rendered":"<h2>\u6458\u8981<\/h2>\n<p>\u817e\u8baf\u5fae\u4fe1\u56e2\u961f\u91cd\u78c5\u53d1\u5e03 Mac \/ PC \u5fae\u4fe1 4.0 \u6d4b\u8bd5\u7248\uff0c\u5168\u65b0\u91c7\u7528 QT+C++\u539f\u751f\u8de8\u5e73\u53f0\u67b6\u6784\uff0c\u5927\u7248\u672c\u53f7\u66f4\u65b0\uff0c\u5e26\u6765\u4e86\u5927\u91cf\u65b0\u7279\u6027\u3002<\/p>\n<p>\u8fd9\u4e5f\u8ba9\u4ee5\u524d\u7684\u81ea\u52a8\u5316\u811a\u672c\u5931\u6548\u4e86\uff0c\u56e0\u4e3a\u5f88\u591a\u63a7\u4ef6\u5185\u5bb9\u6839\u672c\u83b7\u53d6\u4e0d\u5230\u4e86\u3002<\/p>\n<p>\u4e0d\u8fc7\u8fd8\u662f\u6709\u65b9\u6cd5\u7684\uff0c<code>uiautomation<\/code> \u8fd9\u4e2a\u5e93\u8fd8\u662f\u53ef\u4ee5\u83b7\u53d6\u5230\u7fa4\u6d88\u606f\u7684\u3002<\/p>\n<h2>\u4e0a\u4ee3\u7801<\/h2>\n<pre><code>import uiautomation as auto\nimport time\nfrom win10toast import ToastNotifier\nimport traceback\n\n# \u521b\u5efa\u901a\u77e5\u5668\ntoaster = ToastNotifier()\n\n# \u5df2\u7ecf\u901a\u77e5\u8fc7\u7684\u6d88\u606f\u96c6\u5408\nnotified = set()\n\ndef get_chat_texts(ctrl, results=None):\n    if results is None:\n        results = []\n    try:\n        if ctrl.ClassName == &quot;mmui::ChatTextItemView&quot;:\n            text = (ctrl.Name or &quot;&quot;).strip()\n            if text:\n                results.append(text)\n        for child in ctrl.GetChildren():\n            get_chat_texts(child, results)\n    except Exception as e:\n        print(&quot;[\u9519\u8bef] \u83b7\u53d6\u6d88\u606f\u5931\u8d25:&quot;, e)\n        traceback.print_exc()\n    return results\n\nwhile True:\n    try:\n        # \u67e5\u627e\u6240\u6709\u7a97\u53e3\n        windows = auto.GetRootControl().GetChildren()\n        for win in windows:\n            try:\n                if win.ClassName == &quot;mmui::ChatSingleWindow&quot;:\n                    group_name = win.Name or &quot;\u672a\u77e5\u7fa4\u804a&quot;  # \u7fa4\u804a\u6807\u9898\n                    messages = get_chat_texts(win)\n                    for msg in messages:\n                        key = f&quot;{group_name}_{msg}&quot;\n                        if key not in notified:\n                            notified.add(key)\n                            print(f&quot;[\u65b0\u6d88\u606f] {group_name}: {msg}&quot;)\n                            try:\n                                toaster.show_toast(\n                                    f&quot;\u65b0\u6d88\u606f - {group_name}&quot;,\n                                    msg,\n                                    duration=5,\n                                    threaded=False\n                                )\n                            except Exception as e:\n                                print(&quot;[\u9519\u8bef] \u5f39\u51fa\u901a\u77e5\u5931\u8d25:&quot;, e)\n            except Exception as e:\n                print(&quot;[\u9519\u8bef] \u5904\u7406\u7a97\u53e3\u65f6\u51fa\u9519:&quot;, e)\n                traceback.print_exc()\n    except Exception as e:\n        print(&quot;[\u81f4\u547d\u9519\u8bef] \u4e3b\u5faa\u73af\u5f02\u5e38:&quot;, e)\n        traceback.print_exc()\n\n    time.sleep(2)<\/code><\/pre>\n<h2>\u622a\u56fe<\/h2>\n<p>\u83b7\u53d6\u5230\u6d88\u606f\u4f1a\u5728\u53f3\u4e0b\u89d2\u5f39\u51fa\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u9700\u8981\u5355\u72ec\u5c06\u9700\u8981\u83b7\u53d6\u6d88\u606f\u7684\u7fa4\u62c9\u51fa\u6765\uff0c\u53ef\u4ee5\u6700\u5c0f\u5316\uff0c\u4f46\u662f\u4e0d\u80fd\u5173\u95ed\u7a97\u53e3\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"723\" height=\"426\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdmhGX\" alt=\"461e70ffad569a9802e712f06965145e.png\" title=\"461e70ffad569a9802e712f06965145e.png\"><\/p>\n<h2>\u672c\u6587\u4f5c\u8005<\/h2>\n<p>TANKING<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000047217890\">https:\/\/segmentfault.com\/a\/1190000047217890<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6458\u8981 \u817e\u8baf\u5fae\u4fe1\u56e2\u961f\u91cd\u78c5\u53d1\u5e03 Mac \/ PC \u5fae\u4fe1 4.0 \u6d4b\u8bd5\u7248\uff0c\u5168\u65b0\u91c7\u7528 QT+C++\u539f\u751f\u8de8\u5e73\u53f0\u67b6\u6784\uff0c\u5927\u7248 [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10020977","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020977","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10020977"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020977\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10020977"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10020977"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10020977"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}