开发者

How to Receive click location from another process with C#?

My C# application needs to receive a click position from another process, I then need t开发者_如何转开发o show on my app. But I don't know how I would implement it.

Could someone help me figure out how to do this?

Thanks so much


What you need is called a "Hook". Windows allows you to hook both the keyboard and mouse events. Basically windows works by injecting the appropriate movements and clicks of the mouse (and keys typed) into the application that has focus.

However using the hook, you receive all of the events, not just those relevant to your app. Once you have the hook established you can then do what you want with the information.

Note that you are going down to the windows OS and if you do the wrong thing here, you can leak the handles and you can also cause windows to get into a bad state.

There is a great tutorial here from MS Technet that describes how to do this in C#.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜