Accessing other programs.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

First let me say that I am a student learning the .net language, but I am a
quick learner. I'm studying C# and VB.net. I have a program that is not
..net managed. It's basically 3 list boxes where I select a name from each
and click a button. The program then builds an audio file based on the
selections. I would like to be able to automate this off of an input file.

My question is, is there anyway to control the selections of the text boxes
using the .net framework? I realize this is a complex answer (if possible),
if you could just point me to the right namespace/class or a web page I would
be greatful.

Brett
 
Hello Brett,

Right now, your app is set up so that the user's actions drive the behavior
of the app. The user clicks some controls and the app reacts. You want to
change this so that the user provides an input file, and the app will react.
In this case, the U/I is not involved directly. Make sure that the effect
of selecting your controls calls a seperate class that actually performs the
work. That way, you can easily code the behavior of the flat file, because
you can call that same, external, class. It won't matter what the controls
on the U/I do.

As you've probably guessed, I'm not sure why you'd want to wire the user
interface to the flat file. I can only assume that you will be using the
U/I to show information (what is playing) as opposed to selecting
information (what to play)? You may want to use different controls for
this.

Anyway, to answer your question, you can easily change the selections of a
text box or list box through the framework.

To change the item selected in a list box, set the MyListBox.SelectedIndex
property.
To change the text in a text box, change the MyTextBox.Text property. You
can change the selected portion of the text using the SelectedStart and
SelectedLength properties of the text box.

Hope this helps,
--- -Nick Malik
 
Hi Brett,

If I understand you correctly, the unmanaged program can't be changed but
you want to somehow automate it from your own program which accepts a file
as input and calls the unmanaged program with each "song" in turn?

If so, you might manage to do it using Win32 API PostMessage/SendMessage
to simulate user input.
However, you won't be able to know when the unmanaged program is finished
building the audio file.
 
My apologies... I didn't read your requirements correctly.

My answer doesn't apply.

If you can get the windows handle of the window that you are trying to
control, you can send the events to the controls. However, this is not all
that easy to do.

--- Nick
 
Back
Top