检测用户空闲(每个应用程序实例)应用程序、实例、用户

2023-09-03 03:54:34 作者:不能长久就别让我拥有

我需要我唯一的(每个我的应用程序实例)应用程序的用户空闲检测。 我不能使用的 GetLastInputInfo 的,因为是指定会话的用户输入

I need user idle detection in my application only (per "my application instance"). I can't use GetLastInputInfo because is session-specific user input:

GetLastInputInfo 不提供跨所有运行的会话系统范围的用户输入信息。相反,GetLastInputInfo提供的指定会话的用户输入信息只调用该函数的会话。

GetLastInputInfo does not provide system-wide user input information across all running sessions. Rather, GetLastInputInfo provides session-specific user input information for only the session that invoked the function.

有什么建议?

推荐答案

您可以使用 Application.AddMessageFilter 和观看消息重新presenting用户交互(例如鼠标,键盘,也许菜单激活)。

You could use Application.AddMessageFilter and watch for messages representing user interaction (e.g. mouse, keyboard, maybe menu activation).