// 截屏 screenshot('/sdcard/sss.png');
function rtScreenshot(path) {
exeCommand('screenshot', { path: path })
}
// 灭屏
function rtBlacken() {
exeCommand('sleep')
}
// 亮屏
function rtLighten() {
exeCommand('wakeup')
}
stopScreenShot();
// 一般不需要调用,因为开启冰狐后会自动关闭锁屏功能
function rtUnlock() {
exeCommand('unlock')
}
// 按下home
function rtHome() {
exeCommand('home')
}
// 按下power
function rtPower() {
exeCommand('power')
}
// 按下back
function rtBack() {
exeCommand('back')
}
// 停止某个应用程序
function rtStop(packageName) {
exeCommand('stop', { packageName: packageName })
}
// 模拟点击
function rtClick(x, y) {
exeCommand('click1', { x: x, y: y })
}
// 模拟点击
function rtTap(x, y) {
exeCommand('tap', { x: x, y: y })
}
// 模拟点击
function rtSwipe(x1, y1, x2, y2, duration) {
if (undefined == duration) {
duration = 500
}
exeCommand('swipe', { x1: x1, y1: y1, x2: x2, y2: y2, duration: duration })
}
// 长按
function rtLongClick(x, y) {
exeCommand('longClick', { x: x, y: y })
}
// 开启改输入法后才能使用iputText输入中文
function rtEnableIME(enable) {
exeCommand('enableIME', { enable: enable })
}
// 输入文本
function rtInputText(text) {
exeCommand('inputText', { text: text })
}
// 剪切
function rtCut() {
exeCommand('cut')
}
// 拷贝
function rtCopy() {
exeCommand('copy')
}
// 粘贴
function rtPaste() {
exeCommand('paste')
}
// 音量+
function rtVolumeUp() {
exeCommand('valumeUp')
}
// 音量-
function rtVolumeDown() {
exeCommand('valumeDown')
}
// up
function rtUp() {
exeCommand('up')
}
// down
function rtDown() {
exeCommand('down')
}
// left
function rtLeft() {
exeCommand('left')
}
// right
function rtRight() {
exeCommand('right')
}
// ok
function rtOk() {
exeCommand('ok')
}
// enter
function rtEnter() {
exeCommand('enter')
}
// delete
function rtDel() {
exeCommand('delete')
}
// space
function rtSpace() {
exeCommand('space')
}
// tab
function rtTab() {
exeCommand('tab')
}
// key
function rtKey(code) {
exeCommand('key', { keyCode: code })
}
// 执行adb命令
function rtExeAdbCmd(code) {
exeCommand('adbCmd', { code: code })
}
// 开启自定义控件辅助功能
function rtControl() {
exeCommand('control', { enableCustomAccessibility: 1 })
}
// 静默开启无障碍,开启后可以使用使用所有无障碍的功能。静默无障碍和普通的无障碍不一样,静默无障碍一般不会被检测到。如果没有在打包时修改过包名就不用填packageName。
function rtEnableAccessibility(packageName) {
if (strIsEmpty(packageName)) {
packageName = '';
}
exeCommand('enableAccessibility', { enable: true, classPath: packageName + '/com.libra.sar.robot.RobotService' })
}
function exeCommand(cmd, params) {
if (strIsNotEmpty(cmd)) {
var intent = new Intent();
intent.setAction('com.android.smart.ACTION_COMMAND').setPackageName('com.android.settings');
intent.putExtraData('cmd', cmd);
if (params) {
for (var key of params) {
intent.putExtraData(key, params[key]);
}
}
sendBroadcast(intent)
}
}