4

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 element. Any solutions? Does anybody do this?

4

2 に答える 2

3

私の知る限り、AutomationElementInformation にはAcceleratorKeyおよびAccessKeyプロパティがあります。
MSDN からの抜粋:

AutomationElement::AutomationElementInformation::AcceleratorKey
要素に関連付けられたアクションを呼び出す一連のキーの組み合わせ。

と:

AutomationElement::AutomationElementInformation::AccessKey
要素に関連付けられ、その要素をアクティブにするために使用される文字。

その後、SendKeysを使用してキーの押下をシミュレートできます。

別の方法は keybd___event を使用することですが、私の知る限り、これは推奨されておらず、Microsoft は代わりにSendInputを使用することをお勧めしています。それはあなたを助けるかもしれません。

于 2009-09-01T09:22:18.113 に答える
2

メイン ウィンドウをアクティブにし、SendKeys::Send を呼び出してキーをアクティブ ウィンドウに送信する必要があります。これは SendKeys クラスの静的メソッドであるため、メイン ウィンドウの AutomationElement を必要とせずにキーをウィンドウに送信します。

于 2009-09-28T06:04:07.920 に答える