Mouse hook with C#

后端 未结 4 1965
旧巷少年郎
旧巷少年郎 2021-01-15 01:08

I am trying to emulate \"hardware\" mouse clicks as it appears that some software blocks input from PostMessage for instance. I know there\'s SendInput, but that\'s not an o

4条回答
  •  隐瞒了意图╮
    2021-01-15 01:58

    mouse_event or SendInput used to inject mouse input. But just like a real mouse it's global input and can't work on hidden windows.

    A low-level-mouse-hook is global too, but it is used to intercept and manipulate mouse-input, not to inject input.

    When targeting a specific window you'll need to use SendMessage, but as you noted it doesn't work for everything.

    You can also use dll hooking(for example an IAT hook) to intercept calls to APIs which return the gobal cursor position or the state of the mousebuttons. But for that you need to inject a dll into the target application, and that dll shouldn't use .net.

提交回复
热议问题