17 lines
876 B
C#
17 lines
876 B
C#
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<WechatNoteWindowCandidate> windows, int processId, IReadOnlySet<long> 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;
|
|
}
|
|
}
|