How can I tell in C# or VB.NET if a low-level hook is blocked by a high-integrity process?

jacky Perpète 146 Reputation points
2025-05-02T14:40:04.8966667+00:00

Hello,

In a VB.NET application, I'm using a low-level hook to manage mouse movements on the screen.

Windows' built-in security measures prevent the low-level mouse hook from interacting with, for example, the Task Manager.

My program no longer receives mouse coordinates when the Windows Task Manager has focus.

To work around this situation, I don't want to run my application with elevated privileges as an administrator or use a signing certificate.

Is it possible to detect when my application's mouse hook is blocked by a high-integrity process? (API?)

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,845 questions
{count} votes

Accepted answer
  1. RLWA32 48,896 Reputation points
    2025-05-02T17:07:55.71+00:00

    You could use WinEvents to track changes to the foreground window. The event callback could determine if the process owning the foreground window has an integrity level greater than medium. If it does, the assumption would be that your low level mouse hook will not be called until the foreground window changes to a lower integrity level process.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.