开发者

Execute button inside a 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜