µÚÒ»¸ö£¬¼üÊóHIDËæ»úµã»÷Àý×Ó
const ¼üÊó = {};
¼üÊó.µã»÷ = function (x, y) {
if (typeof x === "undefined") return false;
if (typeof y === "undefined") return false;
return hid.click(x, y);
}
¼üÊó.Ëæ»úµã»÷ = function (x, y, random) {
if (typeof x === "undefined") return false;
if (typeof y === "undefined") return false;
let random_s = random || 10;
let x_w = x + rand.randNumber(-random_s, random_s);
let y_h = y + rand.randNumber(-random_s, random_s);
return hid.click(x_w, y_h);
}
¼üÊó.Ëæ»úµã»÷(100, 200, 5);
ÒÔÏÂÊǶÔÄãÌṩµÄ´úÂëµÄÏêϸ½âÊÍ£º
const ¼üÊó = {};
ÕâÐдúÂ붨ÒåÁËÒ»¸ö³£Á¿ ¼üÊó
£¬²¢½«Æä³õʼ»¯ÎªÒ»¸ö¿Õ¶ÔÏó¡£¼üÊó
¶ÔÏó½«ÓÃÓÚ´æ´¢Óë HID ¼üÊó²Ù×÷Ïà¹ØµÄ·½·¨¡£
¼üÊó.µã»÷ = function (x, y) {
if (typeof x === "undefined") return false;
if (typeof y === "undefined") return false;
return hid.click(x, y);
}
ÕâÐдúÂëΪ ¼üÊó
¶ÔÏóÌí¼ÓÁËÒ»¸öÃûΪ µã»÷
µÄ·½·¨¡£¸Ã·½·¨½ÓÊÜÁ½¸ö²ÎÊý x
ºÍ y
£¬·Ö±ð´ú±íµã»÷µÄλÖõĺáÏò×ø±êºÍ×ÝÏò×ø±ê¡£
if (typeof x === "undefined") return false;
£º¼ì²é²ÎÊý x
ÊÇ·ñ䶨Ò壬Èç¹ûÊÇ£¬Ôò·µ»Ø false
±íʾµã»÷ʧ°Ü¡£if (typeof y === "undefined") return false;
£º¼ì²é²ÎÊý y
ÊÇ·ñ䶨Ò壬Èç¹ûÊÇ£¬Ôò·µ»Ø false
±íʾµã»÷ʧ°Ü¡£return hid.click(x, y);
£ºµ÷Óà hid
¶ÔÏóµÄ click
·½·¨£¬²¢½« x
ºÍ y
×÷Ϊ²ÎÊý´«µÝ¸øËü¡£hid.click(x, y)
µÄ·µ»ØÖµ½«×÷Ϊ ¼üÊó.µã»÷
·½·¨µÄ·µ»ØÖµ¡£
¼üÊó.Ëæ»úµã»÷ = function (x, y, random) {
if (typeof x === "undefined") return false;
if (typeof y === "undefined") return false;
let random_s = random || 10;
let x_w = x + rand.randNumber(-random_s, random_s);
let y_h = y + rand.randNumber(-random_s, random_s);
return hid.click(x_w, y_h);
}
ÕâÐдúÂëΪ ¼üÊó
¶ÔÏóÌí¼ÓÁËÒ»¸öÃûΪ Ëæ»úµã»÷
µÄ·½·¨¡£¸Ã·½·¨½ÓÊÜÈý¸ö²ÎÊý x
¡¢y
ºÍ random
£¬·Ö±ð´ú±íµã»÷µÄλÖõĺáÏò×ø±ê¡¢×ÝÏò×ø±êºÍËæ»úÆ«ÒÆÖµ¡£
if (typeof x === "undefined") return false;
£º¼ì²é²ÎÊý x
ÊÇ·ñ䶨Ò壬Èç¹ûÊÇ£¬Ôò·µ»Ø false
±íʾµã»÷ʧ°Ü¡£if (typeof y === "undefined") return false;
£º¼ì²é²ÎÊý y
ÊÇ·ñ䶨Ò壬Èç¹ûÊÇ£¬Ôò·µ»Ø false
±íʾµã»÷ʧ°Ü¡£let random_s = random || 10;
£ºÈç¹û random
²ÎÊý䶨Ò壬ÔòʹÓÃĬÈÏÖµ 10
¡£let x_w = x + rand.randNumber(-random_s, random_s);
£ºÉú³ÉÒ»¸öÔÚ x - random_s
ºÍ x + random_s
Ö®¼äµÄËæ»úÊý£¬²¢½«Æä¼Óµ½ x
ÉÏ£¬µÃµ½ÐµĺáÏò×ø±ê x_w
¡£let y_h = y + rand.randNumber(-random_s, random_s);
£ºÉú³ÉÒ»¸öÔÚ y - random_s
ºÍ y + random_s
Ö®¼äµÄËæ»úÊý£¬²¢½«Æä¼Óµ½ y
ÉÏ£¬µÃµ½ÐµÄ×ÝÏò×ø±ê y_h
¡£return hid.click(x_w, y_h);
£ºµ÷Óà hid
¶ÔÏóµÄ click
·½·¨£¬²¢½«¼ÆËãµÃµ½µÄËæ»úµã»÷λÖà x_w
ºÍ y_h
×÷Ϊ²ÎÊý´«µÝ¸øËü¡£hid.click(x_w, y_h)
µÄ·µ»ØÖµ½«×÷Ϊ ¼üÊó.Ëæ»úµã»÷
·½·¨µÄ·µ»ØÖµ¡£
// ʾÀýµ÷ÓÃËæ»úµã»÷·½·¨
¼üÊó.Ëæ»úµã»÷(100, 200, 5);
ÕâÐдúÂëʾÀýµ÷ÓÃÁË ¼üÊó.Ëæ»úµã»÷
·½·¨£¬²¢´«Èë²ÎÊý 100
£¨ºáÏò×ø±ê£©¡¢200
£¨×ÝÏò×ø±ê£©ºÍ 5
£¨Ëæ»úÆ«ÒÆÖµ£©¡£ÕâÒâζ×ŵã»÷µÄλÖý«ÔÚ (95, 195)
µ½ (105, 205)
Ö®¼äµÄij¸öËæ»úλÖá£
µÚ¶þ¸ö£¬HID¼üÊóģʽ-Ëæ»ú°Ù·Ö±Èµã»÷
const ¼üÊó = {};
¼üÊó.Ëæ»ú°Ù·Ö±Èµã»÷ = function (x, y, random) {
if (typeof x === "undefined") return false;
if (typeof y === "undefined") return false;
let random_w = random || 10;
let w = screen.widthToPercent(random_w);
let h = screen.heightToPercent(random_w);
let x_p = x + rand.randDoubleNumber(-w, w);
let y_p = y + rand.randDoubleNumber(-h, h);
return hid.clickPercent(x_p, y_p);
}
¼üÊó.Ëæ»ú°Ù·Ö±Èµã»÷(50.0, 50.0, 5);
¼üÊó
¶ÔÏó¶¨Ò壺
const ¼üÊó = {};
* ÕâÐдúÂ붨ÒåÁËÒ»¸ö³£Á¿ `¼üÊó`£¬²¢½«Æä³õʼ»¯ÎªÒ»¸ö¿Õ¶ÔÏó¡£`¼üÊó` ¶ÔÏó½«ÓÃÓÚ´æ´¢Óë HID ¼üÊó²Ù×÷Ïà¹ØµÄ·½·¨¡£
¼üÊó.Ëæ»ú°Ù·Ö±Èµã»÷
·½·¨£º
¼üÊó.Ëæ»ú°Ù·Ö±Èµã»÷ = function (x, y, random) {
if (typeof x === "undefined") return false;
if (typeof y === "undefined") return false;
let random_w = random || 10;
let w = screen.widthToPercent(random_w);
let h = screen.heightToPercent(random_w);
let x_p = x + rand.randDoubleNumber(-w, w);
let y_p = y + rand.randDoubleNumber(-h, h);
return hid.clickPercent(x_p, y_p);
}
* **²ÎÊý¼ì²é**£º
if (typeof x === "undefined") return false;
if (typeof y === "undefined") return false;
* ¼ì²é²ÎÊý `x` ºÍ `y` ÊÇ·ñ䶨Ò壬Èç¹ûÊÇÔò·µ»Ø `false` ±íʾµã»÷ʧ°Ü¡£
* **Ëæ»úÆ«ÒÆÖµ´¦Àí**£º
let random_w = random || 10;
* Èç¹û `random` ²ÎÊý䶨Ò壬ÔòʹÓÃĬÈÏÖµ `10`¡£
* **°Ù·Ö±ÈÆ«ÒÆÖµ¼ÆËã**£º
let w = screen.widthToPercent(random_w);
let h = screen.heightToPercent(random_w);
* µ÷Óà `screen.widthToPercent(random_w)` ºÍ `screen.heightToPercent(random_w)` ·½·¨£¬½«Ëæ»úÆ«ÒÆÖµ `random_w` ת»»ÎªÆÁÄ»¿í¶ÈºÍ¸ß¶ÈµÄ°Ù·Ö±È¡£
* **Ëæ»úµã»÷λÖüÆËã**£º
let x_p = x + rand.randDoubleNumber(-w, w);
let y_p = y + rand.randDoubleNumber(-h, h);
* Éú³ÉÒ»¸öÔÚ `x - w` ºÍ `x + w` Ö®¼äµÄËæ»ú¸¡µãÊý£¬²¢½«Æä¼Óµ½ `x` ÉÏ£¬µÃµ½ÐµİٷֱȺáÏò×ø±ê `x_p`¡£
* Éú³ÉÒ»¸öÔÚ `y - h` ºÍ `y + h` Ö®¼äµÄËæ»ú¸¡µãÊý£¬²¢½«Æä¼Óµ½ `y` ÉÏ£¬µÃµ½ÐµİٷֱÈ×ÝÏò×ø±ê `y_p`¡£
* **µ÷Óõã»÷·½·¨**£º
return hid.clickPercent(x_p, y_p);
* µ÷Óà `hid.clickPercent(x_p, y_p)` ·½·¨£¬²¢½«¼ÆËãµÃµ½µÄËæ»úµã»÷λÖà `x_p` ºÍ `y_p` ×÷Ϊ²ÎÊý´«µÝ¸øËü¡£`hid.clickPercent(x_p, y_p)` µÄ·µ»ØÖµ½«×÷Ϊ `¼üÊó.Ëæ»ú°Ù·Ö±Èµã»÷` ·½·¨µÄ·µ»ØÖµ¡£
ʾÀýµ÷Óãº
¼üÊó.Ëæ»ú°Ù·Ö±Èµã»÷(50.0, 50.0, 5);
* ÕâÐдúÂëʾÀýµ÷ÓÃÁË `¼üÊó.Ëæ»ú°Ù·Ö±Èµã»÷` ·½·¨£¬²¢´«Èë²ÎÊý `50.0`£¨°Ù·Ö±ÈºáÏò×ø±ê£©¡¢`50.0`£¨°Ù·Ö±È×ÝÏò×ø±ê£©ºÍ `5`£¨Ëæ»úÆ«ÒÆÖµ£©¡£ÕâÒâζ×ŵã»÷µÄλÖý«ÔÚ `45.0%` µ½ `55.0%` Ö®¼äµÄij¸öËæ»ú°Ù·Ö±ÈλÖá£
µÚÈý¸ö£¬HID¼üÊóģʽ-ģʽÊÖÖ¸Ëæ»úµã»÷
const ¼üÊó = {};
¼üÊó.ģʽËæ»úµã»÷ = function (x, y, random) {
if (typeof x === "undefined") return false;
if (typeof y === "undefined") return false;
let random_w = random || 10;
let x_w = x + rand.randNumber(-random_w, random_w);
let y_w = y + rand.randNumber(-random_w, random_w);
hid.touchDown(0, x_w, y_w);
sleep.millisecond(rand.randNumber(50, 100));
hid.touchUp(0);
return true;
}
¼üÊó.ģʽËæ»úµã»÷(100, 200, 5);
´úÂë½âÊÍ
¼üÊó
¶ÔÏó¶¨Ò壺
const ¼üÊó = {};
* ÕâÐдúÂ붨ÒåÁËÒ»¸ö³£Á¿ `¼üÊó`£¬²¢½«Æä³õʼ»¯ÎªÒ»¸ö¿Õ¶ÔÏó¡£`¼üÊó` ¶ÔÏó½«ÓÃÓÚ´æ´¢Óë HID ¼üÊó²Ù×÷Ïà¹ØµÄ·½·¨¡£
¼üÊó.ģʽËæ»úµã»÷
·½·¨£º
¼üÊó.ģʽËæ»úµã»÷ = function (x, y, random) {
if (typeof x === "undefined") return false;
if (typeof y === "undefined") return false;
let random_w = random || 10;
let x_w = x + rand.randNumber(-random_w, random_w);
let y_w = y + rand.randNumber(-random_w, random_w);
hid.touchDown(0, x_w, y_w);
sleep.millisecond(rand.randNumber(50, 100));
hid.touchUp(0);
return true;
}
* **²ÎÊý¼ì²é**£º
if (typeof x === "undefined") return false;
if (typeof y === "undefined") return false;
* ¼ì²é²ÎÊý `x` ºÍ `y` ÊÇ·ñ䶨Ò壬Èç¹ûÊÇÔò·µ»Ø `false` ±íʾµã»÷ʧ°Ü¡£
* **Ëæ»úÆ«ÒÆÖµ´¦Àí**£º
let random_w = random || 10;
* Èç¹û `random` ²ÎÊý䶨Ò壬ÔòʹÓÃĬÈÏÖµ `10`¡£
* **Ëæ»úµã»÷λÖüÆËã**£º
let x_w = x + rand.randNumber(-random_w, random_w);
let y_w = y + rand.randNumber(-random_w, random_w);
* Éú³ÉÒ»¸öÔÚ `x - random_w` ºÍ `x + random_w` Ö®¼äµÄËæ»úÕûÊý£¬²¢½«Æä¼Óµ½ `x` ÉÏ£¬µÃµ½ÐµĺáÏò×ø±ê `x_w`¡£
* Éú³ÉÒ»¸öÔÚ `y - random_w` ºÍ `y + random_w` Ö®¼äµÄËæ»úÕûÊý£¬²¢½«Æä¼Óµ½ `y` ÉÏ£¬µÃµ½ÐµÄ×ÝÏò×ø±ê `y_w`¡£
* **Ä£ÄâÊÖÖ¸µã»÷**£º
hid.touchDown(0, x_w, y_w);
sleep.millisecond(rand.randNumber(50, 100));
hid.touchUp(0);
* `hid.touchDown(0, x_w, y_w)`£ºÄ£ÄâÊÖÖ¸°´Ï²Ù×÷£¬`0` ±íʾÊÖÖ¸µÄ±àºÅ£¬`x_w` ºÍ `y_w` ÊÇ°´ÏÂλÖõÄ×ø±ê¡£
* `sleep.millisecond(rand.randNumber(50, 100))`£ºÔÝÍ£Ò»¶Îʱ¼ä£¬Ê±¼äÔÚ `50` µ½ `100` ºÁÃëÖ®¼äËæ»ú¡£
* `hid.touchUp(0)`£ºÄ£ÄâÊÖָ̧Æð²Ù×÷£¬`0` ±íʾÊÖÖ¸µÄ±àºÅ¡£
* **·µ»Ø½á¹û**£º
return true;
* µã»÷²Ù×÷Íê³Éºó£¬·µ»Ø `true` ±íʾµã»÷³É¹¦¡£
ʾÀýµ÷Óãº
¼üÊó.ģʽËæ»úµã»÷(100, 200, 5);
* ÕâÐдúÂëʾÀýµ÷ÓÃÁË `¼üÊó.ģʽËæ»úµã»÷` ·½·¨£¬²¢´«Èë²ÎÊý `100`£¨ºáÏò×ø±ê£©¡¢`200`£¨×ÝÏò×ø±ê£©ºÍ `5`£¨Ëæ»úÆ«ÒÆÖµ£©¡£ÕâÒâζ×ŵã»÷µÄλÖý«ÔÚ `(95, 195)` µ½ `(105, 205)` Ö®¼äµÄij¸öËæ»úλÖá£