Update chrome.js

This commit is contained in:
Namhyeon Go 2021-08-14 02:59:42 +09:00 committed by GitHub
parent 44a885788d
commit 93d3a4a8a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -362,7 +362,7 @@ var ChromeObject = function() {
this.terminate = function() { this.terminate = function() {
try { try {
this.oAutoIt.WinKill(this.title); this.oAutoIt.WinKill(this.getTitle());
} catch (e) { } catch (e) {
console.error("ChromeObject.terminate() ->", e.message); console.error("ChromeObject.terminate() ->", e.message);
} }
@ -427,14 +427,14 @@ var ChromeObject = function() {
} }
}; };
this.autoAdjust = function(sX, sY) { this.autoAdjustByScreen = function(sX, sY, divX, divY) {
// catch focus // catch focus
var title = this.focus(); var title = this.focus();
sleep(300); sleep(300);
// adjust window position and size // adjust window position and size
var bX = Math.floor(sX / 6); var bX = Math.floor(sX / divX);
var bY = Math.floor(sY / 3); var bY = Math.floor(sY / divY);
var x = this.getRandomInt(0, bX); var x = this.getRandomInt(0, bX);
var y = this.getRandomInt(0, bY); var y = this.getRandomInt(0, bY);
var w = this.getRandomInt(bX * 3, sX - bX); var w = this.getRandomInt(bX * 3, sX - bX);
@ -444,6 +444,22 @@ var ChromeObject = function() {
// release focus // release focus
this.blur(); this.blur();
}; };
this.autoAdjustByWindow = function(sX, sY, w1, w2, h1, h2) {
// catch focus
var title = this.focus();
sleep(300);
// adjust window position and size
var w = this.getRandomInt(w1, w2);
var h = this.getRandomInt(h1, h2);
var x = this.getRandomInt(0, (sX - w < 0 ? parseInt(sX * 0.2) : (sX - w)));
var y = this.getRandomInt(0, (sY - h < 0 ? parseInt(sY * 0.2) : (sY - h)));
this.oAutoIt.WinMove(title, "", x, y, w, h);
// release focus
this.blur();
};
this.downMouseWheel = function(times) { this.downMouseWheel = function(times) {
if (this.debuggingPort > 0) { if (this.debuggingPort > 0) {