YYPOST群发软件 发表于 7 天前

AIWROK软件苹果系统中实现四种基本滑动操作

AIWROK软件苹果系统中实现四种基本滑动操作

/**
* AIWROK软件安卓交流QQ群711841924
* 苹果内测软件QQ群648461709
* 展示如何在AIWROK苹果系统中实现四种基本滑动操作
/**
* 滑动操作管理器类
* 提供上滑、下滑、左滑、右滑等基本滑动操作
*/
class SwipeManager {
    /**
   * 构造函数
   * @param {number} duration - 滑动持续时间(毫秒)
   */
    constructor(duration = 500) {
      this.duration = duration;
      
      // 获取屏幕尺寸
      this.screenWidth = screen.getScreenWidth();
      this.screenHeight = screen.getScreenHeight();
      
      printl(`📱 屏幕尺寸: ${this.screenWidth} x ${this.screenHeight}`);
    }
   
    /**
   * 上滑操作
   * 从屏幕下方滑动到上方
   */
    swipeUp() {
      printl("👆 执行上滑操作");
      try {
            // 使用hid.swipVPercent执行垂直上滑
            // 从屏幕高度80%处滑动到20%处
            // hid.swipVPercent(startYPercent, endYPercent, xPercent, duration, step, type)
            const result = hid.swipVPercent(0.8, 0.2, 0.5, this.duration, 10, 1);
            printl(`✅ 上滑操作完成: ${result}`);
      } catch (error) {
            printl(`❌ 上滑操作失败: ${error.message}`);
      }
    }
   
    /**
   * 下滑操作
   * 从屏幕上方滑动到下方
   */
    swipeDown() {
      printl("👇 执行下滑操作");
      try {
            // 使用hid.swipVPercent执行垂直下滑
            // 从屏幕高度20%处滑动到80%处
            // hid.swipVPercent(startYPercent, endYPercent, xPercent, duration, step, type)
            const result = hid.swipVPercent(0.2, 0.8, 0.5, this.duration, 10, 1);
            printl(`✅ 下滑操作完成: ${result}`);
      } catch (error) {
            printl(`❌ 下滑操作失败: ${error.message}`);
      }
    }
   
    /**
   * 左滑操作
   * 从屏幕右侧滑动到左侧
   */
    swipeLeft() {
      printl("👈 执行左滑操作");
      try {
            // 使用hid.swipHPercent执行水平左滑
            // 从屏幕宽度80%处滑动到20%处
            // hid.swipHPercent(startXPercent, endXPercent, yPercent, duration, step, type)
            const result = hid.swipHPercent(0.8, 0.2, 0.5, this.duration, 10, 1);
            printl(`✅ 左滑操作完成: ${result}`);
      } catch (error) {
            printl(`❌ 左滑操作失败: ${error.message}`);
      }
    }
   
    /**
   * 右滑操作
   * 从屏幕左侧滑动到右侧
   */
    swipeRight() {
      printl("👉 执行右滑操作");
      try {
            // 使用hid.swipHPercent执行水平右滑
            // 从屏幕宽度20%处滑动到80%处
            // hid.swipHPercent(startXPercent, endXPercent, yPercent, duration, step, type)
            const result = hid.swipHPercent(0.2, 0.8, 0.5, this.duration, 10, 1);
            printl(`✅ 右滑操作完成: ${result}`);
      } catch (error) {
            printl(`❌ 右滑操作失败: ${error.message}`);
      }
    }
   
    /**
   * 自定义滑动操作
   * @param {number} startXPercent - 起点X坐标百分比 (0.0 - 1.0)
   * @param {number} startYPercent - 起点Y坐标百分比 (0.0 - 1.0)
   * @param {number} endXPercent - 终点X坐标百分比 (0.0 - 1.0)
   * @param {number} endYPercent - 终点Y坐标百分比 (0.0 - 1.0)
   * @param {number} duration - 滑动持续时间(毫秒)
   */
    customSwipeByPercent(startXPercent, startYPercent, endXPercent, endYPercent, duration = this.duration) {
      printl(`🔄 执行自定义滑动: (${startXPercent*100}%, ${startYPercent*100}%) -> (${endXPercent*100}%, ${endYPercent*100}%)`);
      try {
            // 判断是水平滑动还是垂直滑动
            if (Math.abs(startXPercent - endXPercent) > Math.abs(startYPercent - endYPercent)) {
                // 水平滑动
                const result = hid.swipHPercent(startXPercent, endXPercent, startYPercent, duration, 10, 1);
                printl(`✅ 自定义滑动完成: ${result}`);
            } else {
                // 垂直滑动
                const result = hid.swipVPercent(startYPercent, endYPercent, startXPercent, duration, 10, 1);
                printl(`✅ 自定义滑动完成: ${result}`);
            }
      } catch (error) {
            printl(`❌ 自定义滑动失败: ${error.message}`);
      }
    }
   
    /**
   * 获取屏幕宽度
   * @returns {number} 屏幕宽度
   */
    getScreenWidth() {
      return this.screenWidth;
    }
   
    /**
   * 获取屏幕高度
   * @returns {number} 屏幕高度
   */
    getScreenHeight() {
      return this.screenHeight;
    }
}

/**
* 演示所有滑动操作
*/
function demonstrateAllSwipes() {
    printl("📱📱📱 AIWROK苹果滑动操作示例 📱📱📱");
    printl("========================================");
   
    // 创建滑动管理器实例
    const swipeManager = new SwipeManager(800); // 800毫秒持续时间
   
    // 执行上滑操作 (从80%高度滑动到20%高度)
    swipeManager.swipeUp();
   
    // 等待1秒
    const start = new Date().getTime();
    while (new Date().getTime() - start < 1000) {
      // 空循环等待
    }
   
    // 执行下滑操作 (从20%高度滑动到80%高度)
    swipeManager.swipeDown();
   
    // 等待1秒
    const start2 = new Date().getTime();
    while (new Date().getTime() - start2 < 1000) {
      // 空循环等待
    }
   
    // 执行左滑操作 (从80%宽度滑动到20%宽度)
    swipeManager.swipeLeft();
   
    // 等待1秒
    const start3 = new Date().getTime();
    while (new Date().getTime() - start3 < 1000) {
      // 空循环等待
    }
   
    // 执行右滑操作 (从20%宽度滑动到80%宽度)
    swipeManager.swipeRight();
   
    printl("&#127881; 所有滑动操作演示完成");
}

/**
* 主函数
*/
function main() {
    printl("&#127822;&#127822;&#127822; AIWROK苹果滑动操作示例 &#127822;&#127822;&#127822;");
    printl("====================================");
   
    // 演示所有滑动操作
    demonstrateAllSwipes();
   
    printl("&#128640; 滑动操作示例已启动,请查看日志输出");
}

// 启动示例
main();




页: [1]
查看完整版本: AIWROK软件苹果系统中实现四种基本滑动操作