uia 0.4.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ === Version 0.5 / 2014-05-26
2
+ * Bug Fixes
3
+ * fixed issue #5 where finding by runtime_id was not working on Windows 8
4
+ machines
5
+
1
6
  === Version 0.4.4 / 2014-05-23
2
7
  * Enhancements
3
8
  * modified how it uses the runtime_id to locate an element to use the
@@ -1,7 +1,7 @@
1
1
  using System;
2
2
  using System.Collections.Generic;
3
+ using System.ComponentModel;
3
4
  using System.Linq;
4
- using System.Runtime.InteropServices;
5
5
  using System.Windows.Automation;
6
6
 
7
7
  namespace UIA.Helper
@@ -10,10 +10,6 @@ namespace UIA.Helper
10
10
  {
11
11
  private readonly AutomationElement _element;
12
12
 
13
- [DllImport("user32")]
14
- [return: MarshalAs(UnmanagedType.Bool)]
15
- static extern bool IsWindow(IntPtr hWnd);
16
-
17
13
  protected Element()
18
14
  {
19
15
  }
@@ -186,13 +182,19 @@ namespace UIA.Helper
186
182
  public static Element ByRuntimeId(int[] runtimeId)
187
183
  {
188
184
  var condition = new PropertyCondition(AutomationElement.RuntimeIdProperty, runtimeId);
189
- return ClosestParentOfId(runtimeId).FindFirst(TreeScope.Subtree, condition);
185
+
186
+ Element foundElement = null;
187
+ PotentialParentsOf(runtimeId)
188
+ .FirstOrDefault(x => null != (foundElement = x.FindFirst(TreeScope.Subtree, condition)));
189
+
190
+ return foundElement;
190
191
  }
191
192
 
192
- private static Element ClosestParentOfId(IEnumerable<int> runtimeId)
193
+ private static IEnumerable<Element> PotentialParentsOf(IEnumerable<int> runtimeId)
193
194
  {
194
- var parentHandle = runtimeId.FirstOrDefault(x => IsWindow(x.IntPtr())).IntPtr();
195
- return IntPtr.Zero != parentHandle ? ByHandle(parentHandle) : new RootElement();
195
+ return runtimeId.Where(x => Win32.IsWindow(x.IntPtr()))
196
+ .Select(x => ByHandle(x.IntPtr()))
197
+ .Concat(new[] {new RootElement()});
196
198
  }
197
199
 
198
200
  private static Element[] Find(AutomationElement element, TreeScope scope, Condition condition)
@@ -50,6 +50,7 @@
50
50
  <Compile Include="Element.cs" />
51
51
  <Compile Include="Extensions.cs" />
52
52
  <Compile Include="Properties\AssemblyInfo.cs" />
53
+ <Compile Include="Win32.cs" />
53
54
  </ItemGroup>
54
55
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
55
56
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -0,0 +1,12 @@
1
+ using System;
2
+ using System.Runtime.InteropServices;
3
+
4
+ namespace UIA.Helper
5
+ {
6
+ class Win32
7
+ {
8
+ [DllImport("user32")]
9
+ [return: MarshalAs(UnmanagedType.Bool)]
10
+ public static extern bool IsWindow(IntPtr hWnd);
11
+ }
12
+ }
@@ -1,3 +1,3 @@
1
1
  module Uia
2
- VERSION = '0.4.4'
2
+ VERSION = '0.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: '0.5'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-23 00:00:00.000000000 Z
12
+ date: 2014-05-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -145,6 +145,7 @@ files:
145
145
  - ext/UiaDll/UIA.Helper/Mouse.cs
146
146
  - ext/UiaDll/UIA.Helper/Properties/AssemblyInfo.cs
147
147
  - ext/UiaDll/UIA.Helper/UIA.Helper.csproj
148
+ - ext/UiaDll/UIA.Helper/Win32.cs
148
149
  - ext/UiaDll/UiaDll.Test/AssemblyInfo.cpp
149
150
  - ext/UiaDll/UiaDll.Test/ElementInformationTest.cpp
150
151
  - ext/UiaDll/UiaDll.Test/ElementStub.h
@@ -262,7 +263,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
262
263
  version: '0'
263
264
  segments:
264
265
  - 0
265
- hash: -945145251
266
+ hash: -806601741
266
267
  required_rubygems_version: !ruby/object:Gem::Requirement
267
268
  none: false
268
269
  requirements:
@@ -271,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
272
  version: '0'
272
273
  segments:
273
274
  - 0
274
- hash: -945145251
275
+ hash: -806601741
275
276
  requirements: []
276
277
  rubyforge_project:
277
278
  rubygems_version: 1.8.28