How to call Keys shortcuts in UI Automation? /. NETWORK

I am writing a program to automate a win32 form. I am using the Microsoft UI Automation library. I do not know how I can get and call the predefined shortcuts in this form. Now I just get the AutomationElement from the MenuItem and call a click on this element. Any solutions? Does anyone do this?

+4
source share
2 answers

As far as I know, AutomationElementInformation has the AcceleratorKey and AccessKey properties.
Some extracts from MSDN:

AutomationElement :: AutomationElementInformation :: AcceleratorKey
A sequence of keyboard shortcuts that trigger an action associated with an item.

and

AutomationElement :: AutomationElementInformation :: AccessKey
The symbol associated with the item that is used to activate this item.

And after you can use SendKeys to simulate keystrokes.

Another way is to use keybd___event, but AFAIK, it is deprecated, and Microsoft recommends SendInput instead. Maybe this will help you.

+3
source

You should activate the main window and call SendKeys :: Send to send the keys to the active window. This is a static method in the SendKeys class, so when sending keys to a window, there is no need for the main AutomationElement window.

+2
source

All Articles