Tracking windows form events

Good day.

I am looking for a way of blanket tracking events of a form object in windows forms. Something like Register-ObjectEvent -EventName *

Is it possible?

Kamil,

Please provide more detail and/or example of what you are trying to accomplish. If you have any code written already please share where we can assist in identifying any errors. If you are looking for someone to write the code for you that is not the scope of this forum.

Good day, Jason.

I am creating a GUI interface based on windows.forms. Now, on the form, there are three objects: datagridview and two buttons. I’d like to log events firing as a user interacts with the form. But to do it comprehensively i have to Register-ObjectEvent for every conceivable EventName. That is why i was wondering is there a way to register an Action scriptblock which would fire for all events no matter what. I’d like to write something like

Register-ObjectEvent -InputObject $form -EventName *

But it isn’t allowed.

Kamil,

What are you adding into the $Form variable? Again we need to see the code to understand what you are trying to accomplish, you are welcome to change what you need to for any proprietary information. However without the code its going to be limited, have you researched the Register-ObjectEvent yet? Below are some links for research.

Help Register-Object -Full

i have read both the help and the Scripting Blog article.

i am looking for a one liner which gets one subscriber subscribed to all (not just one) event types of a given object.

i’ve already typed a one liner which, i imagine, would be good to have, but it does not work that way.

Kamil,

Sorry for the delay on my end. Been extremely busy from my end. Can you give an example of what you are trying to accomplish? If you are building a GUI, why are you attempting to make it a one liner? Sorry if I’m asking questions that are obvious, brain has to kick back into gear.

 

All right.

Imagine a situation where you build a GUI and you want to log ALL events on a form, simply to know what events and in what order happen. In order to do this you have to know the names of all events of all objects in the form including the form itself. Then you have to hard code every event processing scriptblock.

What if you could, instead of writing Register-ObjectEvent -InputObject $form -EventName “Certain event”, write Register-ObjectEvent -InputObject $form -EventName * (notice the asterisk). So that with one Register-ObjectEvent you subscribe to ALL events of an object and all the child objects.

Regards
Kamil