3

My app written in c# (winforms) launches a third party using Process.start().

After launch, I need to fill in some information in Search Textbox of Third party app. So how to identify the textbox of thirdpaty app? how to fill info in it?

Any clue or guidance? Keywords to search for?

user1327064
  • 4,187
  • 5
  • 20
  • 30
  • Please go through this link. It will help you out. http://stackoverflow.com/questions/1019790/how-to-find-a-child-of-a-parent-unmanaged-win32-app – Pushpendra Sep 14 '12 at 18:37

1 Answers1

4

You can do this using the UI Automation Library.

Using either UISPY.exe of Inspect.exe find the automationid , name etc any parameter that can uniquely indentify the TextBox. One you have done this you can do something like this, assuming you know the automation id.

string automationId = "ThirdyPartBox";
string newTextBoxValue = "foobar";
var condition = new PropertyCondition(AutomationElement.AutomationIdProperty, automationId);
var textBox = AutomationElement.RootElement.FindFirst(TreeScope.SubTree , condition);
ValuePattern vPattern = (ValuePattern)textBox.GetCurrentPattern(ValuePattern.Pattern);
vPattern.SetValue(newTextBoxValue);

Maybe the textbox is not uniquely identifiable by itself , you can use conditions like process id , parent container id etc to pin point it.

To Click a Button. Find the automation element first using a condition of your choice and then

InvokePattern clickButton = (InvokePattern)buttonElement.GetCurrentPattern(InvokePattern.Pattern);
clickButton.Invoke();
parapura rajkumar
  • 24,045
  • 1
  • 55
  • 85