23 lines
775 B
C#
23 lines
775 B
C#
using System.Diagnostics;
|
|
using Windows.Win32;
|
|
using WxAgent.Core;
|
|
|
|
namespace WxAgent.Windows;
|
|
|
|
internal static class WechatDesktop
|
|
{
|
|
public static bool IsInputAvailable()
|
|
{
|
|
using var process = Process.GetCurrentProcess();
|
|
// UIA can read cached windows on a locked/disconnected desktop. GetCursorPos requires the input desktop.
|
|
return Environment.UserInteractive && process.SessionId != 0 && PInvoke.GetCursorPos(out _);
|
|
}
|
|
|
|
public static void EnsureInputAvailable()
|
|
{
|
|
if (!IsInputAvailable())
|
|
throw new WxAgentException(WxAgentErrorCode.SessionLocked,
|
|
"The current session cannot access the input desktop. Connect and unlock the existing user session; no login bypass was attempted.");
|
|
}
|
|
}
|