-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.js
60 lines (57 loc) · 1.46 KB
/
util.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// const ocr = $plugins.load("com.hraps.ocr")
const ra = new RootAutomator()
events.on('exit', () => {
ra.exit()
})
module.exports = {
/*
wordOcr: function (img) {
let ocrResults = ocr.detect(img.getBitmap(), 1)
ocrResults = ocr.filterScore(ocrResults, 0.5, 0.5, 0.5)
if (ocrResults.size() === 1) {
let ocrResult = ocrResults.get(0).text
console.log('ocr result: ' + ocrResult)
return ocrResult
}
return null
},
*/
tap: function () {
let duration = random(350, 400)
if (arguments.length === 1) {
let pos = arguments[0]
ra.press(
pos.x,
pos.y,
duration
)
sleep(duration)
}
else if (arguments.length === 2) {
ra.press(
arguments[0],
arguments[1],
duration
)
sleep(duration)
}
},
randomTap: function (x, y, dx, dy) {
let duration = random(350, 400)
ra.press(
random(x, x + dx),
random(y, y + dy),
duration
)
sleep(duration)
},
absRandomTap: function (x, y, x1, y1) {
let duration = random(350, 400)
ra.press(
random(x, x1),
random(y, y1),
duration
)
sleep(duration)
}
}