word = textBox1.Text;
            Process myprocess = new Process();
            myprocess.StartInfo.FileName = @"C:\Users\Public\Desktop\Cambridge Advanced  Learner's Dictionary - 3rd Edition.lnk";
            myprocess.Start();

I'm trying to automate a 3rd party app using c# code. I know how to invoke the main window of the app through code using something like this..
but I dont know how to take control of its child windows and its different options and how to send the value of word to its child windows.

Dani AI

Generated

A quick correction and a practical path forward that complements the replies from and .

Remoting (as mentioned by ) is for sharing .NET objects between processes and will not let an external third‑party GUI expose its internal controls. The SetForegroundWindow/SendKeys approach suggested by can work for quick hacks but is fragile (focus, timing, UAC/elevation, session isolation, and custom controls often break it). A more reliable approach is to use the Windows UI Automation API to talk to the UI elements directly.

Example (core idea) using System.Windows.Automation:

using System.Windows.Automation;

// assume "proc" is the Process for the target app and has a valid MainWindowHandle
var root = AutomationElement.FromHandle(proc.MainWindowHandle);
var edit = root.FindFirst(TreeScope.Descendants,
    new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit));

if (edit != null)
{
    var valuePattern = edit.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
    if (valuePattern != null)
        valuePattern.SetValue(word);
}

Notes, fallbacks and troubleshooting:

  • UI Automation is the preferred, robust method when controls expose ValuePattern, InvokePattern, SelectionPattern, etc. Use Inspect.exe (Windows SDK) or Spy++ to discover control types, AutomationIds, and supported patterns.
  • If controls are plain Win32 edit controls, FindWindowEx + SendMessage(WM_SETTEXT) can set text, but custom controls may ignore messages. Some messages that pass pointers will not work cross-process.
  • Automation must run at the same integrity level as the target (elevated target requires elevated automation process). Synchronization matters: wait for input idle and check control availability.
  • Consider modern wrappers (FlaUI, TestStack.White) that simplify UIA usage and provide higher‑level helpers for common tasks.

These steps give a deterministic, inspectable way to set the word into a child control instead of relying on fragile keystroke injection.

Recommended Answers

All 2 Replies

I think what you want to do, is called remoting in .net. Here's the MSDN article on remoting

I did something similar in the past. I had a rather hard time making it works. I suggest the following :
- get the child window handle from the Process object (MainWindowHandle property)
- set this window as the foreground window using SetForegroundWindow (unmanaged function)
- loop until GetForegroundWindow() is true, then use SendKeys to send your message to the child window.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.