键鼠.随机点击方法让您的点击操作不再呆板,而是带有随机偏移,带来惊喜连连。
键鼠.随机点击方法让您的点击操作不再呆板,而是带有随机偏移,带来惊喜连连。<div><h1 id="h1--hid-" style="color: rgb(0, 0, 0); margin-top: 8px; margin-bottom: 1.5em; padding-bottom: 0.3em; box-sizing: border-box; border-bottom: 1px solid rgb(238, 238, 238); position: relative; line-height: 1.75; font-size: 1.8em !important;">第一个,键鼠HID随机点击例子</h1><p style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; box-sizing: border-box;"><img src="http://doc.aiwork24.com:91/server/index.php?s=/api/attachment/visitFile&sign=5510ed15b10d69d82f5c5ae5ae26238f" alt="" style="box-sizing: border-box; border: 0px; max-width: 100%;"></p><pre style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow-wrap: normal; box-sizing: border-box; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs javascript" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;"><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">const</span> 键鼠 = {};键鼠.点击 = <span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">function</span> (<span class="hljs-params" style="box-sizing: border-box;">x, y</span>) </span>{
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> x === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> y === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> hid.click(x, y);
}
键鼠.随机点击 = <span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">function</span> (<span class="hljs-params" style="box-sizing: border-box;">x, y, random</span>) </span>{
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> x === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> y === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> random_s = random || <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">10</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> x_w = x + rand.randNumber(-random_s, random_s);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> y_h = y + rand.randNumber(-random_s, random_s);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> hid.click(x_w, y_h);
}
<span class="hljs-comment" style="box-sizing: border-box; color: rgb(170, 170, 170); font-style: italic;">// 示例调用随机点击方法</span>
键鼠.随机点击(<span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">100</span>, <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">200</span>, <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">5</span>);
</code></pre><p style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; box-sizing: border-box;">以下是对你提供的代码的详细解释:</p><pre style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow-wrap: normal; box-sizing: border-box; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs cpp" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;"><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">const</span> 键鼠 = {};
</code></pre><p style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; box-sizing: border-box;">这行代码定义了一个常量 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">键鼠</code>,并将其初始化为一个空对象。<code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">键鼠</code> 对象将用于存储与 HID 键鼠操作相关的方法。</p><pre style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow-wrap: normal; box-sizing: border-box; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs javascript" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;">键鼠.点击 = <span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">function</span> (<span class="hljs-params" style="box-sizing: border-box;">x, y</span>) </span>{
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> x === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> y === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> hid.click(x, y);
}
</code></pre><p style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; box-sizing: border-box;">这行代码为 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">键鼠</code> 对象添加了一个名为 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">点击</code> 的方法。该方法接受两个参数 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">x</code> 和 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">y</code>,分别代表点击的位置的横向坐标和纵向坐标。</p><ul style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; margin-left: 14px; padding-left: 2em; box-sizing: border-box;"><li style="list-style-position: initial; list-style-image: initial; box-sizing: border-box;"><code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">if (typeof x === "undefined") return false;</code>:检查参数 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">x</code> 是否未定义,如果是,则返回 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">false</code> 表示点击失败。</li><li style="list-style-position: initial; list-style-image: initial; box-sizing: border-box;"><code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">if (typeof y === "undefined") return false;</code>:检查参数 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">y</code> 是否未定义,如果是,则返回 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">false</code> 表示点击失败。</li><li style="list-style-position: initial; list-style-image: initial; box-sizing: border-box;"><p style="margin-top: 16px; margin-bottom: 1.5em; box-sizing: border-box;"><code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">return hid.click(x, y);</code>:调用 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">hid</code> 对象的 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">click</code> 方法,并将 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">x</code> 和 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">y</code> 作为参数传递给它。<code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">hid.click(x, y)</code> 的返回值将作为 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">键鼠.点击</code> 方法的返回值。</p><p style="margin-top: 16px; margin-bottom: 1.5em; box-sizing: border-box;">键鼠.随机点击 = function (x, y, random) {</p><pre style="overflow-wrap: normal; box-sizing: border-box; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs csharp" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;"><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> x === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> y === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> random_s = random || <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">10</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> x_w = x + rand.randNumber(-random_s, random_s);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> y_h = y + rand.randNumber(-random_s, random_s);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> hid.click(x_w, y_h);
</code></pre><p style="margin-top: 16px; margin-bottom: 1.5em; box-sizing: border-box;">}</p></li></ul><p style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; box-sizing: border-box;">这行代码为 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">键鼠</code> 对象添加了一个名为 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">随机点击</code> 的方法。该方法接受三个参数 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">x</code>、<code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">y</code> 和 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">random</code>,分别代表点击的位置的横向坐标、纵向坐标和随机偏移值。</p><ul style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; margin-left: 14px; padding-left: 2em; box-sizing: border-box;"><li style="list-style-position: initial; list-style-image: initial; box-sizing: border-box;"><code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">if (typeof x === "undefined") return false;</code>:检查参数 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">x</code> 是否未定义,如果是,则返回 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">false</code> 表示点击失败。</li><li style="list-style-position: initial; list-style-image: initial; box-sizing: border-box;"><code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">if (typeof y === "undefined") return false;</code>:检查参数 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">y</code> 是否未定义,如果是,则返回 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">false</code> 表示点击失败。</li><li style="list-style-position: initial; list-style-image: initial; box-sizing: border-box;"><code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">let random_s = random || 10;</code>:如果 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">random</code> 参数未定义,则使用默认值 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">10</code>。</li><li style="list-style-position: initial; list-style-image: initial; box-sizing: border-box;"><code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">let x_w = x + rand.randNumber(-random_s, random_s);</code>:生成一个在 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">x - random_s</code> 和 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">x + random_s</code> 之间的随机数,并将其加到 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">x</code> 上,得到新的横向坐标 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">x_w</code>。</li><li style="list-style-position: initial; list-style-image: initial; box-sizing: border-box;"><code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">let y_h = y + rand.randNumber(-random_s, random_s);</code>:生成一个在 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">y - random_s</code> 和 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">y + random_s</code> 之间的随机数,并将其加到 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">y</code> 上,得到新的纵向坐标 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">y_h</code>。</li><li style="list-style-position: initial; list-style-image: initial; box-sizing: border-box;"><p style="margin-top: 16px; margin-bottom: 1.5em; box-sizing: border-box;"><code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">return hid.click(x_w, y_h);</code>:调用 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">hid</code> 对象的 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">click</code> 方法,并将计算得到的随机点击位置 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">x_w</code> 和 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">y_h</code> 作为参数传递给它。<code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">hid.click(x_w, y_h)</code> 的返回值将作为 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">键鼠.随机点击</code> 方法的返回值。</p><p style="margin-top: 16px; margin-bottom: 1.5em; box-sizing: border-box;">// 示例调用随机点击方法<br style="box-sizing: border-box;">键鼠.随机点击(100, 200, 5);</p></li></ul><p style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; box-sizing: border-box;">这行代码示例调用了 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">键鼠.随机点击</code> 方法,并传入参数 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">100</code>(横向坐标)、<code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">200</code>(纵向坐标)和 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">5</code>(随机偏移值)。这意味着点击的位置将在 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">(95, 195)</code> 到 <code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">(105, 205)</code> 之间的某个随机位置。</p><h1 id="h1--hid-" style="color: rgb(0, 0, 0); margin-top: 1em; margin-bottom: 1.5em; padding-bottom: 0.3em; box-sizing: border-box; border-bottom: 1px solid rgb(238, 238, 238); position: relative; line-height: 1.75; font-size: 1.8em !important;"><a name="第二个,HID键鼠模式-随机百分比点击" class="reference-link" style="color: rgb(65, 131, 196); transition: color 0.08s ease-out 0s; font-weight: 400; box-sizing: border-box; background: 0px 0px;"></a>第二个,HID键鼠模式-随机百分比点击</h1><p style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; box-sizing: border-box;"><img src="http://doc.aiwork24.com:91/server/index.php?s=/api/attachment/visitFile&sign=da68f83beed2c7570c8c3ff60076cfac" alt="" style="box-sizing: border-box; border: 0px; max-width: 100%;"></p><pre style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow-wrap: normal; box-sizing: border-box; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs javascript" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;"><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">const</span> 键鼠 = {};
<span class="hljs-comment" style="box-sizing: border-box; color: rgb(170, 170, 170); font-style: italic;">/**
* HID键鼠模式-随机百分比点击
* <span class="hljs-doctag" style="box-sizing: border-box; color: rgb(198, 120, 221);">@param <span class="hljs-type" style="box-sizing: border-box; color: rgb(209, 154, 102);">{浮点}</span> </span>x 百分比横向坐标x
* <span class="hljs-doctag" style="box-sizing: border-box; color: rgb(198, 120, 221);">@param <span class="hljs-type" style="box-sizing: border-box; color: rgb(209, 154, 102);">{浮点}</span> </span>y 百分比纵向坐标y
* <span class="hljs-doctag" style="box-sizing: border-box; color: rgb(198, 120, 221);">@param <span class="hljs-type" style="box-sizing: border-box; color: rgb(209, 154, 102);">{整数}</span> </span>random 随机偏移值,不写默认10
* <span class="hljs-doctag" style="box-sizing: border-box; color: rgb(198, 120, 221);">@returns <span class="hljs-type" style="box-sizing: border-box; color: rgb(209, 154, 102);">{布尔}</span> </span>成功:true,失败:false
*/</span>
键鼠.随机百分比点击 = <span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">function</span> (<span class="hljs-params" style="box-sizing: border-box;">x, y, random</span>) </span>{
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> x === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> y === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> random_w = random || <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">10</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> w = screen.widthToPercent(random_w);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> h = screen.heightToPercent(random_w);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> x_p = x + rand.randDoubleNumber(-w, w);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> y_p = y + rand.randDoubleNumber(-h, h);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> hid.clickPercent(x_p, y_p);
}
<span class="hljs-comment" style="box-sizing: border-box; color: rgb(170, 170, 170); font-style: italic;">// 示例调用随机百分比点击方法</span>
键鼠.随机百分比点击(<span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">50.0</span>, <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">50.0</span>, <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">5</span>);
</code></pre><ol style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; padding-left: 2em; box-sizing: border-box;"><li style="box-sizing: border-box;"><p style="margin-top: 16px; margin-bottom: 1.5em; box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: 700;"><code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">键鼠</code> 对象定义</span>:</p><pre style="overflow-wrap: normal; box-sizing: border-box; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs cpp" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;"><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">const</span> 键鼠 = {};
</code></pre></li></ol><pre style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow-wrap: normal; box-sizing: border-box; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs markdown" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;"><span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);">*</span> 这行代码定义了一个常量 <span class="hljs-code" style="box-sizing: border-box;">`键鼠`</span>,并将其初始化为一个空对象。<span class="hljs-code" style="box-sizing: border-box;">`键鼠`</span> 对象将用于存储与 HID 键鼠操作相关的方法。
</code></pre><ol style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; padding-left: 2em; box-sizing: border-box;"><li style="box-sizing: border-box;"><p style="margin-top: 16px; margin-bottom: 1.5em; box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: 700;"><code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">键鼠.随机百分比点击</code> 方法</span>:</p><pre style="overflow-wrap: normal; box-sizing: border-box; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs javascript" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;">键鼠.随机百分比点击 = <span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">function</span> (<span class="hljs-params" style="box-sizing: border-box;">x, y, random</span>) </span>{
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> x === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> y === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> random_w = random || <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">10</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> w = screen.widthToPercent(random_w);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> h = screen.heightToPercent(random_w);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> x_p = x + rand.randDoubleNumber(-w, w);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> y_p = y + rand.randDoubleNumber(-h, h);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> hid.clickPercent(x_p, y_p);
}
</code></pre></li></ol><pre style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow-wrap: normal; box-sizing: border-box; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs markdown" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;"><span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);">*</span> <span class="hljs-strong" style="box-sizing: border-box; font-weight: 700;">**参数检查**</span>:
<span class="hljs-code" style="box-sizing: border-box;"> if (typeof x === "undefined") return false;
if (typeof y === "undefined") return false;
</span>
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);"> *</span> 检查参数 <span class="hljs-code" style="box-sizing: border-box;">`x`</span> 和 <span class="hljs-code" style="box-sizing: border-box;">`y`</span> 是否未定义,如果是则返回 <span class="hljs-code" style="box-sizing: border-box;">`false`</span> 表示点击失败。
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);">*</span> <span class="hljs-strong" style="box-sizing: border-box; font-weight: 700;">**随机偏移值处理**</span>:
<span class="hljs-code" style="box-sizing: border-box;"> let random_w = random || 10;
</span>
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);"> *</span> 如果 <span class="hljs-code" style="box-sizing: border-box;">`random`</span> 参数未定义,则使用默认值 <span class="hljs-code" style="box-sizing: border-box;">`10`</span>。
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);">*</span> <span class="hljs-strong" style="box-sizing: border-box; font-weight: 700;">**百分比偏移值计算**</span>:
<span class="hljs-code" style="box-sizing: border-box;"> let w = screen.widthToPercent(random_w);
let h = screen.heightToPercent(random_w);
</span>
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);"> *</span> 调用 <span class="hljs-code" style="box-sizing: border-box;">`screen.widthToPercent(random_w)`</span> 和 <span class="hljs-code" style="box-sizing: border-box;">`screen.heightToPercent(random_w)`</span> 方法,将随机偏移值 <span class="hljs-code" style="box-sizing: border-box;">`random_w`</span> 转换为屏幕宽度和高度的百分比。
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);">*</span> <span class="hljs-strong" style="box-sizing: border-box; font-weight: 700;">**随机点击位置计算**</span>:
<span class="hljs-code" style="box-sizing: border-box;"> let x_p = x + rand.randDoubleNumber(-w, w);
let y_p = y + rand.randDoubleNumber(-h, h);
</span>
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);"> *</span> 生成一个在 <span class="hljs-code" style="box-sizing: border-box;">`x - w`</span> 和 <span class="hljs-code" style="box-sizing: border-box;">`x + w`</span> 之间的随机浮点数,并将其加到 <span class="hljs-code" style="box-sizing: border-box;">`x`</span> 上,得到新的百分比横向坐标 <span class="hljs-code" style="box-sizing: border-box;">`x_p`</span>。
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);"> *</span> 生成一个在 <span class="hljs-code" style="box-sizing: border-box;">`y - h`</span> 和 <span class="hljs-code" style="box-sizing: border-box;">`y + h`</span> 之间的随机浮点数,并将其加到 <span class="hljs-code" style="box-sizing: border-box;">`y`</span> 上,得到新的百分比纵向坐标 <span class="hljs-code" style="box-sizing: border-box;">`y_p`</span>。
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);">*</span> <span class="hljs-strong" style="box-sizing: border-box; font-weight: 700;">**调用点击方法**</span>:
<span class="hljs-code" style="box-sizing: border-box;"> return hid.clickPercent(x_p, y_p);
</span>
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);"> *</span> 调用 <span class="hljs-code" style="box-sizing: border-box;">`hid.clickPercent(x_p, y_p)`</span> 方法,并将计算得到的随机点击位置 <span class="hljs-code" style="box-sizing: border-box;">`x_p`</span> 和 <span class="hljs-code" style="box-sizing: border-box;">`y_p`</span> 作为参数传递给它。<span class="hljs-code" style="box-sizing: border-box;">`hid.clickPercent(x_p, y_p)`</span> 的返回值将作为 <span class="hljs-code" style="box-sizing: border-box;">`键鼠.随机百分比点击`</span> 方法的返回值。
</code></pre><ol style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; padding-left: 2em; box-sizing: border-box;"><li style="box-sizing: border-box;"><p style="margin-top: 16px; margin-bottom: 1.5em; box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: 700;">示例调用</span>:</p><pre style="overflow-wrap: normal; box-sizing: border-box; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs less" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;"><span class="hljs-comment" style="box-sizing: border-box; color: rgb(170, 170, 170); font-style: italic;">// 示例调用随机百分比点击方法</span>
键鼠.随机百分比点击(<span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">50.0</span>, <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">50.0</span>, <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">5</span>);
</code></pre></li></ol><pre style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow-wrap: normal; box-sizing: border-box; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs markdown" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;"><span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);">*</span> 这行代码示例调用了 <span class="hljs-code" style="box-sizing: border-box;">`键鼠.随机百分比点击`</span> 方法,并传入参数 <span class="hljs-code" style="box-sizing: border-box;">`50.0`</span>(百分比横向坐标)、<span class="hljs-code" style="box-sizing: border-box;">`50.0`</span>(百分比纵向坐标)和 <span class="hljs-code" style="box-sizing: border-box;">`5`</span>(随机偏移值)。这意味着点击的位置将在 <span class="hljs-code" style="box-sizing: border-box;">`45.0%`</span> 到 <span class="hljs-code" style="box-sizing: border-box;">`55.0%`</span> 之间的某个随机百分比位置。
</code></pre><h1 id="h1--hid-" style="color: rgb(0, 0, 0); margin-top: 1em; margin-bottom: 1.5em; padding-bottom: 0.3em; box-sizing: border-box; border-bottom: 1px solid rgb(238, 238, 238); position: relative; line-height: 1.75; font-size: 1.8em !important;"><a name="第三个,HID键鼠模式-模式手指随机点击" class="reference-link" style="color: rgb(65, 131, 196); transition: color 0.08s ease-out 0s; font-weight: 400; box-sizing: border-box; background: 0px 0px;"></a>第三个,HID键鼠模式-模式手指随机点击</h1><p style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; box-sizing: border-box;"><img src="http://doc.aiwork24.com:91/server/index.php?s=/api/attachment/visitFile&sign=ee6ca7fc116396c60f466c30e1c86f52" alt="" style="box-sizing: border-box; border: 0px; max-width: 100%;"></p><pre style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow-wrap: normal; box-sizing: border-box; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs javascript" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;"><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">const</span> 键鼠 = {};
<span class="hljs-comment" style="box-sizing: border-box; color: rgb(170, 170, 170); font-style: italic;">/**
* HID键鼠模式-模式手指随机点击
* <span class="hljs-doctag" style="box-sizing: border-box; color: rgb(198, 120, 221);">@param <span class="hljs-type" style="box-sizing: border-box; color: rgb(209, 154, 102);">{整数}</span> </span>x 横向坐标x
* <span class="hljs-doctag" style="box-sizing: border-box; color: rgb(198, 120, 221);">@param <span class="hljs-type" style="box-sizing: border-box; color: rgb(209, 154, 102);">{整数}</span> </span>y 纵向坐标y
* <span class="hljs-doctag" style="box-sizing: border-box; color: rgb(198, 120, 221);">@param <span class="hljs-type" style="box-sizing: border-box; color: rgb(209, 154, 102);">{整数}</span> </span>random 随机偏移值,不写默认10
* <span class="hljs-doctag" style="box-sizing: border-box; color: rgb(198, 120, 221);">@returns <span class="hljs-type" style="box-sizing: border-box; color: rgb(209, 154, 102);">{布尔}</span> </span>成功:true,失败:false
*/</span>
键鼠.模式随机点击 = <span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">function</span> (<span class="hljs-params" style="box-sizing: border-box;">x, y, random</span>) </span>{
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> x === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> y === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> random_w = random || <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">10</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> x_w = x + rand.randNumber(-random_w, random_w);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> y_w = y + rand.randNumber(-random_w, random_w);
hid.touchDown(<span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">0</span>, x_w, y_w);
sleep.millisecond(rand.randNumber(<span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">50</span>, <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">100</span>));
hid.touchUp(<span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">0</span>);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">true</span>;
}
<span class="hljs-comment" style="box-sizing: border-box; color: rgb(170, 170, 170); font-style: italic;">// 示例调用模式随机点击方法</span>
键鼠.模式随机点击(<span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">100</span>, <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">200</span>, <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">5</span>);
</code></pre><h3 id="h3-u4EE3u7801u89E3u91CA" style="color: rgb(0, 0, 0); margin-top: 1em; margin-bottom: 1.5em; box-sizing: border-box; position: relative; line-height: 1.75; font-size: 1.25em !important;"><a name="代码解释" class="reference-link" style="color: rgb(65, 131, 196); transition: color 0.08s ease-out 0s; box-sizing: border-box; background: 0px 0px;"></a>代码解释</h3><ol style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; padding-left: 2em; box-sizing: border-box;"><li style="box-sizing: border-box;"><p style="margin-top: 16px; margin-bottom: 1.5em; box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: 700;"><code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">键鼠</code> 对象定义</span>:</p><pre style="overflow-wrap: normal; box-sizing: border-box; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs cpp" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;"><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">const</span> 键鼠 = {};
</code></pre></li></ol><pre style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow-wrap: normal; box-sizing: border-box; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs markdown" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;"><span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);">*</span> 这行代码定义了一个常量 <span class="hljs-code" style="box-sizing: border-box;">`键鼠`</span>,并将其初始化为一个空对象。<span class="hljs-code" style="box-sizing: border-box;">`键鼠`</span> 对象将用于存储与 HID 键鼠操作相关的方法。
</code></pre><ol style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; padding-left: 2em; box-sizing: border-box;"><li style="box-sizing: border-box;"><p style="margin-top: 16px; margin-bottom: 1.5em; box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: 700;"><code style="box-sizing: border-box; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; padding: 3px; margin-right: 4px; margin-left: 5px; background: rgb(249, 249, 249); border-radius: 3px; border: 1px solid rgb(221, 221, 221); color: rgb(64, 158, 255);">键鼠.模式随机点击</code> 方法</span>:</p><pre style="overflow-wrap: normal; box-sizing: border-box; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs javascript" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;">键鼠.模式随机点击 = <span class="hljs-function" style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">function</span> (<span class="hljs-params" style="box-sizing: border-box;">x, y, random</span>) </span>{
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> x === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">if</span> (<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">typeof</span> y === <span class="hljs-string" style="box-sizing: border-box; color: rgb(152, 195, 121);">"undefined"</span>) <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">false</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> random_w = random || <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">10</span>;
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> x_w = x + rand.randNumber(-random_w, random_w);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">let</span> y_w = y + rand.randNumber(-random_w, random_w);
hid.touchDown(<span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">0</span>, x_w, y_w);
sleep.millisecond(rand.randNumber(<span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">50</span>, <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">100</span>));
hid.touchUp(<span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">0</span>);
<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(198, 120, 221);">return</span> <span class="hljs-literal" style="box-sizing: border-box; color: rgb(86, 182, 194);">true</span>;
}
</code></pre></li></ol><pre style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow-wrap: normal; box-sizing: border-box; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs markdown" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;"><span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);">*</span> <span class="hljs-strong" style="box-sizing: border-box; font-weight: 700;">**参数检查**</span>:
<span class="hljs-code" style="box-sizing: border-box;"> if (typeof x === "undefined") return false;
if (typeof y === "undefined") return false;
</span>
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);"> *</span> 检查参数 <span class="hljs-code" style="box-sizing: border-box;">`x`</span> 和 <span class="hljs-code" style="box-sizing: border-box;">`y`</span> 是否未定义,如果是则返回 <span class="hljs-code" style="box-sizing: border-box;">`false`</span> 表示点击失败。
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);">*</span> <span class="hljs-strong" style="box-sizing: border-box; font-weight: 700;">**随机偏移值处理**</span>:
<span class="hljs-code" style="box-sizing: border-box;"> let random_w = random || 10;
</span>
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);"> *</span> 如果 <span class="hljs-code" style="box-sizing: border-box;">`random`</span> 参数未定义,则使用默认值 <span class="hljs-code" style="box-sizing: border-box;">`10`</span>。
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);">*</span> <span class="hljs-strong" style="box-sizing: border-box; font-weight: 700;">**随机点击位置计算**</span>:
<span class="hljs-code" style="box-sizing: border-box;"> let x_w = x + rand.randNumber(-random_w, random_w);
let y_w = y + rand.randNumber(-random_w, random_w);
</span>
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);"> *</span> 生成一个在 <span class="hljs-code" style="box-sizing: border-box;">`x - random_w`</span> 和 <span class="hljs-code" style="box-sizing: border-box;">`x + random_w`</span> 之间的随机整数,并将其加到 <span class="hljs-code" style="box-sizing: border-box;">`x`</span> 上,得到新的横向坐标 <span class="hljs-code" style="box-sizing: border-box;">`x_w`</span>。
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);"> *</span> 生成一个在 <span class="hljs-code" style="box-sizing: border-box;">`y - random_w`</span> 和 <span class="hljs-code" style="box-sizing: border-box;">`y + random_w`</span> 之间的随机整数,并将其加到 <span class="hljs-code" style="box-sizing: border-box;">`y`</span> 上,得到新的纵向坐标 <span class="hljs-code" style="box-sizing: border-box;">`y_w`</span>。
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);">*</span> <span class="hljs-strong" style="box-sizing: border-box; font-weight: 700;">**模拟手指点击**</span>:
<span class="hljs-code" style="box-sizing: border-box;"> hid.touchDown(0, x_w, y_w);
sleep.millisecond(rand.randNumber(50, 100));
hid.touchUp(0);
</span>
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);"> *</span> <span class="hljs-code" style="box-sizing: border-box;">`hid.touchDown(0, x_w, y_w)`</span>:模拟手指按下操作,<span class="hljs-code" style="box-sizing: border-box;">`0`</span> 表示手指的编号,<span class="hljs-code" style="box-sizing: border-box;">`x_w`</span> 和 <span class="hljs-code" style="box-sizing: border-box;">`y_w`</span> 是按下位置的坐标。
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);"> *</span> <span class="hljs-code" style="box-sizing: border-box;">`sleep.millisecond(rand.randNumber(50, 100))`</span>:暂停一段时间,时间在 <span class="hljs-code" style="box-sizing: border-box;">`50`</span> 到 <span class="hljs-code" style="box-sizing: border-box;">`100`</span> 毫秒之间随机。
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);"> *</span> <span class="hljs-code" style="box-sizing: border-box;">`hid.touchUp(0)`</span>:模拟手指抬起操作,<span class="hljs-code" style="box-sizing: border-box;">`0`</span> 表示手指的编号。
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);">*</span> <span class="hljs-strong" style="box-sizing: border-box; font-weight: 700;">**返回结果**</span>:
<span class="hljs-code" style="box-sizing: border-box;"> return true;
</span>
<span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);"> *</span> 点击操作完成后,返回 <span class="hljs-code" style="box-sizing: border-box;">`true`</span> 表示点击成功。
</code></pre><ol style="color: rgb(0, 0, 0); font-size: medium; margin-bottom: 1.5em; padding-left: 2em; box-sizing: border-box;"><li style="box-sizing: border-box;"><p style="margin-top: 16px; margin-bottom: 1.5em; box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: 700;">示例调用</span>:</p><pre style="overflow-wrap: normal; box-sizing: border-box; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; margin-bottom: 1.5em; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs less" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;"><span class="hljs-comment" style="box-sizing: border-box; color: rgb(170, 170, 170); font-style: italic;">// 示例调用模式随机点击方法</span>
键鼠.模式随机点击(<span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">100</span>, <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">200</span>, <span class="hljs-number" style="box-sizing: border-box; color: rgb(209, 154, 102);">5</span>);
</code></pre></li></ol><pre style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 11.9px; line-height: 1.6; font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; overflow-wrap: normal; box-sizing: border-box; padding: 1em; overflow: auto; background: rgb(56, 69, 72); border-radius: 4px; border: 1px solid rgb(221, 221, 221); position: relative; color: rgb(209, 210, 210);"><code class="hljs markdown" style="overflow-wrap: normal; box-sizing: border-box; background: 0px 0px transparent; font-family: Consolas, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace; border-radius: 3px; border: 0px; word-break: normal; display: block; max-width: none; overflow-x: auto; overflow-y: initial; line-height: inherit;"><span class="hljs-bullet" style="box-sizing: border-box; color: rgb(97, 174, 238);">*</span> 这行代码示例调用了 <span class="hljs-code" style="box-sizing: border-box;">`键鼠.模式随机点击`</span> 方法,并传入参数 <span class="hljs-code" style="box-sizing: border-box;">`100`</span>(横向坐标)、<span class="hljs-code" style="box-sizing: border-box;">`200`</span>(纵向坐标)和 <span class="hljs-code" style="box-sizing: border-box;">`5`</span>(随机偏移值)。这意味着点击的位置将在 <span class="hljs-code" style="box-sizing: border-box;">`(95, 195)`</span> 到 <span class="hljs-code" style="box-sizing: border-box;">`(105, 205)`</span> 之间的某个随机位置。
</code><div><br></div></pre></div>
页:
[1]