shredder2794 0 Light Poster

Hello all,
I'm making a WPF automated program using C#.
Sorry if this is a dumb question but how do you invoke a button press on a toolbar(say "File" in any internet browser)?
Heres some of my code:

AutomationElement aeToolsButton = aeForm.FindFirst(TreeScope.Children,
new PropertyCondition(AutomationElement.NameProperty, "Tools"));


InvokePattern ipClickButton1 =
(InvokePattern)aeButton.
GetCurrentPattern(
InvokePattern.Pattern);
ipClickButton1.Invoke();

Whats wrong with this code?
Thanks in advance!

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.