Question about automating program actions in VB.NET

  • Thread starter Thread starter Anthony P.
  • Start date Start date
A

Anthony P.

Hello Everyone,

I'm needing to write an application that will take information from a
text file and use that text to do something in another program.
Basically, I need my VB.NET program to simulate the users actions if
they were using the program. So let's take a simple example:

Let's say I have a program that has the window caption "Program A".
Now, I know how to find the right window through the use of the
FindWindowA API function. That isn't a problem. Now, let's say that
window has three textboxs and I want to paste text into the third text
box. That is what I don't know how to do.

Can anyone help?

Thank you!

Anthony
 
Anthony P. said:
Hello Everyone,

I'm needing to write an application that will take information from a
text file and use that text to do something in another program.
Basically, I need my VB.NET program to simulate the users actions if
they were using the program. So let's take a simple example:

Let's say I have a program that has the window caption "Program A".
Now, I know how to find the right window through the use of the
FindWindowA API function. That isn't a problem. Now, let's say that
window has three textboxs and I want to paste text into the third text
box. That is what I don't know how to do.

Can anyone help?

Thank you!

Anthony

You could use the SendKeys class. I think the problem with providing more
info than this would be, how are you determining which text box is "third"?
You have to make the text box you want active, possibly by SendKeys with a
tab, but that only works with the tab order of the form.

Mike
 
That's like trying to wash windows using kleenex taped to a backhoe.
OVERKILL.

Get yourself a copy of VB6. Way less over head and more speed. .Nxt is
awful for desktop application, especially where cross process tasks are
involved.

--
2025
If you do not believe in time travel,
your beliefs are about to be tempered.

http://www.facebook.com/group.php?gid=43606237254
message |
|
| "Anthony P." wrote:
|
| > Hello Everyone,
| >
| > I'm needing to write an application that will take information from a
| > text file and use that text to do something in another program.
| > Basically, I need my VB.NET program to simulate the users actions if
| > they were using the program. So let's take a simple example:
| >
| > Let's say I have a program that has the window caption "Program A".
| > Now, I know how to find the right window through the use of the
| > FindWindowA API function. That isn't a problem. Now, let's say that
| > window has three textboxs and I want to paste text into the third text
| > box. That is what I don't know how to do.
| >
| > Can anyone help?
| >
| > Thank you!
| >
| > Anthony
| >
|
| You could use the SendKeys class. I think the problem with providing more
| info than this would be, how are you determining which text box is
"third"?
| You have to make the text box you want active, possibly by SendKeys with a
| tab, but that only works with the tab order of the form.
|
| Mike
 
Well, you'd need to find the handle to that third text box and call
SetWindowText on it.

The problem is, that handle will change every time the app in question is
launched! If the text box in question is always pre-populated with some
constant string you could likely use FindWindowEx to locate its handle.

Try using Spy++ on the window in question to determine the class name of the
textbox in question. It's likely to be something like EDIT, but if it's a
VB6 app it will more likely be something like ThunderRT6TextBox. You could
then use FindWindowEx to find the first child control on the target window
with that class name, and keep calling it until you find the desired text
box. In theory, it *should* be the same position in the queue - i.e. if
FindWindowEx returned the handle to the correct text-box on the third
iteration, then it should always do it on the third iteration - but don't
take my word on that!

Once you can reliably determine the handle to the text box every time the
app is launched, you can either call SetWindowText or SendMessage with a msg
of WM_SETTEXT.

Hope that points you in the right direction,
Alex
 
Well, you'd need to find the handle to that third text box and call
SetWindowText on it.

You can't use SetWindowText on a control in another process. You have to send
a WM_SETTEXT message.
 
Back
Top