7 changed files with 5491 additions and 121 deletions
File diff suppressed because it is too large
@ -1,10 +1,33 @@ |
|||||
import { DPStarter, DPTask } from './base/base'; |
import { DPStarter, DPTask } from './base/index'; |
||||
|
import { clickForce } from './lib/utils'; |
||||
|
|
||||
class Hongguo extends DPStarter { |
class Hongguo extends DPStarter { |
||||
doInit() { |
doInit() { |
||||
launchApp('com.hongguo.app'); |
console.log('初始化!'); |
||||
|
|
||||
|
makeSure(app.launch('com.phoenix.read'), { |
||||
|
closeBtns: ['android:id/button1'], |
||||
|
landing: [id('di1').text('福利').visibleToUser().selected(false).findOne(1000)] |
||||
|
}); |
||||
|
const widget = id('di1').text('福利').visibleToUser().selected(false).findOne(1000); |
||||
|
widget && clickForce(widget); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
const hongguo = new Hongguo(); |
const hongguo = new Hongguo(); |
||||
|
|
||||
|
const task1 = new DPTask(hongguo); |
||||
|
|
||||
hongguo.start(); |
hongguo.start(); |
||||
|
function makeSure(result: any, options: any) { |
||||
|
if (!result) { |
||||
|
console.log('result is null'); |
||||
|
return; |
||||
|
} |
||||
|
if (options.closeBtns) { |
||||
|
options.closeBtns.forEach((cid: string) => { |
||||
|
const btn = id(cid).findOne(1000); |
||||
|
btn && clickForce(btn); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
@ -0,0 +1,21 @@ |
|||||
|
// 找到控件区域点击
|
||||
|
export function clickForce(ele: UiObject) { |
||||
|
if (!ele) { |
||||
|
console.log('控件不存在'); |
||||
|
return; |
||||
|
} |
||||
|
const bound = ele.bounds(); |
||||
|
const x = bound.centerX(); |
||||
|
const y = bound.centerY(); |
||||
|
click(x, y); |
||||
|
click(x - 1, y + 1); |
||||
|
click(x + 1, y - 1); |
||||
|
} |
||||
|
|
||||
|
export function clickForceXY(x: number, y: number, width: number, height: number) { |
||||
|
width ? (x = x + width / 2) : (x = x + 2); |
||||
|
height ? (y = y + height / 2) : (y = y + 2); |
||||
|
click(x, y); |
||||
|
click(x - 1, y + 1); |
||||
|
click(x + 1, y - 1); |
||||
|
} |
Loading…
Reference in new issue