Reputation: 4702
I'm using C# and Process newProcess = Process.Start("someProgram.exe");
This someProgram.exe has a form that has public text boxes.
Is there anyway that I can use newProcess to set the textBoxes? I was hoping there would be something like newProcess.GetField(textField1).Text = "Awesome";
I've looked at the Process API and properties while debugging and nothing jumped out.
EDIT: I do have the source to someProgram.exe, so I know the text box fields are public. I can't edit someProgram's source. The code that uses Process.Start was handed down and I didn't want to spend time changing how it works if I could pass some parameters to the new process.
My real goal is when Process.Start("someProgram.exe") runs I can place text in the text fields so I can be lazy and not type in a user name and pw everytime. :)
Thanks
Upvotes: 2
Views: 972
Reputation: 5955
The short answer is probably no. The long answer is maybe. If you open up someProgram.exe and use Spy++, you might be able to glean information about the window information, and then send a WM_* message to the right window handle which would mimic the typing of text to that text box.
I would only go this route if you don't have the source to someProgram.exe which would allow you to use more conventional means.
Upvotes: 0
Reputation: 564441
You cannot access this directly.
Members are only public within the application in which they are running. You cannot access types within other applications (directly), in this fashion.
This, by the way, is a very good thing. If you were allowed to mess with the internal operations of other applications, you'd be able to completely violate any security model present within just about any application. System security and stability would suffer greatly.
There are two options for this scenario:
Upvotes: 0
Reputation: 78272
You cannot. See this question.
IPC Mechanisms in C# - Usage and Best Practices..
Upvotes: 2