Share via

Blocking Mouse Hook for a vb.net application when the task manager has focus.

jacky Perpète 171 Reputation points
2025-04-18T09:07:49.86+00:00

Hello,

For a VB.NET application with WPF, I'm using a transparent window that follows the movement of the mouse cursor on the screen.

This application uses the mouse hook to handle the move event.

This window represents a custom cursor.

This test application works correctly except on Windows applications like Task Manager or Device Manager.

When one of these windows gains focus, the mouse hook is disabled in my application.

How can I prevent this?

I've seen custom cursors using the same principle that don't have this problem.

I'm attaching my test program in VB under WPF.To attach it.

I changed the file extension from .zip to .txt.

To use it, you'll need to change the extension from .txt to .zip.

WpfCursorWindow.txt

TestHookMouse

Developer technologies | VB
0 comments No comments

Answer accepted by question author

  1. RLWA32 52,561 Reputation points
    2025-04-18T14:13:56.1133333+00:00

    If you are signed-on as an account that is a member of the Administrators group then Task Manager will auto-elevate so it will run with a high integrity level. Your application runs at medium integrity so Windows built-in security measures prevent the low-level mouse hook from interacting with Task Manager.

    You can work around this by making your application a UIAccess application. This is done by signing the application, installing it to a protected file system location and manifesting it with uiAccess=true. An alternative is to run the application with elevated privileges as Administrator though this is probably not what you would want. The screen capture isn't very good but it does demonstrate the solution works -

    UIAccess

    Was this answer helpful?

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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