0

私はメトロアプリを持っています。自動化クライアントを開発しています。メトロアプリのすべての要素を一覧表示したい。

  1. IApplicationActivationManagerを介してメトロアプリを起動しています
  2. 焦点を絞った要素を取得しています

    HRESULT hr = Automation-> GetRootElement(&pRoot);
    hr=自動化->GetFocusedElement(&pFound);

今、私はボタン、画像要素、その他のようなすべてのコントロールをリストしたかった

自動化インターフェースのFindAllを使用して要素を取得しています。

    // Create a property condition for the button control type.   
    VARIANT varProp;  
    varProp.vt = VT_I4;  
    varProp.lVal = UIA_ButtonControlTypeId;  
    hr = automation->CreatePropertyCondition(UIA_ControlTypePropertyId, varProp, &pButtonCondition);   

    if (pButtonCondition == NULL)
        goto cleanup;

    // Create a property condition for the enabled property.
    varProp.vt = VT_BOOL;
    varProp.boolVal = VARIANT_TRUE;
    hr = automation->CreatePropertyCondition(UIA_IsEnabledPropertyId, varProp, &pEnabledCondition);
    if (pEnabledCondition == NULL)
        goto cleanup;


    // Combine the conditions.
    hr = automation->CreateAndCondition(pButtonCondition, pEnabledCondition, &pCombinedCondition);
    if (pCombinedCondition == NULL)
        goto cleanup;

    // Find the matching elements. Note that if the scope is changed to TreeScope_Descendants, 
    // system buttons on the caption bar will be found as well.
    hr = pParent->FindAll(TreeScope_Children, pCombinedCondition, &pFound);

メトロアプリにあるこの唯一のリストボタン。ウィンドウ上のすべてのコントロールを一覧表示したかったのです。
これを手伝ってください。メトロアプリのすべての要素を取得するにはどうすればよいですか?

4

1 に答える 1

1

私はそれを見つけます......真の条件を使用すると、UI上のすべての要素を見つけることができます

IUIAutomationCondition* pCombinedCondition = NULL;
 hr = automation->CreateTrueCondition(&pCombinedCondition);
if (pCombinedCondition == NULL)
    goto cleanup;
// Find the matching elements. Note that if the scope is changed to TreeScope_Descendants, 
// system buttons on the caption bar will be found as well.
hr = pParent->FindAll(TreeScope_Children,pCombinedCondition , &pFound);
于 2012-08-07T09:25:27.440 に答える