自动发帖软件

标题: hid的滑动没有百分比坐标滑动吗 [打印本页]

作者: 发帖软件    时间: 昨天 08:59
标题: hid的滑动没有百分比坐标滑动吗
hid的滑动没有百分比坐标滑动吗
hid的滑动没有百分比坐标滑动吗 群发软件发帖工具

hid的滑动没有百分比坐标滑动吗 群发软件发帖工具

  1. // 🍎交流QQ群711841924群一,苹果内测群,528816639
  2. // 该示例演示如何使用百分比坐标进行滑动操作

  3. /**
  4. * 使用百分比坐标进行滑动的函数
  5. * @param {number} startXPercent - 起始点X坐标百分比 (0-1)
  6. * @param {number} startYPercent - 起始点Y坐标百分比 (0-1)
  7. * @param {number} endXPercent - 结束点X坐标百分比 (0-1)
  8. * @param {number} endYPercent - 结束点Y坐标百分比 (0-1)
  9. * @param {number} duration - 滑动持续时间(毫秒)
  10. */
  11. function swipeWithPercentCoordinates(startXPercent, startYPercent, endXPercent, endYPercent, duration) {
  12.     // 将百分比坐标转换为实际像素坐标
  13.     var startX = screen.percentToWidth(startXPercent);
  14.     var startY = screen.percentToHeight(startYPercent);
  15.     var endX = screen.percentToWidth(endXPercent);
  16.     var endY = screen.percentToHeight(endYPercent);
  17.    
  18.     // 执行滑动操作
  19.     hid.swip(startX, startY, endX, endY, duration, 0, 0);
  20.    
  21.     printl("已执行滑动操作: 从(" + startXPercent*100 + "%, " + startYPercent*100 + "%) 到 (" +
  22.            endXPercent*100 + "%, " + endYPercent*100 + "%),持续时间: " + duration + "ms");
  23. }

  24. /**
  25. * 模拟用户常用滑动操作的函数
  26. */
  27. function commonSwipeGestures() {
  28.     printl("=== 常用滑动操作示例 ===");
  29.    
  30.     // 1. 向右滑动 (例如在相册中向右切换图片)
  31.     printl("1. 向右滑动");
  32.     swipeWithPercentCoordinates(0.2, 0.5, 0.8, 0.5, 300);
  33.     sleep.millisecond(1000);
  34.    
  35.     // 2. 向左滑动 (例如在相册中向左切换图片)
  36.     printl("2. 向左滑动");
  37.     swipeWithPercentCoordinates(0.8, 0.5, 0.2, 0.5, 300);
  38.     sleep.millisecond(1000);
  39.    
  40.     // 3. 向上滑动 (例如向上滚动页面)
  41.     printl("3. 向上滑动");
  42.     swipeWithPercentCoordinates(0.5, 0.8, 0.5, 0.2, 500);
  43.     sleep.millisecond(1000);
  44.    
  45.     // 4. 向下滑动 (例如向下滚动页面)
  46.     printl("4. 向下滑动");
  47.     swipeWithPercentCoordinates(0.5, 0.2, 0.5, 0.8, 500);
  48.     sleep.millisecond(1000);
  49.    
  50.     // 5. 从屏幕底部向上滑动 (例如打开通知栏)
  51.     printl("5. 从底部向上滑动");
  52.     swipeWithPercentCoordinates(0.5, 0.9, 0.5, 0.1, 800);
  53.     sleep.millisecond(1000);
  54.    
  55.     printl("所有滑动操作演示完毕");
  56. }

  57. /**
  58. * 自定义滑动操作函数
  59. * @param {string} direction - 滑动方向 ("up", "down", "left", "right")
  60. * @param {number} duration - 滑动持续时间(毫秒)
  61. */
  62. function customSwipe(direction, duration) {
  63.     printl("执行自定义滑动: " + direction);
  64.    
  65.     switch(direction) {
  66.         case "up":
  67.             swipeWithPercentCoordinates(0.5, 0.7, 0.5, 0.3, duration);
  68.             break;
  69.         case "down":
  70.             swipeWithPercentCoordinates(0.5, 0.3, 0.5, 0.7, duration);
  71.             break;
  72.         case "left":
  73.             swipeWithPercentCoordinates(0.7, 0.5, 0.3, 0.5, duration);
  74.             break;
  75.         case "right":
  76.             swipeWithPercentCoordinates(0.3, 0.5, 0.7, 0.5, duration);
  77.             break;
  78.         default:
  79.             printl("未知的滑动方向: " + direction);
  80.     }
  81. }

  82. // 使用示例
  83. printl("=== 百分比坐标滑动示例 ===");

  84. // 检查HID是否开启
  85. if (hid.isOn()) {
  86.     printl("HID设备已开启");
  87.    
  88.     // 演示常用滑动操作
  89.     commonSwipeGestures();
  90.    
  91.     // 演示自定义滑动操作
  92.     printl("\n=== 自定义滑动操作 ===");
  93.     customSwipe("up", 400);
  94.     sleep.millisecond(500);
  95.     customSwipe("down", 400);
  96.     sleep.millisecond(500);
  97.     customSwipe("left", 300);
  98.     sleep.millisecond(500);
  99.     customSwipe("right", 300);
  100.    
  101.     printl("\n所有示例执行完毕");
  102. } else {
  103.     printl("错误: HID设备未开启,请先开启HID设备");
  104. }
复制代码







欢迎光临 自动发帖软件 (http://www.fatiegongju.com/) Powered by Discuz! X3.2