Retrieving textBox handles

128 views Asked by At

I'm currently working on a project to provide interop between two unrelated pieces of software. I need to pass the data from a textBox/textBoxes, into a textBox of the other said app.

My current idea is to find the handle of the target control, make it active, and enter the data by copying it to the clipboard, and pasting it via:

Clipboard.SetText(textBox1.Text, TextDataFormat.Text);
SendKeys.SendWait("^V");

As textBoxes have no 'caption', handles are dynamically assigned on the process start, and class names are appended with various data regarding the process, is it possible to get a handle for an object within a window via some sort of indexing? I'd be more than willing to find the correct handle by trial and error if need be, as long as it would be consistent for every instance of the application.

Thanks in advance

A.

1

There are 1 answers

3
Slack Shot On

If you don't have any other choice.. to make this easier, you can use AutoIT.. I had to do something like this a very long time ago. AutoIT. They have a DLL for .net Applications, so you can use their functionality without having to use their scripts. If you do use their scripts.. they also have an option that will turn their script into an executable.