MaaXYZ / MaaFramework

基于图像识别的自动化黑盒测试框架 | An automation black-box testing framework based on image recognition
GNU Lesser General Public License v3.0
1.51k stars 178 forks source link

关于Pipeline协议中“动作类型”,是否支持多指操作,比如双指捏合等 #419

Open 2236863943-name opened 1 week ago

2236863943-name commented 1 week ago

Pipeline协议中动作类型有以下几种, DoNothing、Click、Swipe、Key、InputText、StartApp、StopApp、StopTask、Custom。 请问是否支持多指操作?比如双指捏合等。

MistEO commented 1 week ago

可以在 CustomAction 中使用 controller.touch 系列函数实现,第一个参数 contact 就是手指编号

2236863943-name commented 1 week ago

请问有相关使用文档吗?

可以在 CustomAction 中使用 controller.touch 系列函数实现,第一个参数 contact 就是手指编号

2236863943-name commented 1 week ago
{
  "PinchGesture": {
    "action": "Custom",
    "custom_action": "performPinchGesture",
    "custom_action_param": {
      "finger1_start": [100, 100],
      "finger1_end": [500, 500],
      "finger2_start": [900, 100],
      "finger2_end": [500, 500]
    }
  }
}
def performPinchGesture(param):
    from controller import touch

    # 模拟第一个手指的按下、移动和抬起
    touch.down(param['finger1_start'][0], param['finger1_start'][1], 0)
    touch.move(param['finger1_end'][0], param['finger1_end'][1], 0)
    touch.up(0)

    # 模拟第二个手指的按下、移动和抬起
    touch.down(param['finger2_start'][0], param['finger2_start'][1], 1)
    touch.move(param['finger2_end'][0], param['finger2_end'][1], 1)
    touch.up(1)

请问是这样吗?我该把python代码放在哪个文件里?

MistEO commented 1 week ago

https://github.com/MaaXYZ/MaaFramework/blob/main/test/python/binding_test.py#L91

可以参考这个。用 https://github.com/MaaXYZ/MaaFramework/blob/main/docs/zh_cn/1.1-%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B.md#%E4%BD%BF%E7%94%A8-json-%E4%BD%8E%E4%BB%A3%E7%A0%81%E7%BC%96%E7%A8%8B%E4%BD%86%E5%AF%B9%E5%A4%8D%E6%9D%82%E4%BB%BB%E5%8A%A1%E4%BD%BF%E7%94%A8%E8%87%AA%E5%AE%9A%E4%B9%89%E9%80%BB%E8%BE%91 这种方式,或者自己集成

dongwlin commented 1 week ago
{
  "PinchGesture": {
    "action": "Custom",
    "custom_action": "performPinchGesture",
    "custom_action_param": {
      "finger1_start": [100, 100],
      "finger1_end": [500, 500],
      "finger2_start": [900, 100],
      "finger2_end": [500, 500]
    }
  }
}
def performPinchGesture(param):
    from controller import touch

    # 模拟第一个手指的按下、移动和抬起
    touch.down(param['finger1_start'][0], param['finger1_start'][1], 0)
    touch.move(param['finger1_end'][0], param['finger1_end'][1], 0)
    touch.up(0)

    # 模拟第二个手指的按下、移动和抬起
    touch.down(param['finger2_start'][0], param['finger2_start'][1], 1)
    touch.move(param['finger2_end'][0], param['finger2_end'][1], 1)
    touch.up(1)

请问是这样吗?我该把python代码放在哪个文件里?

思路是对的,但python代码部分就...