Closed weil closed 3 months ago
Hi! Thanks for posting this issue! I will look into it in the nearest future.
I've just tried reproducing it using the code you provided, and everything works correctly on my machine - when suppressing the mouse press/release events for Button2
, no right-clicks go through.
Could you please describe in more detail, what happens on your machine? Do other applications register the right click and show a context menu?
I've just tried reproducing it using the code you provided, and everything works correctly on my machine - when suppressing the mouse press/release events for
Button2
, no right-clicks go through.Could you please describe in more detail, what happens on your machine? Do other applications register the right click and show a context menu?
even I set "e.SuppressEvent = true;", all other applications (e.g vs code, chrome) can still show the right click menu.
I used other open source lib like " Gma.System.MouseKeyHook", i was able to stop the right click menu by doing "e.handled =true"
Could you please also tell me what Windows version you have and whether your project uses .NET Framework or the new .NET?
Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.4 windows: Windows 10 Pro
I've just tried reproducing it using the code you provided, and everything works correctly on my machine - when suppressing the mouse press/release events for
Button2
, no right-clicks go through.Could you please describe in more detail, what happens on your machine? Do other applications register the right click and show a context menu?
could you plz share me the zip of your program and .net version? I tried .net 7 on my side and still had the same issue. Thanks in advance.
I literally just used the code you provided without any changes. I used .NET 8, but I don't think there will be any difference between 7 and 8.
Can you add some code to see that the event handler is actually called? Like adding Debug.WriteLine
or something like that. We should see whether just suppressing the event doesn't work, or the event handler doesn't work at all.
Also, you should either dispose the global hook when the window closes, or you should create it the following way:
new SimpleGlobalHook(runAsyncOnBackgroundThread: true);
This way the application will exit when you close the window. Otherwise it will keep running in the background since the global hook is still running on another thread.
Since I cannot reproduce the issue on my machine, there's not much I can actually do to help right now, unfortunately.
Could you maybe add some Debug.WriteLine
statements to the event handler to see whether the hook works? Maybe, the handlers don't get called at all?
all other applications (e.g vs code, chrome) can still show the right click menu.
FYI I've had issues with VS Code, Chrome, and VMWare Horizons. I can't quite recall the issue I had in chromium based apps, but in VMWare, it has some sort of keylogger protection. I'm pretty sure it uses DebugProc
or something similar to catch and disable the hook.
@weil since I cannot reproduce this issue, I will close it due to inactivity, but we can continue the discussion and reopen it if necessary.
I created a simple sharphook c# program to disable the global right click menu: https://pastecode.io/s/mdu66mhk
I expected it could disable the global right click menu, not just the form right click. Is that a right expectation? Or it only disable the right click functionality within the form? Thanks for looking in it. Really appreciate it.