@@ -9,6 +9,15 @@ var sleep1 = function(t) {
99 sleep ( t + random ( 0 , 80 ) )
1010}
1111
12+ var swipe1 = function ( x1 , y1 , x2 , y2 , duration ) {
13+ const _x1 = x1 + random ( - 10 , 10 )
14+ const _x2 = x2 + random ( - 10 , 10 )
15+ const _y1 = y1 + random ( - 10 , 10 )
16+ const _y2 = y2 + random ( - 10 , 10 )
17+ const _duration = duration + random ( - 100 , 100 )
18+ swipe ( _x1 , _y1 , _x2 , _y2 , _duration )
19+ }
20+
1221var readImage = function ( img ) {
1322 const b = images . read ( img )
1423 return b
@@ -20,11 +29,14 @@ var findButton = function (b, options) {
2029 const threshold = options ? options . threshold || 0.7 : 0.7
2130
2231 for ( let i = 0 ; i < maxTimes ; i ++ ) {
23- const point = findImage ( captureScreen ( ) , b , { threshold : threshold } )
24- if ( point ) {
25- return [ point . x , point . y ]
26- }
27- sleep1 ( interval )
32+ const h = captureScreen ( ) . getHeight ( )
33+ const w = captureScreen ( ) . getWidth ( )
34+ const point = findImage ( captureScreen ( ) , b , { threshold : threshold } )
35+
36+ if ( point ) {
37+ return [ Math . floor ( point . x / h * 1080 ) , Math . floor ( point . y / w * 2340 ) ]
38+ }
39+ sleep1 ( interval )
2840 }
2941 return false
3042}
@@ -41,3 +53,4 @@ exports.sleep = sleep1
4153exports . readImage = readImage
4254exports . findButton = findButton
4355exports . stopExecution = stopExecution
56+ exports . swipe = swipe1
0 commit comments