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

jacky Perpète 126 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,837 questions
{count} votes

1 answer

Sort by: Most helpful
  1. RLWA32 48,416 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.

    0 comments No comments

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.