YYPOST群发软件 发表于 2025-11-7 09:10:51

AIWROK软件安卓随机工具应用函数生成

AIWROK软件安卓随机工具应用函数生成








//🍎交流 QQ 群 711841924 群一,苹果内测群,528816639
//适用本文档ES5系统安卓 JavaScript引擎Rhino
/*
类别 详情说明
方法功能 生成指定范围内的随机小数
方法签名 Double LtUqFOGkc6(Double min, Double max)
返回值 Double(生成的随机小数)
参数 - Double min:随机小数的最小值
   - Double max:随机小数的最大值
*/
function LtUqFOGkc6(min, max) {
    return Math.random() * (max - min) + min;
}

// 📌随机点击位置生成函数(修复版本)
/*
类别 详情说明
方法功能 在指定区域内生成随机点击坐标
方法签名 Object randClickPosition(Double left, Double top, Double right, Double bottom)
返回值 Object(包含x和y坐标的对象)
参数 - Double left:区域左边界
   - Double top:区域上边界
   - Double right:区域右边界
   - Double bottom:区域下边界
*/
function randClickPosition(left, top, right, bottom) {
    // 确保参数是有效的数值
    if (typeof left !== 'number' || typeof top !== 'number' ||
      typeof right !== 'number' || typeof bottom !== 'number') {
      throw new Error('所有参数必须是数值类型');
    }
   
    if (left >= right || top >= bottom) {
      throw new Error('left必须小于right,top必须小于bottom');
    }
   
    var x = LtUqFOGkc6(left, right);
    var y = LtUqFOGkc6(top, bottom);
    return {x: x, y: y};
}

// 使用示例:
printl("=== LtUqFOGkc6随机小数函数使用示例 ===");
print.log("=== LtUqFOGkc6随机小数函数使用示例 ===");

// 生成0到1之间的随机小数
var randomDecimal1 = LtUqFOGkc6(0, 1);
printl("生成0-1之间的随机小数: " + randomDecimal1);
print.log("生成0-1之间的随机小数: " + randomDecimal1);

// 生成10到100之间的随机小数
var randomDecimal2 = LtUqFOGkc6(10, 100);
printl("生成10-100之间的随机小数: " + randomDecimal2);
print.log("生成10-100之间的随机小数: " + randomDecimal2);

// 生成随机延迟时间(1.5秒到3.5秒之间)
var delayTime = LtUqFOGkc6(1.5, 3.5);
printl("生成随机延迟时间: " + delayTime + "秒");
print.log("生成随机延迟时间: " + delayTime + "秒");

// 在点击操作中使用随机小数作为坐标
var x = LtUqFOGkc6(100.0, 500.0);
var y = LtUqFOGkc6(200.0, 800.0);
printl("生成随机坐标: (" + x + ", " + y + ")");
print.log("生成随机坐标: (" + x + ", " + y + ")");

// 使用修复后的随机点击位置函数
var clickPos = randClickPosition(100.0, 200.0, 500.0, 800.0);
printl("生成随机点击位置: (" + clickPos.x + ", " + clickPos.y + ")");
print.log("生成随机点击位置: (" + clickPos.x + ", " + clickPos.y + ")");

// 更多随机数相关函数示例:

// 📌随机整数生成函数
/*
类别 详情说明
方法功能 生成指定范围内的随机整数
方法签名 Int32 randInt(Int32 min, Int32 max)
返回值 Int32(生成的随机整数)
参数 - Int32 min:随机整数的最小值
   - Int32 max:随机整数的最大值
*/
function randInt(min, max) {
    // 确保参数是有效的整数
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min;
}

// 📌随机布尔值生成函数
/*
类别 详情说明
方法功能 生成随机布尔值(true/false)
方法签名 Boolean randBool()
返回值 Boolean(生成的随机布尔值)
参数 无
*/
function randBool() {
    return Math.random() < 0.5;
}

// &#128204;随机数组元素选择函数
/*
类别 详情说明
方法功能 从数组中随机选择一个元素
方法签名 Object randChoice(Array arr)
返回值 Object(数组中的随机元素)
参数 - Array arr:源数组
*/
function randChoice(arr) {
    if (!arr || !Array.isArray(arr) || arr.length === 0) return null;
    var index = randInt(0, arr.length - 1);
    return arr;
}

// &#128204;随机颜色生成函数
/*
类别 详情说明
方法功能 生成随机颜色值
方法签名 String randColor()
返回值 String(十六进制颜色值)
参数 无
*/
function randColor() {
    var letters = '0123456789ABCDEF';
    var color = '#';
    for (var i = 0; i < 6; i++) {
      color += letters;
    }
    return color;
}

// 使用示例:
printl("=== 更多随机数方法使用示例 ===");
print.log("=== 更多随机数方法使用示例 ===");

// 随机整数示例
var randomInteger = randInt(1, 100);
printl("生成1-100之间的随机整数: " + randomInteger);
print.log("生成1-100之间的随机整数: " + randomInteger);

// 随机布尔值示例
var randomBoolean = randBool();
printl("生成随机布尔值: " + randomBoolean);
print.log("生成随机布尔值: " + randomBoolean);

// 随机数组元素示例
var fruits = ["苹果", "香蕉", "橙子", "葡萄", "草莓"];
var randomFruit = randChoice(fruits);
printl("从数组中随机选择: " + randomFruit);
print.log("从数组中随机选择: " + randomFruit);

// 随机颜色示例
var randomColor = randColor();
printl("生成随机颜色: " + randomColor);
print.log("生成随机颜色: " + randomColor);

// FOR循环十次操作示例
printl("=== FOR循环十次操作示例 ===");
print.log("=== FOR循环十次操作示例 ===");
for (var i = 0; i < 10; i++) {
    var randomX = LtUqFOGkc6(0, 100);
    var randomY = LtUqFOGkc6(0, 100);
    var position = randClickPosition(0, 0, 100, 100);
    var randomInt = randInt(1, 10);
    var randomBooleanValue = randBool();
    var randomArrayElement = randChoice(["A", "B", "C", "D", "E"]);
    var randomColorValue = randColor();
   
    printl("第" + (i + 1) + "次循环: 随机坐标(" + randomX.toFixed(2) + ", " + randomY.toFixed(2) +
         "), 点击位置(" + position.x.toFixed(2) + ", " + position.y.toFixed(2) +
         "), 随机整数(" + randomInt +
         "), 随机布尔值(" + randomBooleanValue +
         "), 数组元素(" + randomArrayElement +
         "), 随机颜色(" + randomColorValue + ")");
   
    print.log("第" + (i + 1) + "次循环: 随机坐标(" + randomX.toFixed(2) + ", " + randomY.toFixed(2) +
         "), 点击位置(" + position.x.toFixed(2) + ", " + position.y.toFixed(2) +
         "), 随机整数(" + randomInt +
         "), 随机布尔值(" + randomBooleanValue +
         "), 数组元素(" + randomArrayElement +
         "), 随机颜色(" + randomColorValue + ")");
}

// 综合应用示例:模拟用户随机操作
function simulateRandomUserActions() {
    printl("=== 模拟用户随机操作 ===");
    print.log("=== 模拟用户随机操作 ===");
   
    // 随机决定执行哪种操作
    var actions = ["点击", "滑动", "输入", "等待"];
    var action = randChoice(actions);
   
    switch(action) {
      case "点击":
            // 注意:这里需要确保screen对象存在并且有getScreenWidth和getScreenHeight方法
            try {
                var screenWidth = screen.getScreenWidth();
                var screenHeight = screen.getScreenHeight();
                var pos = randClickPosition(0, 0, screenWidth, screenHeight);
                printl("随机点击屏幕位置: (" + pos.x + ", " + pos.y + ")");
                print.log("随机点击屏幕位置: (" + pos.x + ", " + pos.y + ")");
                // hid.click(pos.x, pos.y); // 实际点击操作
            } catch (e) {
                printl("获取屏幕尺寸失败: " + e.message);
                print.log("获取屏幕尺寸失败: " + e.message);
            }
            break;
            
      case "滑动":
            var startPos = randClickPosition(100, 100, 400, 600);
            var endPos = randClickPosition(100, 100, 400, 600);
            printl("随机滑动从: (" + startPos.x + ", " + startPos.y + ") 到 (" + endPos.x + ", " + endPos.y + ")");
            print.log("随机滑动从: (" + startPos.x + ", " + startPos.y + ") 到 (" + endPos.x + ", " + endPos.y + ")");
            // hid.swip(startPos.x, startPos.y, endPos.x, endPos.y, 50, 500, 1); // 实际滑动操作
            break;
            
      case "输入":
            var texts = ["Hello", "World", "AIWork", "Automation"];
            var text = randChoice(texts);
            printl("随机输入文本: " + text);
            print.log("随机输入文本: " + text);
            // hid.inputSimple(text); // 实际输入操作
            break;
            
      case "等待":
            var waitTime = randInt(1000, 3000);
            printl("随机等待: " + waitTime + "毫秒");
            print.log("随机等待: " + waitTime + "毫秒");
            // sleep.millisecond(waitTime); // 实际等待操作
            break;
    }
}

// 执行模拟示例
simulateRandomUserActions();

// 配置日志窗口属性
try {
    var logWindow = logWindow;
    logWindow.clear(); // 清空历史日志
    logWindow.setWidth(screen.getScreenWidth()); // 设置宽度为屏幕宽度
    logWindow.setHeight(screen.getScreenHeight()); // 设置高度为屏幕高度
    logWindow.setPosition(0, 0); // 设置位置为左上角
    logWindow.setAlpha(0.7); // 设置透明度为70%
    logWindow.setNoClickModel(); // 设置点击穿透模式
    logWindow.showModel(0); // 显示所有内容
} catch (e) {
    printl("日志窗口配置失败: " + e.message);
    print.log("日志窗口配置失败: " + e.message);
}

printl("=== 随机数方法示例结束 ===");
print.log("=== 随机数方法示例结束 ===");


页: [1]
查看完整版本: AIWROK软件安卓随机工具应用函数生成