TolikPylypchuk / SharpHook

SharpHook provides a cross-platform global keyboard and mouse hook, event simulation, and text entry simulation for .NET
https://sharphook.tolik.io
MIT License
347 stars 32 forks source link

Failed mouse movement on mac #70

Closed GuruGurra closed 11 months ago

GuruGurra commented 1 year ago

This question is about version 4.2.0. I realize there have been several updates since then, but since there are breaking changes, I need to perform thorough tests before releasing an updated version of my app. In the meantime...

Are there or have there been any known issues where the mouse does not move on Mac?

My situation is like this: On a key press, the app should query and save the mouse position. On another key press, the app should restore the mouse to the recorded position. This works on a vast majority of the installations but fails on a few. On installations where it fails, the call to SimulateMouseMovement() with the correct target coordinates gives the Success return code. However, the mouse does not move, and when querying the mouse position, it is still in the exact location as before the call to SimulateMouseMovement().

Are there any peripherals, like trackpads or 3D mice or anything, that can cause such problems? Or are there any security settings that may prevent the app from moving the mouse? I haven't found any common denominator between the systems that experience this problem. Or are there any changes in later versions (then 4.2.0) that address such problems, even though the version history doesn't mention this?

TolikPylypchuk commented 1 year ago

Hi! Thanks for posting this issue!

Unfortunately, I haven't seen a problem like this before so I can't say what may cause it. I've just looked through some other issues and I didn't find any issues like yours.

I don't think it's a security issue - otherwise the global hook wouldn't have worked on these installations as well. Regardless, could you please try running your application as root on the failing installations to see whether the issue is still there? As I've said, I don't think it's a security issue, so this will probably change nothing, but you can never be too sure.

Also, could you please share the libuiohook debug logs from those installations?

As for changes in the newer versions - there haven't been any functional changes in how libuiohook (or SharpHook) simulates mouse movement on macOS (there were cosmetic changes to the code, but those don't really matter).

Even if it may be non-trivial for you, I would still recommend updating to the newest version of SharpHook. If I fix this issue, the fix will be in the 5.x line as I don't support older versions.

TolikPylypchuk commented 11 months ago

Hi @GuruGurra! I'm just pinging for updates. As I've said before, could you please provide some more info or update to the latest version and try it out? Otherwise, I'll close this issue in a couple more weeks, though we can still continue the discussion after that.

GuruGurra commented 11 months ago

Sorry, I forgot to report back. I got a message from the user where he said it started to work when he gave the app the Accessibility right on the computer, so it was a security settings issue.

TolikPylypchuk commented 11 months ago

Great, thanks for letting me know! This is expected behavior, so I'm closing this issue.