AXElements 1.0.0.alpha3 → 1.0.0.alpha4
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/accessibility/core/core.c +26 -0
- data/ext/accessibility/key_coder/key_coder.c +4 -2
- data/lib/accessibility/dsl.rb +13 -0
- data/lib/accessibility/version.rb +1 -1
- data/lib/mouse.rb +66 -26
- metadata +5 -4
@@ -0,0 +1,26 @@
|
|
1
|
+
/*
|
2
|
+
* key_coder.c
|
3
|
+
* KeyCoder
|
4
|
+
*
|
5
|
+
* Created by Mark Rada on 11-07-27.
|
6
|
+
* Copyright 2011-2012 Marketcircle Incorporated. All rights reserved.
|
7
|
+
*/
|
8
|
+
|
9
|
+
|
10
|
+
#import <Cocoa/Cocoa.h>
|
11
|
+
#import <Carbon/Carbon.h>
|
12
|
+
#import <ApplicationServices/ApplicationServices.h>
|
13
|
+
|
14
|
+
#include "ruby.h"
|
15
|
+
|
16
|
+
|
17
|
+
void
|
18
|
+
ax_callback()
|
19
|
+
{
|
20
|
+
}
|
21
|
+
|
22
|
+
|
23
|
+
void
|
24
|
+
Init_core()
|
25
|
+
{
|
26
|
+
}
|
@@ -26,7 +26,8 @@
|
|
26
26
|
* @return [Hash{String=>Number}]
|
27
27
|
*/
|
28
28
|
|
29
|
-
static
|
29
|
+
static
|
30
|
+
VALUE
|
30
31
|
keycoder_dynamic_mapping()
|
31
32
|
{
|
32
33
|
|
@@ -91,7 +92,8 @@ keycoder_dynamic_mapping()
|
|
91
92
|
* @return [true]
|
92
93
|
*/
|
93
94
|
|
94
|
-
static
|
95
|
+
static
|
96
|
+
VALUE
|
95
97
|
keycoder_post_event(VALUE self, VALUE event)
|
96
98
|
{
|
97
99
|
VALUE code = rb_ary_entry(event, 0);
|
data/lib/accessibility/dsl.rb
CHANGED
@@ -581,6 +581,19 @@ module Accessibility::DSL
|
|
581
581
|
sleep wait
|
582
582
|
end
|
583
583
|
|
584
|
+
##
|
585
|
+
# Perform a triple click action
|
586
|
+
#
|
587
|
+
# If an argument is provided then the mouse will move to that point
|
588
|
+
# first; the argument must respond to `#to_point`.
|
589
|
+
#
|
590
|
+
# @param obj [#to_point]
|
591
|
+
def triple_click obj = nil, wait = 0.2
|
592
|
+
move_mouse_to obj, wait: 0 if obj
|
593
|
+
Mouse.triple_click
|
594
|
+
sleep wait
|
595
|
+
end
|
596
|
+
|
584
597
|
|
585
598
|
# @!group Debug Helpers
|
586
599
|
|
data/lib/mouse.rb
CHANGED
@@ -15,7 +15,7 @@ module Mouse
|
|
15
15
|
extend self
|
16
16
|
|
17
17
|
##
|
18
|
-
# Number of animation steps per second
|
18
|
+
# Number of animation steps per second
|
19
19
|
#
|
20
20
|
# @return [Number]
|
21
21
|
FPS = 120
|
@@ -24,13 +24,13 @@ module Mouse
|
|
24
24
|
# @note We keep the number as a rational to try and avoid rounding
|
25
25
|
# error introduced by the floats, especially MacRuby floats.
|
26
26
|
#
|
27
|
-
# Smallest unit of time allowed for an animation step
|
27
|
+
# Smallest unit of time allowed for an animation step
|
28
28
|
#
|
29
29
|
# @return [Number]
|
30
30
|
QUANTUM = Rational(1, FPS)
|
31
31
|
|
32
32
|
##
|
33
|
-
# Available constants for the type of units to use when scrolling
|
33
|
+
# Available constants for the type of units to use when scrolling
|
34
34
|
#
|
35
35
|
# @return [Hash{Symbol=>Fixnum}]
|
36
36
|
UNIT = {
|
@@ -40,7 +40,9 @@ module Mouse
|
|
40
40
|
|
41
41
|
##
|
42
42
|
# The coordinates of the mouse using the flipped coordinate system
|
43
|
-
#
|
43
|
+
#
|
44
|
+
# Flipped coordinates have the origin in top left corner of the
|
45
|
+
# primary screen.
|
44
46
|
#
|
45
47
|
# @return [CGPoint]
|
46
48
|
def current_position
|
@@ -48,7 +50,7 @@ module Mouse
|
|
48
50
|
end
|
49
51
|
|
50
52
|
##
|
51
|
-
# Move the mouse from the current position to the given point
|
53
|
+
# Move the mouse from the current position to the given point
|
52
54
|
#
|
53
55
|
# @param point [CGPoint]
|
54
56
|
# @param duration [Float] animation duration, in seconds
|
@@ -57,7 +59,7 @@ module Mouse
|
|
57
59
|
end
|
58
60
|
|
59
61
|
##
|
60
|
-
# Click and drag from the current position to the given point
|
62
|
+
# Click and drag from the current position to the given point
|
61
63
|
#
|
62
64
|
# @param point [CGPoint]
|
63
65
|
# @param duration [Float] animation duration, in seconds
|
@@ -72,15 +74,17 @@ module Mouse
|
|
72
74
|
##
|
73
75
|
# @todo Need to double check to see if I introduce any inaccuracies.
|
74
76
|
#
|
75
|
-
# Scroll at the current position the given amount of units
|
77
|
+
# Scroll at the current position the given amount of units
|
76
78
|
#
|
77
79
|
# Scrolling too much or too little in a period of time will cause the
|
78
80
|
# animation to look weird, possibly causing the app to mess things up.
|
79
81
|
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
# @param
|
82
|
+
# A positive `amonut` to scroll will scroll up and a negative `amount`
|
83
|
+
# will scroll down.
|
84
|
+
#
|
85
|
+
# @param amount [Fixnum] number of units to scroll
|
86
|
+
# @param duration [Float] in seconds
|
87
|
+
# @param units [Symbol] must be either `:line` or `:pixel`
|
84
88
|
def scroll amount, duration = 0.2, units = :line
|
85
89
|
units = UNIT[units] || raise(ArgumentError, "#{units} is not a valid unit")
|
86
90
|
steps = (FPS * duration).round
|
@@ -95,8 +99,11 @@ module Mouse
|
|
95
99
|
end
|
96
100
|
|
97
101
|
##
|
98
|
-
#
|
99
|
-
#
|
102
|
+
# @api semipublic
|
103
|
+
#
|
104
|
+
# Perform a down click
|
105
|
+
#
|
106
|
+
# You should follow this up with a call to {#click_up} to finish the click.
|
100
107
|
#
|
101
108
|
# @param point [CGPoint]
|
102
109
|
# @param duration [Number]
|
@@ -107,8 +114,12 @@ module Mouse
|
|
107
114
|
end
|
108
115
|
|
109
116
|
##
|
110
|
-
#
|
111
|
-
#
|
117
|
+
# @api semipublic
|
118
|
+
#
|
119
|
+
# Perform an up click
|
120
|
+
#
|
121
|
+
# This should only be called after a call to {#click_down} to finish
|
122
|
+
# the click event.
|
112
123
|
#
|
113
124
|
# @param point [CGPoint]
|
114
125
|
def click_up point = current_position
|
@@ -117,10 +128,12 @@ module Mouse
|
|
117
128
|
end
|
118
129
|
|
119
130
|
##
|
120
|
-
# Standard secondary click
|
131
|
+
# Standard secondary click, sometimes called a "right click"
|
132
|
+
#
|
133
|
+
# Default position is the current position.
|
121
134
|
#
|
122
135
|
# @param point [CGPoint]
|
123
|
-
# @param duration [Number]
|
136
|
+
# @param duration [Number] in seconds
|
124
137
|
def secondary_click point = current_position, duration = 12
|
125
138
|
event = new_event KCGEventRightMouseDown, point, KCGMouseButtonRight
|
126
139
|
post event
|
@@ -131,16 +144,21 @@ module Mouse
|
|
131
144
|
alias_method :right_click, :secondary_click
|
132
145
|
|
133
146
|
##
|
134
|
-
#
|
147
|
+
# @api semipublic
|
148
|
+
#
|
149
|
+
# Generate a multi click event at the given position
|
150
|
+
#
|
151
|
+
# `num_clicks` is the number of clicks for the event, where a value of `2'
|
152
|
+
# corresponds to a double click, `3` corresponds to a triple click, etc.
|
153
|
+
#
|
154
|
+
# However, I've only tested with a double and triple click, for which you
|
155
|
+
# can just call {#double_click} and {#triple_click} instead.
|
135
156
|
#
|
157
|
+
# @param num_clicks [Fixnum]
|
136
158
|
# @param point [CGPoint]
|
137
|
-
def
|
159
|
+
def multi_click num_clicks, point = current_position
|
138
160
|
event = new_event KCGEventLeftMouseDown, point, KCGMouseButtonLeft
|
139
|
-
|
140
|
-
set_type event, KCGEventLeftMouseUp
|
141
|
-
post event
|
142
|
-
|
143
|
-
CGEventSetIntegerValueField(event, KCGMouseEventClickState, 2)
|
161
|
+
CGEventSetIntegerValueField(event, KCGMouseEventClickState, num_clicks)
|
144
162
|
set_type event, KCGEventLeftMouseDown
|
145
163
|
post event
|
146
164
|
set_type event, KCGEventLeftMouseUp
|
@@ -148,8 +166,30 @@ module Mouse
|
|
148
166
|
end
|
149
167
|
|
150
168
|
##
|
151
|
-
#
|
152
|
-
#
|
169
|
+
# A standard double click
|
170
|
+
#
|
171
|
+
# Defaults to clicking at the current position.
|
172
|
+
#
|
173
|
+
# @param point [CGPoint]
|
174
|
+
def double_click point = current_position
|
175
|
+
multi_click 2, point
|
176
|
+
end
|
177
|
+
|
178
|
+
##
|
179
|
+
# A standard triple click
|
180
|
+
#
|
181
|
+
# Defaults to clicking at the current position.
|
182
|
+
#
|
183
|
+
# @param point [CGPoint]
|
184
|
+
def triple_click point = current_position
|
185
|
+
multi_click 3, point
|
186
|
+
end
|
187
|
+
|
188
|
+
##
|
189
|
+
# Click with an arbitrary mouse button
|
190
|
+
#
|
191
|
+
# Numbers are used to map the mouse buttons. At the time of writing,
|
192
|
+
# the documented values are:
|
153
193
|
#
|
154
194
|
# - KCGMouseButtonLeft = 0
|
155
195
|
# - KCGMouseButtonRight = 1
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: AXElements
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 1.0.0.
|
5
|
+
version: 1.0.0.alpha4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mark Rada
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-27 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -19,14 +19,14 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 4.3.1
|
23
23
|
type: :development
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 4.3.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: yard
|
32
32
|
prerelease: false
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/mouse.rb
|
111
111
|
- lib/rspec/expectations/ax_elements.rb
|
112
112
|
- ext/accessibility/key_coder/extconf.rb
|
113
|
+
- ext/accessibility/core/core.c
|
113
114
|
- ext/accessibility/key_coder/key_coder.c
|
114
115
|
- rakelib/doc.rake
|
115
116
|
- rakelib/ext.rake
|