Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handle button click in another application

Tags:

c#

winapi

I am looking for a method to get a button press event, something similar like this which is used to retrieve a pointer right after an event is fired. The button I mean is located on any particular windows application I set as a target (.eg windows media player's Play button). If you know what message to catch right after I click the Play button.

like image 817
Pevus Avatar asked Jun 05 '26 05:06

Pevus


1 Answers

What you are looking for is Global Mouse Hook. You can take a look at this article: Processing Global Mouse and Keyboard Hooks in C#

Once you handle CLICK event, you can use API functions to get Application / Control under the cursor (WindowFromPoint).

Here is one more article with code sample that will help you: .NET Object Spy and InvokeRemote (this is similar to spy++)

You cannot do this without using windows native methods.

like image 57
HABJAN Avatar answered Jun 06 '26 18:06

HABJAN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!