xdrp 0.2.1 → 0.2.2
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/xdrp.rb +60 -45
- data.tar.gz.sig +0 -0
- metadata +10 -10
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 617fbc32a4b2adaf234769104583696286e5e9b76f4bf11a0f131e107362c6ca
|
4
|
+
data.tar.gz: 91f2f6c128055b9e895bfb64449d58e0869def96bccf288b81a872a919701119
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eaec277d3c3929b9b1b978510e1357d63125f41ae3138f03f77f1793147df35efc8bfacfd66f19b7fadabf34c9982669e5b79334a9d925f182e92c6edf6f4ba
|
7
|
+
data.tar.gz: d58741546686f94390594a42a8ca0b11fc5e2bac1827392252ac2ca108df7f86e54ed610a0e7ba2ef525fefd0941e587cc74b018e17582bddcbfd6badd3bec8e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/xdrp.rb
CHANGED
@@ -19,22 +19,22 @@ MOUSE = 1
|
|
19
19
|
KEYBOARD = 2
|
20
20
|
KEYBOARD_MOUSE = 3
|
21
21
|
|
22
|
-
|
22
|
+
|
23
23
|
module Xdrp
|
24
24
|
|
25
25
|
class Recorder
|
26
26
|
|
27
27
|
attr_reader :xml
|
28
|
-
|
28
|
+
|
29
29
|
# level:
|
30
30
|
# 1 = mouse
|
31
31
|
# 2 = keyboard
|
32
32
|
# 3 = keyboard + mouse
|
33
33
|
|
34
34
|
def initialize(levelx=KEYBOARD_MOUSE, level: levelx, debug: false)
|
35
|
-
|
35
|
+
|
36
36
|
@mouse, @keyboard = false, false
|
37
|
-
|
37
|
+
|
38
38
|
case level
|
39
39
|
when 1
|
40
40
|
@mouse = true
|
@@ -46,13 +46,13 @@ module Xdrp
|
|
46
46
|
|
47
47
|
|
48
48
|
@xiw = XInputWrapper.new(verbose: true, debug: debug, callback: self)
|
49
|
-
|
49
|
+
|
50
50
|
@wm = WMCtrl.display
|
51
51
|
@win_title = ''
|
52
|
-
|
52
|
+
|
53
53
|
end
|
54
54
|
|
55
|
-
def on_keypress(key, keycode, modifier=nil)
|
55
|
+
def on_keypress(key, keycode, modifier=nil)
|
56
56
|
|
57
57
|
if @debug then
|
58
58
|
puts 'key: ' + key.inspect
|
@@ -61,32 +61,32 @@ module Xdrp
|
|
61
61
|
end
|
62
62
|
|
63
63
|
stop() if modifier and modifier[0] == :alt and key == :z
|
64
|
-
|
65
|
-
return unless @keyboard
|
64
|
+
|
65
|
+
return unless @keyboard
|
66
66
|
|
67
67
|
add_sleep() if Time.now > (@t1 + 2)
|
68
|
-
|
68
|
+
|
69
69
|
|
70
70
|
if @a.length >= 1 and @a[-1][0] == :type then
|
71
71
|
|
72
72
|
if modifier.nil? or (modifier and modifier.empty?) then
|
73
73
|
@a[-1][2] += key.to_s.sub('{space}', ' ')
|
74
74
|
else
|
75
|
-
|
75
|
+
|
76
76
|
if modifier.length < 2 then
|
77
|
-
|
77
|
+
|
78
78
|
if modifier.first == :shift and (keycode.between?(10,21) \
|
79
79
|
or keycode.between?(24,35) \
|
80
80
|
or keycode.between?(38,48)) then
|
81
|
-
|
81
|
+
|
82
82
|
char = if key.to_s =~ /[a-z]/ then
|
83
83
|
key.to_s.upcase
|
84
84
|
elsif key.to_s =~ /[0-9]/
|
85
85
|
%w[) ! " £ $ % ^ & * ( ][key.to_s.to_i]
|
86
86
|
else
|
87
|
-
|
87
|
+
|
88
88
|
lsym = %i(` - = [ ] ; ' # \ , . /)
|
89
|
-
|
89
|
+
|
90
90
|
if lsym.include? key then
|
91
91
|
|
92
92
|
usym = %w(¬ _ + { } : @ ~ | < > ?)
|
@@ -95,14 +95,14 @@ module Xdrp
|
|
95
95
|
end
|
96
96
|
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
@a[-1][2] += char
|
100
|
-
|
100
|
+
|
101
101
|
else
|
102
|
-
@a << [modifier.first, {key: key}]
|
102
|
+
@a << [modifier.first, {key: key}]
|
103
103
|
end
|
104
104
|
end
|
105
|
-
end
|
105
|
+
end
|
106
106
|
|
107
107
|
else
|
108
108
|
|
@@ -123,9 +123,9 @@ module Xdrp
|
|
123
123
|
|
124
124
|
def on_mousedown(button, x, y)
|
125
125
|
|
126
|
-
return unless @mouse
|
127
|
-
monitor_app()
|
128
|
-
|
126
|
+
return unless @mouse
|
127
|
+
monitor_app()
|
128
|
+
|
129
129
|
puts "mouse %s button down at %s, %s" % [button, x, y] if @debug
|
130
130
|
add_sleep() if Time.now > (@t1 + 2)
|
131
131
|
@a << [:mouse, {click: button, x: x, y: y}]
|
@@ -133,7 +133,7 @@ module Xdrp
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def on_mouseup(button, x, y)
|
136
|
-
|
136
|
+
|
137
137
|
return unless @mouse
|
138
138
|
puts "mouse %s button up at %s, %s" % [button, x, y] if @debug
|
139
139
|
end
|
@@ -141,7 +141,7 @@ module Xdrp
|
|
141
141
|
def on_mousemove(x, y)
|
142
142
|
|
143
143
|
return unless @mouse
|
144
|
-
|
144
|
+
|
145
145
|
puts 'mouse is moving at ' + x.to_s + ' y ' + y.to_s if @debug
|
146
146
|
add_sleep() if Time.now > (@t1 + 2)
|
147
147
|
@a << [:mousemove, {x: x, y: y}]
|
@@ -151,7 +151,7 @@ module Xdrp
|
|
151
151
|
def on_mouse_scrolldown()
|
152
152
|
|
153
153
|
return unless @mouse
|
154
|
-
|
154
|
+
|
155
155
|
puts 'mouse is scrolling down' if @debug
|
156
156
|
add_sleep() if Time.now > (@t1 + 2)
|
157
157
|
@a << [:mousewheel, {scroll: 'down'}]
|
@@ -161,32 +161,32 @@ module Xdrp
|
|
161
161
|
def on_mouse_scrollup()
|
162
162
|
|
163
163
|
return unless @mouse
|
164
|
-
|
164
|
+
|
165
165
|
puts 'mouse is scrolling up ' if @debug
|
166
166
|
add_sleep() if Time.now > (@t1 + 2)
|
167
167
|
@a << [:mousewheel, {scroll: 'up'}]
|
168
168
|
|
169
169
|
end
|
170
|
-
|
170
|
+
|
171
171
|
def save(filepath)
|
172
172
|
File.write filepath, xml()
|
173
173
|
end
|
174
174
|
|
175
175
|
def start()
|
176
|
-
|
176
|
+
|
177
177
|
@a = []
|
178
178
|
Thread.new { @xiw.listen }
|
179
179
|
puts 'recording ...'
|
180
180
|
@t1 = Time.now
|
181
|
-
|
181
|
+
|
182
182
|
end
|
183
183
|
|
184
184
|
def stop()
|
185
|
-
|
185
|
+
|
186
186
|
@xiw.stop = true
|
187
187
|
@doc = Rexle.new(['xdrp', {}, '', *@a])
|
188
188
|
puts 'recording stopped'
|
189
|
-
|
189
|
+
|
190
190
|
end
|
191
191
|
|
192
192
|
def xml()
|
@@ -199,21 +199,22 @@ module Xdrp
|
|
199
199
|
@a << [:sleep, {duration: (Time.now - @t1).round}]
|
200
200
|
@t1 = Time.now
|
201
201
|
end
|
202
|
-
|
203
|
-
def monitor_app()
|
204
202
|
|
205
|
-
|
206
|
-
|
203
|
+
def monitor_app()
|
204
|
+
|
205
|
+
win = @wm.windows.find {|x| x.active}
|
206
|
+
|
207
207
|
if win.title != @win_title then
|
208
208
|
@win_title = win.title
|
209
209
|
@a << [:window, {activate: win.title}]
|
210
210
|
end
|
211
|
-
|
211
|
+
|
212
212
|
end
|
213
213
|
|
214
214
|
end
|
215
215
|
|
216
216
|
class Player
|
217
|
+
using ColouredText
|
217
218
|
|
218
219
|
def initialize(src, debug: false)
|
219
220
|
|
@@ -226,8 +227,17 @@ module Xdrp
|
|
226
227
|
def play()
|
227
228
|
|
228
229
|
@doc.root.elements.each do |e|
|
229
|
-
|
230
|
-
|
230
|
+
|
231
|
+
if @debug then
|
232
|
+
puts ('e: ' + e.xml.inspect).debug
|
233
|
+
puts 'e.class: ' + e.class.inspect.debug
|
234
|
+
end
|
235
|
+
|
236
|
+
if e.attributes.any? then
|
237
|
+
method('xdo_' + e.name.to_s).call(**(e.attributes))
|
238
|
+
else
|
239
|
+
method('xdo_' + e.name.to_s).call(e.text)
|
240
|
+
end
|
231
241
|
end
|
232
242
|
|
233
243
|
end
|
@@ -239,17 +249,17 @@ module Xdrp
|
|
239
249
|
end
|
240
250
|
|
241
251
|
def xdo_mouse(click: 'left', x: 0, y: 0)
|
242
|
-
XDo::Mouse.click(x.to_i, y.to_i,
|
252
|
+
XDo::Mouse.click(x.to_i, y.to_i,
|
243
253
|
Object.const_get('XDo::Mouse::' + click.upcase))
|
244
254
|
end
|
245
255
|
|
246
256
|
def xdo_mousemove(x: 0, y: 0)
|
247
257
|
XDo::Mouse.move(x.to_i, y.to_i)
|
248
258
|
end
|
249
|
-
|
259
|
+
|
250
260
|
def xdo_mousewheel(scroll: 'down')
|
251
261
|
XDo::Mouse.wheel(Object.const_get('XDo::Mouse::' + scroll.upcase, 4))
|
252
|
-
end
|
262
|
+
end
|
253
263
|
|
254
264
|
def xdo_sleep(duration: 0)
|
255
265
|
sleep duration.to_f
|
@@ -262,15 +272,20 @@ module Xdrp
|
|
262
272
|
def xdo_type(s)
|
263
273
|
XDo::Keyboard.simulate(s.gsub('{enter}', "\n"))
|
264
274
|
end
|
265
|
-
|
275
|
+
|
266
276
|
def xdo_window(activate: '')
|
267
|
-
|
277
|
+
|
278
|
+
if @debug then
|
279
|
+
puts 'inside xdo_window'
|
280
|
+
puts 'activate: ' + activate.inspect
|
281
|
+
end
|
282
|
+
|
268
283
|
wm = WMCtrl.display
|
269
284
|
window = wm.windows.find {|x| x.title == activate}
|
270
285
|
window.activate
|
271
|
-
|
286
|
+
|
272
287
|
end
|
273
|
-
|
288
|
+
|
274
289
|
|
275
290
|
end
|
276
291
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xdrp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
TiejpssCygWf9HFO3IZRrjH3OzSduilBf7oorCJZqxI5d7KbuK6ceM00aCBJibQO
|
36
36
|
K2bW5QcTuyp9GEliuroid41b
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2021-11-
|
38
|
+
date: 2021-11-16 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: xdo
|
@@ -121,24 +121,24 @@ dependencies:
|
|
121
121
|
name: keystroker
|
122
122
|
requirement: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
|
-
- - ">="
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
version: 0.3.0
|
127
124
|
- - "~>"
|
128
125
|
- !ruby/object:Gem::Version
|
129
126
|
version: '0.3'
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: 0.3.1
|
130
130
|
type: :runtime
|
131
131
|
prerelease: false
|
132
132
|
version_requirements: !ruby/object:Gem::Requirement
|
133
133
|
requirements:
|
134
|
-
- - ">="
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
version: 0.3.0
|
137
134
|
- - "~>"
|
138
135
|
- !ruby/object:Gem::Version
|
139
136
|
version: '0.3'
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 0.3.1
|
140
140
|
description:
|
141
|
-
email:
|
141
|
+
email: digital.robertson@gmail.com
|
142
142
|
executables: []
|
143
143
|
extensions: []
|
144
144
|
extra_rdoc_files: []
|
@@ -156,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
156
|
requirements:
|
157
157
|
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
159
|
+
version: 3.0.2
|
160
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
161
|
requirements:
|
162
162
|
- - ">="
|
metadata.gz.sig
CHANGED
Binary file
|