uia 0.0.9 → 0.1

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
+ === Verions 0.1 / 2013-02-06
2
+ * Enhancements
3
+ * changed #click to be clickable point only
4
+ * added #click_center to try to click in the bounding_rectangle
5
+
1
6
  === Version 0.0.9 / 2014-02-06
2
7
  * Enhancements
3
8
  * Element#focused? and Element#focus
Binary file
Binary file
@@ -21,18 +21,27 @@ namespace UIA.Helper
21
21
  private const uint MOUSEEVENTLF_LEFTDOWN = 0x2;
22
22
  private const uint MOUSEEVENTLF_LEFTUP = 0x4;
23
23
 
24
- public static void MouseClick(AutomationElement element)
24
+ public static void ClickClickablePoint(AutomationElement element)
25
+ {
26
+ Click(element, element.GetClickablePoint());
27
+ }
28
+
29
+ public static void ClickCenter(AutomationElement element)
30
+ {
31
+ Click(element, Center(element));
32
+ }
33
+
34
+ private static void Click(AutomationElement element, Point point)
25
35
  {
26
36
  element.ScrollToIfPossible();
27
37
  element.TryToFocus();
28
38
 
29
- var clickablePoint = ClickablePoint(element);
30
- Cursor.Position = new System.Drawing.Point((int)clickablePoint.X, (int)clickablePoint.Y);
39
+ Cursor.Position = new System.Drawing.Point((int) point.X, (int) point.Y);
31
40
  mouse_event(MOUSEEVENTLF_LEFTDOWN, 0, 0, 0, 0);
32
41
  mouse_event(MOUSEEVENTLF_LEFTUP, 0, 0, 0, 0);
33
42
  }
34
43
 
35
- private static Point ClickablePoint(AutomationElement element)
44
+ private static Point Center(AutomationElement element)
36
45
  {
37
46
  try
38
47
  {
@@ -112,9 +112,14 @@ namespace UIA.Helper
112
112
  get { return Find(TreeScope.Descendants, Condition.TrueCondition); }
113
113
  }
114
114
 
115
- public void MouseClick()
115
+ public void ClickClickablePoint()
116
116
  {
117
- Clicker.MouseClick(_element);
117
+ Clicker.ClickClickablePoint(_element);
118
+ }
119
+
120
+ public void ClickCenter()
121
+ {
122
+ Clicker.ClickCenter(_element);
118
123
  }
119
124
 
120
125
  public static Element From(AutomationElement element)
@@ -136,9 +136,17 @@ extern "C" {
136
136
  }
137
137
  }
138
138
 
139
- __declspec(dllexport) void Element_Click(ElementInformationPtr element, char* errorInfo, const int errorLength) {
139
+ __declspec(dllexport) void Element_ClickClickablePoint(ElementInformationPtr element, char* errorInfo, const int errorLength) {
140
140
  try {
141
- Find(element)->MouseClick();
141
+ Find(element)->ClickClickablePoint();
142
+ } catch(Exception^ error) {
143
+ StringHelper::CopyToUnmanagedString(error->Message, errorInfo, errorLength);
144
+ }
145
+ }
146
+
147
+ __declspec(dllexport) void Element_ClickCenter(ElementInformationPtr element, char* errorInfo, const int errorLength) {
148
+ try {
149
+ Find(element)->ClickCenter();
142
150
  } catch(Exception^ error) {
143
151
  StringHelper::CopyToUnmanagedString(error->Message, errorInfo, errorLength);
144
152
  }
data/lib/uia/element.rb CHANGED
@@ -68,6 +68,11 @@ module Uia
68
68
  true
69
69
  end
70
70
 
71
+ def click_center
72
+ Library.click_center(@element)
73
+ true
74
+ end
75
+
71
76
  def focus
72
77
  Library.focus(@element)
73
78
  end
data/lib/uia/library.rb CHANGED
@@ -70,7 +70,8 @@ module Uia
70
70
  attach_throwable_function :find_child_by_name, :Element_FindChildByName, [:pointer, :string, :string], ManagedElementStruct.by_ref, &element_or_nil
71
71
  elements_from :children, :Element_Children, [:pointer]
72
72
  elements_from :descendants, :Element_Descendants, [:pointer]
73
- attach_throwable_function :click, :Element_Click, [:pointer], :void
73
+ attach_throwable_function :click, :Element_ClickClickablePoint, [:pointer], :void
74
+ attach_throwable_function :click_center, :Element_ClickCenter, [:pointer], :void
74
75
  attach_throwable_function :focus, :Element_Focus, [:pointer], :void
75
76
  attach_throwable_function :refresh, :Element_Refresh, [:pointer], :void
76
77
 
data/lib/uia/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Uia
2
- VERSION = '0.0.9'
2
+ VERSION = '0.1'
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.0.9
4
+ version: '0.1'
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-02-06 00:00:00.000000000 Z
12
+ date: 2014-02-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -249,7 +249,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
249
249
  version: '0'
250
250
  segments:
251
251
  - 0
252
- hash: -154468511
252
+ hash: 258330671
253
253
  required_rubygems_version: !ruby/object:Gem::Requirement
254
254
  none: false
255
255
  requirements:
@@ -258,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
258
  version: '0'
259
259
  segments:
260
260
  - 0
261
- hash: -154468511
261
+ hash: 258330671
262
262
  requirements: []
263
263
  rubyforge_project:
264
264
  rubygems_version: 1.8.24