0

I'm trying to write software that is capable of performing data entry into a third party application.

I can detect the presence of windows on the screen by reference to their title by using GetOpenedWindow() etc, focus the window and then inject keystrokes using SendKeys.SendWait("...") etc.

However, depending on what's being entered, the behaviour of the receiving application is not consistent and there's no way to determine how it would behave in advance. In particular, the form I want to fill has a number of fields. Depending upon what is entered, you might need to "press" enter/tab a different number of times to find your way to the right field.

It's therefore not possible simply to have a pre-determined set of keys that need to be sent. Rather, my software will need to be able to interact with the third party software by knowing which control on the third party form is active at a particular time.

i.e. I need to be able to determine where the caret is on a form in third party software, or even better move it to a specific control on the form directly.

Is this even possible please?

I'm using C# .NET in MS Visual Studio 2017.

Andrew17856
  • 161
  • 13

1 Answers1

0

Technically you can do all this by enumerating the windows (sub controls) in app, and casting them to the equivalent ie TextBox, maybe you could use left and top to pin down which control are which, and properties like focus to achieve what you are after...

*Note : Remember Controls are just windows with handles, so it is possible to cast them and use them as such

There are many resources on the internet and stack overflow to achieve this

Maybe some of these might help you

From HWND to control

Access the state of control in Winforms from another application

https://msdn.microsoft.com/en-us/library/system.windows.forms.control.focused(v=vs.110).aspx

TheGeneral
  • 79,002
  • 9
  • 103
  • 141
  • Thanks. That's very helpful. I've been able to enumerate the child windows, but the problem I've now run into is that the particular app of interest is a WPF app, so the entire window is wrapped in an HwndWrapper and so doesn't have any children. I'll post a separate question on that. – Andrew17856 Dec 15 '17 at 11:15