2017-03-19 56 views
3

Skypeプログラム(すべてのチャットタブを含む)のすべての要素を取得しようとしていますが、表示される項目のみを取得します。AutomationElementが不可視要素を取得しない

これは、コードIT:

var window = AutomationElement.RootElement.FindFirst(TreeScope.Subtree, 
       new PropertyCondition(AutomationElement.ClassNameProperty, "tSkMainForm")); 

if (window != null) 
{ 
    var items = window.FindAll(TreeScope.Subtree, Condition.TrueCondition); 
    //DO SOME CODE... 
} 

プロパティは、すべてのunvisibleの項目を(例えば、誰かとのチャットの内側の詳細は、のは、ダンを言わせ)が含まれていないアイテムを。しかし、DanとのチャットがSkypeで開かれている場合、itemsプロパティにはDanとのこのチャットの内部の詳細も含まれます。 タブが自分のSkypeで開かれていなくても、アイテムのプロパティにチャット内部の詳細を設定したいとします。

なぜ私のコードがすべてのデータを取得しないのですか?すべてのデータ(開いていなくてもすべてのチャットタブを含む)を取得するにはどうすればよいですか?あなたは、標準のUIAツール「inspect.exe」を使用する場合

+2

のIScrollProviderインタフェースの実装を使用し、すべてのGRIDCONTROL行を反復処理は、あなたが要素を参照してください(https://msdn.microsoft.com /en-us/library/windows/desktop/dd318521.aspx)? –

答えて

0

GridControlAutomationPeer

private void Button_Click_1(object sender, RoutedEventArgs e) { 
      var p = Process.GetProcessesByName(ProcName).FirstOrDefault(x => x != null); 
      if (p == null) { 
       Console.WriteLine("proccess: {0} was not found", ProcName); return; 
      } 
      var root = AutomationElement.RootElement.FindChildByProcessId(p.Id); 
      AutomationElement devexGridAutomationElement = root.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, DevexGridAutomationId)); 
      if (devexGridAutomationElement == null) { 
       Console.WriteLine("No AutomationElement was found with id: {0}", DevexGridAutomationId); 
       return; 
      } 

      var cond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.DataItem); 
      var devexGridItems = devexGridAutomationElement.FindAll(TreeScope.Descendants, cond); 
      GridPattern gridPat = devexGridAutomationElement.GetCurrentPattern(GridPattern.Pattern) as GridPattern; 
      Console.WriteLine("number of elements in the grid: {0}", gridPat.Current.RowCount); 
     } 
関連する問題