簡體   English   中英

WPF UI自動化查找圖像

[英]WPF UI Automation finding image

嘿,我正在嘗試從WPF應用程序獲取圖像:

在此處輸入圖片說明

如您所見,圖像在樹下

“遠程電話”窗口>“”自定義>“”圖像

我已經找到了有關如何查找文本框和按鈕(以及調用按鈕)的示例,但是我還沒有找到允許我獲取圖像並將其顯示在表單圖片框內的代碼。

LogMessage("Getting RootElement...");
AutomationElement rootElement = AutomationElement.RootElement;

if (rootElement != null)
{
    LogMessage("OK." + Environment.NewLine);

    Automation.Condition condition = new PropertyCondition(AutomationElement.NameProperty, "Remote phone");

    LogMessage("Searching for Remote Phone Window...");
    AutomationElement appElement = rootElement.FindFirst(TreeScope.Children, condition);

    if (appElement != null)
    {
        LogMessage("OK " + Environment.NewLine);
        LogMessage("Searching for Image...");

        AutomationElement txtElementA = GetTextElement(appElement, "image");

        if (txtElementA != null)
          etc..etc...

它發現appElement很好,但是一旦到達txtElementA ,它應該為NULL ,因為它正在尋找GetTextElement而不是圖片/圖像元素。

查找圖像並抓取圖像,然后將其顯示在表單上的圖片框內,正確的代碼是什么?

謝謝!

沒有UI自動化模式可以支持您嘗試執行的操作。 如果查看檢查窗口,則會注意到所有IsXXXPatternAvailable屬性均為false,這意味着所有模式均不可用(IsLegacyIAccessblePatternAvailable除外,但這也無濟於事)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM