rautomation 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/History.rdoc +7 -1
  4. data/VERSION +1 -1
  5. data/ext/UiaDll/RAutomation.UIA/Controls/Clicker.cs +59 -0
  6. data/ext/UiaDll/RAutomation.UIA/Controls/SelectList.cs +76 -0
  7. data/ext/UiaDll/RAutomation.UIA/Controls/Spinner.cs +46 -0
  8. data/ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs +54 -0
  9. data/ext/UiaDll/RAutomation.UIA/Controls/TableControl.cs +87 -0
  10. data/ext/UiaDll/RAutomation.UIA/Controls/TextControl.cs +50 -0
  11. data/ext/UiaDll/RAutomation.UIA/Expander.cs +59 -0
  12. data/ext/UiaDll/RAutomation.UIA/Extensions/Element.cs +108 -0
  13. data/ext/UiaDll/RAutomation.UIA/Extensions/Enumerable.cs +63 -0
  14. data/ext/UiaDll/RAutomation.UIA/Extensions/Property.cs +27 -0
  15. data/ext/UiaDll/RAutomation.UIA/Properties/AssemblyInfo.cs +36 -0
  16. data/ext/UiaDll/RAutomation.UIA/Properties/AutomationProperties.cs +18 -0
  17. data/ext/UiaDll/RAutomation.UIA/RAutomation.UIA.csproj +68 -0
  18. data/ext/UiaDll/UiaDll.sln +24 -2
  19. data/ext/UiaDll/UiaDll/ControlMethods.cpp +6 -5
  20. data/ext/UiaDll/UiaDll/DynamicAssemblyResolver.cpp +24 -0
  21. data/ext/UiaDll/UiaDll/DynamicAssemblyResolver.h +16 -0
  22. data/ext/UiaDll/UiaDll/{AutomationFinder.cpp → Locator.cpp} +25 -15
  23. data/ext/UiaDll/UiaDll/{AutomationFinder.h → Locator.h} +4 -2
  24. data/ext/UiaDll/UiaDll/MenuItemSelector.cpp +3 -3
  25. data/ext/UiaDll/UiaDll/MenuMethods.cpp +4 -0
  26. data/ext/UiaDll/UiaDll/SelectListMethods.cpp +40 -21
  27. data/ext/UiaDll/UiaDll/SpinnerMethods.cpp +61 -0
  28. data/ext/UiaDll/UiaDll/StringHelper.cpp +13 -1
  29. data/ext/UiaDll/UiaDll/StringHelper.h +1 -0
  30. data/ext/UiaDll/UiaDll/TabControlMethods.cpp +11 -8
  31. data/ext/UiaDll/UiaDll/TableMethods.cpp +20 -21
  32. data/ext/UiaDll/UiaDll/TextMethods.cpp +19 -17
  33. data/ext/UiaDll/UiaDll/UiaDll.cpp +191 -342
  34. data/ext/UiaDll/UiaDll/UiaDll.vcxproj +11 -21
  35. data/ext/UiaDll/UiaDll/UiaDll.vcxproj.filters +22 -115
  36. data/ext/UiaDll/UiaDll/dllmain.cpp +1 -21
  37. data/ext/UiaDll/UiaDll/stdafx.h +0 -2
  38. data/ext/WindowsForms/WindowsForms/DataEntryForm.Designer.cs +17 -0
  39. data/ext/WindowsForms/WindowsForms/DataEntryForm.cs +2 -6
  40. data/ext/WindowsForms/WindowsForms/MainFormWindow.Designer.cs +6 -7
  41. data/ext/WindowsForms/WindowsForms/MainFormWindow.cs +2 -0
  42. data/ext/WindowsForms/WindowsForms/UIA.Extensions.dll +0 -0
  43. data/ext/WindowsForms/WindowsForms/ValueMonthCalendar.cs +28 -0
  44. data/ext/WindowsForms/WindowsForms/WindowsForms.csproj +5 -4
  45. data/lib/rautomation/adapter/ms_uia.rb +1 -0
  46. data/lib/rautomation/adapter/ms_uia/control.rb +1 -13
  47. data/lib/rautomation/adapter/ms_uia/functions.rb +2 -16
  48. data/lib/rautomation/adapter/ms_uia/list_box.rb +2 -2
  49. data/lib/rautomation/adapter/ms_uia/spinner.rb +31 -0
  50. data/lib/rautomation/adapter/ms_uia/uia_dll.rb +59 -31
  51. data/lib/rautomation/adapter/ms_uia/window.rb +5 -4
  52. data/rautomation.gemspec +1 -0
  53. data/spec/adapter/ms_uia/spinner_spec.rb +44 -0
  54. data/spec/adapter/ms_uia/value_control_spec.rb +2 -2
  55. metadata +26 -25
  56. data/ext/UiaDll/UiaDll/AutomatedSelectList.cpp +0 -93
  57. data/ext/UiaDll/UiaDll/AutomatedSelectList.h +0 -47
  58. data/ext/UiaDll/UiaDll/AutomatedTabControl.cpp +0 -45
  59. data/ext/UiaDll/UiaDll/AutomatedTabControl.h +0 -41
  60. data/ext/UiaDll/UiaDll/AutomatedTable.cpp +0 -92
  61. data/ext/UiaDll/UiaDll/AutomatedTable.h +0 -35
  62. data/ext/UiaDll/UiaDll/AutomatedText.cpp +0 -22
  63. data/ext/UiaDll/UiaDll/AutomatedText.h +0 -26
  64. data/ext/UiaDll/UiaDll/AutomationClicker.cpp +0 -53
  65. data/ext/UiaDll/UiaDll/AutomationClicker.h +0 -30
  66. data/ext/UiaDll/UiaDll/AutomationControl.cpp +0 -40
  67. data/ext/UiaDll/UiaDll/AutomationControl.h +0 -75
  68. data/ext/UiaDll/UiaDll/ExpandCollapseHelper.cpp +0 -53
  69. data/ext/UiaDll/UiaDll/ExpandCollapseHelper.h +0 -25
  70. data/ext/UiaDll/UiaDll/SelectionItem.cpp +0 -10
  71. data/ext/UiaDll/UiaDll/SelectionItem.h +0 -21
  72. data/ext/UiaDll/UiaDll/Toggle.cpp +0 -2
  73. data/ext/UiaDll/UiaDll/Toggle.h +0 -22
  74. data/ext/UiaDll/UiaDll/globals.h +0 -3
  75. data/ext/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs +0 -59
  76. data/ext/WindowsForms/WindowsForms/AutomationHelpers/AutomationProvider.cs +0 -91
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d214593bdd0a96a896107ac65185546ba21fb97
4
- data.tar.gz: 7067fcd4ff5bfdbdd0e3ea57528337de1b3a0003
3
+ metadata.gz: ba425fe2212cdb7f9f34623423af85e658b97977
4
+ data.tar.gz: 3e0b9423dc16e4bfdaa1f6e94d409076dc859ce6
5
5
  SHA512:
6
- metadata.gz: d32f355823ab33e46aa0ee8400dd2771d3c027a5773e4b57271c5af4c8ca6de2178d1fe2a4227b423d5cfa257d5b6ada7177af120d29760826fbf24ca31bb45b
7
- data.tar.gz: 5b84555b5f03746d8d395015a4b521dc676167045af85a4c55ed35d116a3c03212ff22086de3bc2239332e14084ee296eea548a5298de833c1d2112a8b57c7d6
6
+ metadata.gz: 43102aa78240ef7dc3a270ee1037cc8f02cd91c39f795eb362d403da5fc27285c2a390013b397f78d478444adcc8228405fbff71d585a0e5bc744032b55c11a9
7
+ data.tar.gz: d1a8f0f19361f7f26067e8b14513a3c76a1506cef9c1cb33fb26bf1586f4e2706022deb8309e229c1b10fe954901b4e2582eb6c75cbcdaafabb8ee0d708cff3e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rautomation (0.10.0)
4
+ rautomation (0.11.0)
5
5
  ffi
6
6
 
7
7
  GEM
data/History.rdoc CHANGED
@@ -1,4 +1,10 @@
1
- == 0.9.5
1
+ == 0.11.0 / 2013-08-10
2
+
3
+ === MsUia adapter
4
+
5
+ * Add support for Window#spinner
6
+
7
+ == 0.10.0 / 2013-07-26
2
8
 
3
9
  === MsUia adapter
4
10
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.0
1
+ 0.11.0
@@ -0,0 +1,59 @@
1
+ using System;
2
+ using System.Runtime.InteropServices;
3
+ using System.Windows.Automation;
4
+ using System.Windows.Forms;
5
+ using RAutomation.UIA.Extensions;
6
+
7
+ namespace RAutomation.UIA.Controls
8
+ {
9
+ public class Clicker
10
+ {
11
+ [DllImport("user32.dll")]
12
+ static extern void mouse_event(uint flags, uint x, uint y, uint data, int extraInfo);
13
+
14
+ [Flags]
15
+ public enum MouseEvent
16
+ {
17
+ Leftdown = 0x00000002,
18
+ Leftup = 0x00000004,
19
+ }
20
+
21
+ private const uint MOUSEEVENTLF_LEFTDOWN = 0x2;
22
+ private const uint MOUSEEVENTLF_LEFTUP = 0x4;
23
+
24
+ public static bool Click(AutomationElement element)
25
+ {
26
+ try
27
+ {
28
+ if (AutomationElement.IsInvokePatternAvailableProperty.In(element))
29
+ {
30
+ element.As<InvokePattern>(InvokePattern.Pattern).Invoke();
31
+ }
32
+ else if (AutomationElement.IsTogglePatternAvailableProperty.In(element))
33
+ {
34
+ element.AsTogglePattern().Toggle();
35
+ }
36
+ else if (AutomationElement.IsSelectionItemPatternAvailableProperty.In(element))
37
+ {
38
+ element.AsSelectionItem().Select();
39
+ }
40
+
41
+ return true;
42
+ }
43
+ catch (Exception e)
44
+ {
45
+ Console.WriteLine(e);
46
+ return false;
47
+ }
48
+ }
49
+
50
+ public static void MouseClick(AutomationElement element)
51
+ {
52
+ element.SetFocus();
53
+ var clickablePoint = element.GetClickablePoint();
54
+ Cursor.Position = new System.Drawing.Point((int) clickablePoint.X, (int) clickablePoint.Y);
55
+ mouse_event(MOUSEEVENTLF_LEFTDOWN, 0, 0, 0, 0);
56
+ mouse_event(MOUSEEVENTLF_LEFTUP, 0, 0, 0, 0);
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,76 @@
1
+ using System.Collections.Generic;
2
+ using System.Linq;
3
+ using System.Windows.Automation;
4
+ using RAutomation.UIA.Extensions;
5
+ using RAutomation.UIA.Properties;
6
+
7
+ namespace RAutomation.UIA.Controls
8
+ {
9
+ public class SelectList
10
+ {
11
+ private readonly AutomationElement _element;
12
+
13
+ public SelectList(AutomationElement element)
14
+ {
15
+ _element = element;
16
+ }
17
+
18
+ public string[] Options
19
+ {
20
+ get { return SelectionItems.Names().ToArray(); }
21
+ }
22
+
23
+ public int Count
24
+ {
25
+ get { return SelectionItems.Count(); }
26
+ }
27
+
28
+ public int SelectedIndex
29
+ {
30
+ get { return SelectionItems.IndexOf(IsSelected); }
31
+ set { Select(SelectionItems.ElementAt(value)); }
32
+ }
33
+
34
+ public string At(int index)
35
+ {
36
+ return SelectionItems.ElementAt(index).Current.Name;
37
+ }
38
+
39
+ public string Selection
40
+ {
41
+ get
42
+ {
43
+ var selection = SelectionItems.FirstOrDefault(IsSelected);
44
+ return null == selection ? "" : selection.Current.Name;
45
+ }
46
+ set
47
+ {
48
+ Select(SelectionItems.First(x => x.Current.Name == value));
49
+ }
50
+ }
51
+
52
+ private static void Select(AutomationElement element)
53
+ {
54
+ var selectionItem = element.AsSelectionItem();
55
+
56
+ try
57
+ {
58
+ Clicker.MouseClick(element);
59
+ }
60
+ catch { }
61
+
62
+ if (!selectionItem.Current.IsSelected)
63
+ selectionItem.Select();
64
+ }
65
+
66
+ private static bool IsSelected(AutomationElement element)
67
+ {
68
+ return element.AsSelectionItem().Current.IsSelected;
69
+ }
70
+
71
+ private IEnumerable<AutomationElement> SelectionItems
72
+ {
73
+ get { return _element.Find(AutomationProperties.IsSelectionItem); }
74
+ }
75
+ }
76
+ }
@@ -0,0 +1,46 @@
1
+ using System.Windows.Automation;
2
+ using RAutomation.UIA.Extensions;
3
+
4
+ namespace RAutomation.UIA.Controls
5
+ {
6
+ public class Spinner
7
+ {
8
+ private readonly AutomationElement _element;
9
+
10
+ public Spinner(AutomationElement element)
11
+ {
12
+ _element = element;
13
+ }
14
+
15
+ public double Value
16
+ {
17
+ get { return RangeValue.Current.Value; }
18
+ set { RangeValue.SetValue(value); }
19
+ }
20
+
21
+ public double Minimum
22
+ {
23
+ get { return RangeValue.Current.Minimum; }
24
+ }
25
+
26
+ public double Maximum
27
+ {
28
+ get { return RangeValue.Current.Maximum; }
29
+ }
30
+
31
+ public double Increment()
32
+ {
33
+ return Value += RangeValue.Current.SmallChange;
34
+ }
35
+
36
+ public double Decrement()
37
+ {
38
+ return Value -= RangeValue.Current.SmallChange;
39
+ }
40
+
41
+ private RangeValuePattern RangeValue
42
+ {
43
+ get { return _element.As<RangeValuePattern>(RangeValuePattern.Pattern); }
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,54 @@
1
+ using System.Collections.Generic;
2
+ using System.Linq;
3
+ using System.Windows.Automation;
4
+ using RAutomation.UIA.Extensions;
5
+
6
+ namespace RAutomation.UIA.Controls
7
+ {
8
+ public class TabControl
9
+ {
10
+ private readonly AutomationElement _element;
11
+
12
+ public TabControl(AutomationElement element)
13
+ {
14
+ _element = element;
15
+ }
16
+
17
+ public string[] TabNames
18
+ {
19
+ get { return TabItems.Select(x => x.Current.Name).ToArray(); }
20
+ }
21
+
22
+ public string Selection
23
+ {
24
+ get { return TabItems.First(IsSelected).Current.Name; }
25
+ set { TabItems.First(x => x.Current.Name == value).AsSelectionItem().Select(); }
26
+ }
27
+
28
+ public int SelectedIndex
29
+ {
30
+ get { return TabItems.IndexOf(IsSelected); }
31
+ set { SelectionItems.ElementAt(value).Select(); }
32
+ }
33
+
34
+ private static bool IsSelected(AutomationElement tabItem)
35
+ {
36
+ return tabItem.AsSelectionItem().Current.IsSelected;
37
+ }
38
+
39
+ private IEnumerable<AutomationElement> TabItems
40
+ {
41
+ get { return _element.Find(IsTabItem); }
42
+ }
43
+
44
+ private IEnumerable<SelectionItemPattern> SelectionItems
45
+ {
46
+ get { return TabItems.AsSelectionItems(); }
47
+ }
48
+
49
+ private static Condition IsTabItem
50
+ {
51
+ get { return new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TabItem); }
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,87 @@
1
+ using System.Collections.Generic;
2
+ using System.Linq;
3
+ using System.Windows.Automation;
4
+ using RAutomation.UIA.Extensions;
5
+ using RAutomation.UIA.Properties;
6
+
7
+ namespace RAutomation.UIA.Controls
8
+ {
9
+ public class TableControl
10
+ {
11
+ private readonly AutomationElement _element;
12
+
13
+ public TableControl(AutomationElement element)
14
+ {
15
+ _element = element;
16
+ }
17
+
18
+ public int RowCount
19
+ {
20
+ get { return _element.As<TablePattern>(TablePattern.Pattern).Current.RowCount; }
21
+ }
22
+
23
+ public int SelectedIndex
24
+ {
25
+ get { return SelectionItems.IndexOf(x => x.Current.IsSelected); }
26
+ set { DataItems.ElementAt(value).AsSelectionItem().Select(); }
27
+ }
28
+
29
+ public string Value
30
+ {
31
+ set { SelectionElements.First(x => x.Current.Name == value).AsSelectionItem().Select(); }
32
+ }
33
+
34
+ public bool Exists(int row, int column)
35
+ {
36
+ return At(row, column).Exists();
37
+ }
38
+
39
+ public string ValueAt(int row, int column)
40
+ {
41
+ return At(row, column).Current.Name;
42
+ }
43
+
44
+ public AutomationElement At(int row, int column)
45
+ {
46
+ return _element.FindOne(IsTableItem, GridItemPattern.ColumnProperty.Is(column), GridItemPattern.RowProperty.Is(row));
47
+ }
48
+
49
+ public string[] Headers
50
+ {
51
+ get { return _element.Find(ControlType.HeaderItem.Condition()).Select(x => x.Current.Name).ToArray(); }
52
+ }
53
+
54
+ public string[] Values
55
+ {
56
+ get { return TableOrListItems.Select(x => x.Current.Name).ToArray(); }
57
+ }
58
+
59
+ private IEnumerable<SelectionItemPattern> SelectionItems
60
+ {
61
+ get { return SelectionElements.Select(x => x.As<SelectionItemPattern>(SelectionItemPattern.Pattern)); }
62
+ }
63
+
64
+ private IEnumerable<AutomationElement> DataItems
65
+ {
66
+ get
67
+ {
68
+ return _element.Find(AutomationProperties.IsDataItem);
69
+ }
70
+ }
71
+
72
+ private IEnumerable<AutomationElement> SelectionElements
73
+ {
74
+ get { return _element.Find(AutomationProperties.IsSelectionItem); }
75
+ }
76
+
77
+ private IEnumerable<AutomationElement> TableOrListItems
78
+ {
79
+ get { return _element.FindAny(IsTableItem, ControlType.ListItem.Condition()); }
80
+ }
81
+
82
+ private static Condition IsTableItem
83
+ {
84
+ get { return AutomationElement.IsTableItemPatternAvailableProperty.TrueCondition(); }
85
+ }
86
+ }
87
+ }
@@ -0,0 +1,50 @@
1
+ using System.Runtime.Remoting.Services;
2
+ using System.Windows.Automation;
3
+ using System.Windows.Forms;
4
+ using RAutomation.UIA.Extensions;
5
+
6
+ namespace RAutomation.UIA.Controls
7
+ {
8
+ public class TextControl
9
+ {
10
+ private readonly AutomationElement _element;
11
+
12
+ public TextControl(AutomationElement element)
13
+ {
14
+ _element = element;
15
+ }
16
+
17
+ public string Value
18
+ {
19
+ get { return _element.IsValuePattern() ? TextValue : DocumentText; }
20
+ set
21
+ {
22
+ if (_element.IsValuePattern())
23
+ TextValue = value;
24
+ else
25
+ DocumentText = value;
26
+ }
27
+ }
28
+
29
+ private string DocumentText
30
+ {
31
+ get { return _element.AsTextPattern().DocumentRange.GetText(-1); }
32
+ set
33
+ {
34
+ _element.SetFocus();
35
+ Enter("^{HOME}", "^+{END}", "{DEL}", value);
36
+ }
37
+ }
38
+
39
+ private static void Enter(params string[] keys)
40
+ {
41
+ keys.ForEach(SendKeys.SendWait);
42
+ }
43
+
44
+ private string TextValue
45
+ {
46
+ get { return _element.AsValuePattern().Current.Value; }
47
+ set { _element.AsValuePattern().SetValue(value); }
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,59 @@
1
+ using System.Collections.Generic;
2
+ using System.Linq;
3
+ using System.Windows.Automation;
4
+ using RAutomation.UIA.Extensions;
5
+
6
+ namespace RAutomation.UIA
7
+ {
8
+ public class ExpandibleCollapsibleContainer
9
+ {
10
+ protected readonly AutomationElement _element;
11
+
12
+ protected ExpandibleCollapsibleContainer(AutomationElement element)
13
+ {
14
+ _element = element;
15
+ }
16
+
17
+ protected IEnumerable<ExpandCollapsePattern> ExpandCollapsItems
18
+ {
19
+ get { return Elements.Select(x => x.As<ExpandCollapsePattern>(ExpandCollapsePattern.Pattern)); }
20
+ }
21
+
22
+ protected IEnumerable<AutomationElement> Elements
23
+ {
24
+ get { return _element.Find(AutomationElement.IsExpandCollapsePatternAvailableProperty.TrueCondition()); }
25
+ }
26
+ }
27
+
28
+ public class Expander : ExpandibleCollapsibleContainer
29
+ {
30
+ public Expander(AutomationElement element) : base(element)
31
+ {}
32
+
33
+ public void Expand(int index)
34
+ {
35
+ ExpandCollapsItems.ElementAt(index).Expand();
36
+ }
37
+
38
+ public void Expand(string value)
39
+ {
40
+ Elements.FirstOrDefault(x => x.Current.Name == value).As<ExpandCollapsePattern>(ExpandCollapsePattern.Pattern).Expand();
41
+ }
42
+ }
43
+
44
+ public class Collapser : ExpandibleCollapsibleContainer
45
+ {
46
+ public Collapser(AutomationElement element) : base(element)
47
+ {}
48
+
49
+ public void Collapse(int index)
50
+ {
51
+ ExpandCollapsItems.ElementAt(index).Collapse();
52
+ }
53
+
54
+ public void Collapse(string value)
55
+ {
56
+ Elements.FirstOrDefault(x => x.Current.Name == value).As<ExpandCollapsePattern>(ExpandCollapsePattern.Pattern).Collapse();
57
+ }
58
+ }
59
+ }