namespace WxAgent.Core; public sealed record WechatNoteWindowCandidate(long Handle, int ProcessId, string Title, bool IsVisible, bool HasChatSurface); public static class WechatNoteWindow { public static long? FindOpened(IEnumerable windows, int processId, IReadOnlySet previousHandles) { var candidates = windows.Where(window => window.Handle != 0 && window.ProcessId == processId && !previousHandles.Contains(window.Handle) && window.IsVisible && !window.HasChatSurface && window.Title.Contains("笔记", StringComparison.Ordinal)).ToArray(); if (candidates.Length > 1) throw new WxAgentException(WxAgentErrorCode.UiStructureChanged, "Multiple new note windows appeared; refusing ambiguous content."); return candidates.Length == 1 ? candidates[0].Handle : null; } }