You can do this using UIAComWrapper , you will need to process this window (where you are trying to copy from) and the information about this element, which you can get from UIAutomationVerify .
var elementCollection = AutomationElement.FromHandle(windowHandle).FindAll(TreeScope.Subtree, Condition.TrueCondition);
foreach (var item in elementCollection)
{
}
Alternatively, instead, Condition.TrueConditionyou can provide a more sophisticated filter to get only one item.
, :
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
const string InternetExplorerClass = "IEFrame";
static void Main()
{
var windowHandle = new IntPtr(0);
windowHandle = FindWindow(InternetExplorerClass, null);
if (!windowHandle.Equals(IntPtr.Zero))
{
var localizedControlType = new PropertyCondition(
AutomationElement.LocalizedControlTypeProperty,
"tab item");
var elementCollection =
AutomationElement.FromHandle(windowHandle)
.FindAll(TreeScope.Subtree, localizedControlType);
foreach (AutomationElement item in elementCollection)
{
Console.WriteLine(item.Current.Name);
}
}
else
{
Console.WriteLine("Internet explorer not found");
}
Console.ReadLine();
}
Internet Explorer . GitHub.