use adb to take screenshot

This commit is contained in:
Lei PAN
2023-10-23 16:44:53 +02:00
parent 8f8e1c5f87
commit a36a9cf7cb
3 changed files with 23 additions and 11 deletions
+10 -3
View File
@@ -83,6 +83,10 @@ class CommandorPage {
async connect_to_browser(ocrResult) { async connect_to_browser(ocrResult) {
console.log("connect_to_browser() called"); console.log("connect_to_browser() called");
if (this.browser === undefined) {
this.isTerminated = true
return
}
console.log("browser.isConnected: " + this.browser.isConnected()); console.log("browser.isConnected: " + this.browser.isConnected());
if (!this.browser.isConnected()) { if (!this.browser.isConnected()) {
this.browser = await puppeteer.connect({ this.browser = await puppeteer.connect({
@@ -980,9 +984,10 @@ class CommandorPage {
await this.checkResultWithOcr(); await this.checkResultWithOcr();
break; break;
case OCRResult.BRAVE_PRIVACY: case OCRResult.BRAVE_PRIVACY:
if (this.device.model() === "MI 5s") if (this.device.model() === "MI 5s") {
await this.device.shell("input tap " + 530 + " " + 970) await this.tapForDevice(this.device, 530, 970)
else if (this.device.model() === "ONEPLUS A6000") // await this.device.shell("input tap " + 530 + " " + 970)
} else if (this.device.model() === "ONEPLUS A6000")
await this.device.shell("input tap " + 530 + " " + 1064) await this.device.shell("input tap " + 530 + " " + 1064)
else if (this.device.model() === "KB2003") else if (this.device.model() === "KB2003")
await this.tapForDevice(this.device, 500, 1200) await this.tapForDevice(this.device, 500, 1200)
@@ -1124,6 +1129,8 @@ class CommandorPage {
this.device.shell("input tap " + 900 + " " + 1532) this.device.shell("input tap " + 900 + " " + 1532)
} else if (this.device.model() === "MI 5s") { } else if (this.device.model() === "MI 5s") {
this.device.shell("input tap " + 925 + " " + 1325) this.device.shell("input tap " + 925 + " " + 1325)
} else if (this.device.model() === "22041219PG") {
this.device.shell("input tap " + 925 + " " + 1430)
} else } else
this.device.shell("input tap " + 933 + " " + 1538) this.device.shell("input tap " + 933 + " " + 1538)
await delay(2000); await delay(2000);
+9 -3
View File
@@ -72,9 +72,15 @@ const BRAVE_SKIP_PRIVACY_PAGE_2 = "Partagez des renseignements"
async function convertImageToWhiteBlack(image_path, device) { async function convertImageToWhiteBlack(image_path, device) {
console.log("convertImageToWhiteBlack for " + device.serial()) console.log("convertImageToWhiteBlack for " + device.serial())
const image = await Jimp.read(image_path); try {
image.grayscale().write(image_path + ".wb"); const image = await Jimp.read(image_path);
return image_path + ".wb"; image.grayscale().write(image_path + ".wb");
return image_path + ".wb";
} catch (e) {
console.log(e)
return image_path
}
} }
class OCRChecker { class OCRChecker {
+4 -5
View File
@@ -29,12 +29,11 @@ class SlidingCaptchaSolver {
} }
async take_screen_shot(name, device) { async take_screen_shot(name, device) {
// let stdout1 = await exec("adb -s " + device.serial() + " shell screencap -p /sdcard/" + name) console.log("will take screenshot for " + device.model() + ":" + device.serial())
console.log("take screenshot " + name); let stdout1 = await exec("adb -s " + device.serial() + " exec-out screencap -p > " + name)
await device.screenshot({path: name}); // await delay(5000);
// let stdout1 = await exec("adb -s " + device.serial() + " exec-out screencap -p > " + name) console.log(`stdout: ${stdout1}`);
await delay(1000); await delay(1000);
// console.log(`stdout: ${stdout1}`);
} }