Intercepting click event for all controls in an app in C# (WinForms)

前端 未结 4 798
不思量自难忘°
不思量自难忘° 2021-01-02 23:01

I want to make an application to intercept all UI events in all the forms of my application and to write them to a log. This data can than be used to see which controls are

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-02 23:35

    You can install a message filter.

    A message filter is an object that implements IMessageFilter. WinForms calls your PreFilterMessage method for every message that passes through your thread's message loop. This is enough to monitor user input across the application (and gives you the option of manipulating it).

提交回复
热议问题