Feature: Add window info RPC for foreground checks and window activation
Add a capability-gated main-connection RPC (COMMAND_MCP_WINDOW_INFO=179 / TOKEN_MCP_WINDOW_INFO=180) that returns visible top-level windows with UTF-8 titles, screen rectangles, foreground flag and z-order, so MCP can verify focus before injecting input. New tool get_foreground_window; host_list_windows switches to the richer fields; host_control_window and operate_window gain action=activate; remote_keyboard and remote_mouse gain expect_hwnd, require_foreground and report_foreground. Old clients keep the previous behavior: the RPC is refused up front via CLIENT_CAP_WINDOW_INFO. The client caps a response at 96 windows (about 101 KB, under MAX_SEND_BUFFER). Signal the cut-off in the mode byte (0x80) instead of silently dropping windows: host_list_windows now reports truncated=true and says the list is incomplete, and activate verification reports state=unknown with reason=list_truncated rather than claiming the window is gone. expect_hwnd is checked only after the session is validated, so an invalid session_id no longer burns a window RPC and no longer reports a window error for a session that does not exist. Nullable output fields (foreground, window) are declared as ["object","null"] so strict clients do not reject responses. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
c7e23f750d
commit
b2c0d81396
18 files changed
+1298
-68
No files matched your search
@@ -3,6 +3,9 @@
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "stdafx.h"
|
||||
#include "MachineManager.h"
|
||||
// 不能包含 Common.h:本文件里的注入用 ThreadProc 会与 Common.h 的同名函数形成重载,
|
||||
// 导致下面 (DWORD_PTR)ThreadProc 的取址歧义。这里只声明需要的辅助函数。
|
||||
bool ClientActivateWindow(HWND hwnd);
|
||||
#include <psapi.h>
|
||||
#include <LMACCESS.h>
|
||||
#include <LMERR.h>
|
||||
@@ -165,7 +168,12 @@ void CMachineManager::OnReceive(PBYTE lpBuffer, ULONG nSize)
|
||||
DWORD dHow;
|
||||
memcpy((void*)&hwnd, lpBuffer + 1, sizeof(DWORD)); //得到窗口句柄
|
||||
memcpy(&dHow, lpBuffer + 1 + sizeof(DWORD), sizeof(DWORD)); //得到窗口处理参数
|
||||
ShowWindow((HWND__*)hwnd, dHow);
|
||||
// 能力位 CLIENT_CAP_WINDOW_INFO 下的“激活”哨兵:ShowWindow 只能改可见性,
|
||||
// 后台窗口仍会被别的窗口盖住,必须走真正的置前逻辑。
|
||||
if (dHow == CMD_WINDOW_ACTIVATE_FLAG)
|
||||
ClientActivateWindow((HWND)hwnd);
|
||||
else
|
||||
ShowWindow((HWND__*)hwnd, dHow);
|
||||
}
|
||||
break;
|
||||
case COMMAND_WINDOW_CLOSE: { //关闭
|
||||
|
||||
Reference in new issue
Block a user