Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute button inside a ribbon

Tags:

ribbon

I want to write a script (C# or AutoIT or VBScript.. whatever works) which should

  1. Get reference of already open outlook application

  2. Iterate through ribbons to find a specific button

  3. Execute that button click

How can I do it?

like image 323
helloworld Avatar asked Jul 06 '11 10:07

helloworld


1 Answers

Use AutomationPeers.

Here is the MSDN article with lots of details: http://msdn.microsoft.com/en-us/library/ms752331.aspx

Add references to:

  • UIAutomationClient
  • UIAutomationClientsideProviders
  • UIAutomationProvider
  • UIAutomationTypes

And here is a little C# code snippet of how to get the AutomationId of what currently has focus:

var id = AutomationElement.FocusedElement.Current.AutomationId;
this.txt.Text = id;

You can navigate the entire tree of a window and drive the entire UI using automation peers. This is how accessibility applications interact with applications in Windows. This is also one way that automated UI testing applications do it as well.

like image 64
justin.m.chase Avatar answered Jan 03 '23 14:01

justin.m.chase