I'm writing program to automate win32 form. I'm using Microsoft UI Automation library. I don't know how I can get and invoke predifined shortcuts key on that form. Now I simply get AutomationElement of the MenuItem and invoke click on that elemnt. Any solutions? Does anybody do this?
As far as I know AutomationElementInformation has an AcceleratorKey and AccessKey properties.
Some extractions from MSDN:
AutomationElement::AutomationElementInformation::AcceleratorKey
The sequence of key combinations that invoke an action associated with the element.
and:
AutomationElement::AutomationElementInformation::AccessKey
The character, associated with an element, that is used to activate that element.
And after you can use SendKeys to simulate key pressings.
Another way is to use keybd___event but, AFAIK, it was deprecated and Microsoft advises to use SendInput instead. May be it will help you.
You should active the main window, and call the SendKeys::Send to send the keys to the active window. It's a static method in SendKeys class, so, send the keys to window no need the main window's AutomationElement.