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 -