Hook button press event in another application - c#

I’ve to develop an application that has to track the button press event of a button which in another application. After some research I found that Windows Hooks might work for me and I’d develop a sample application that hooks the button press event in another application.
The problem I’m facing with that sample application, gets the control after the button is pressed whereas I need to get the control before the button is pressed i.e., First the sample application should get the control so, that it can grab the information from that dialog and, then after the control goes to the actual event handler of that button in other application.
I’ve already tried WH_CALLWNDPROC, WH_CALLWNDPROCRET, WH_GETMESSAGE, & WH_SYSMSGFILTER. Using WH_CALLWNDPROC hook I’m able to hook the button press but my application gets the control after the button press event handler is executed but my requirement is to get the control before the button press event handler is executed.
I’ve used the Wilson GlobalHooks to hook the application in C#. Here is the link to it.

Related

Listening to textChanged from another application

Is it possible to know when a text from another application has changed?
Currently I can capture the Click event using globalhooks and WindowFromPoint()

UI Automation monitoring

I'm trying to monitor an external WPF application(no source-code) from a local app, and see when a button is clicked in c#.
So far i've been exploring UI Automation's options, and i saw that it works similar if not same to the Inspect.exe tool.
The problem i have is, the WPF form i need to monitor does not contain the button i need directly, as a sub-control. Instead, first you need to log in, then click a few buttons and then finally a new window opens, and it contains the button i need to check.
So my question is, is there a way this to be monitored with the UI Automation? I know i can trigger an event when the main form starts a new process, and the button is clicked, but how do i handle all the steps in between?
(Or in other words how can i trigger an event when the final window containing the button i need to check is actually open)

How to keep the keyboard open after completed event fired on a Xamarin entry?

Everyone just want to hide the keyboard, but it closes automatically.
I want to keep the keyboard open and keep the entry focused after the completed event fired on a Xamarin entry control or in other words, I do not want the entry control blurred.

Event-Handling buttons on WinForm from a DLL

I have written a C# utility class (DLL), which gets called by a windows application. Within the windows application, I have setup a backgrounderWorker to allow for time-consuming code not to hog the windows application. The time-consuming code is in the utility class DLL. Now, I setup two buttons on the windows application a 'submit' button - where the time-consuming code gets called in the utility class and a 'cancel' button.
I would like the 'cancel' button to stop the backgroundWorker code if clicked. Problem is the the 'Cancel' button is in the windows application and the code is in the DLL. So is there a way for me to maybe attach the 'cancel' button's 'onClick' eventHandler to the DLL and then have the DLL periodically check to see if the button was pressed?
BTW, the cancel button does work up until the DLL code gets initiated.
Am I correct in my thoughts or is there a better way? Any help would be appreciated.
Yes, It is possible to register to events between projects. all you have to do is have a reference of the winforms application inside your dll, and have the cancel button public. then you can register to any of it's events inside the dll code. However, I'm not sure that this is the best way to do what you want. I think a better way to do it is have a method called Cancel inside the dll and have the cancel button click event call this function. This way your dll is less dependent on your winforms application.
I actually went back and looked at some documentation I had about events and event handling. I did the following in the DLL:
Made a public class an added an eventHandler, my own custom eventArgs, and a subclass (eventWatcher) to host an event (call it onCancel)
I registered eventWatcher to listen for the OnCancel event in the DLL.
I made the eventWatcher public so it can be consumed in the client app.
In the client app, I did the following:
I modified the cancel button to raise the onCancel event. This allowed me to assign a method in the DLL to handle the graceful exiting of the time-consuming code in the DLL.
It now works as expected!

Detect whenever click event is fired in fully transparent window

I have a transparent controls and window where I can click through as it would not even exist. My question is: Is it possible to detect whenever click event is fired no matter where on the screen I click, while the wpf applicaton is running?
The reason why I need this is because I'm making an agent that will collect all information about actions made by user. Any suggestions, hacks, tricks will do.
You would need to create an event hook so that you could snoop all system wide messages before they are dispatched to the target window. Check the following link for more information...

Categories