You can achieve this using White .
It allows you to programmatically simulate user interactions with Win32, WinForms, WPF, Silverlight, and SWT applications. I used it many years ago when for the first time I was able to automate some simple smoke tests in a WinForms application with great success.
(Caution: this is based on my use a while ago, so now it may be slightly different)
I created some code to run my application and search for a number of controls by name. After detection, each control can be controlled (for example, entered text, button press, etc.). To find the name of the controls, use something like Spy ++ (Win32), UISpy (WinForms), or Snoop (WPF) to check the running application.
source share