gpt4 book ai didi

android - 使用 adb 向 Android 手机发出捏合/捏合命令

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:53:19 27 4
gpt4 key购买 nike

到目前为止,我能够使用 adb 命令点击、滑动、解锁、安装/卸载和启动应用程序,但无法找到如何使用 adb 命令执行放大/缩小。

我有捏合/捏合的坐标,但不明白如何从终端使用 adb 命令触发它们。

例如,我们有命令 --> adb shell 输入 tap x y 所以在这里我们可以类似地用值/坐标替换 x 和 y 我想知道模拟捏合/捏合的方法。

我得到的捏入坐标如下。

{"id":0,"dumb":[{"events":[{"id":0,"pressure":1,"x":392.94117647058823,"y":607.4264705882354}],"action":0},{"events":[{"id":0,"pressure":1,"x":392.94117647058823,"y":607.4264705882354},{"id":1,"pressure":1,"x":327.05882352941177,"y":672.5735294117648}],"action":261},{"events":[{"id":0,"pressure":1,"x":392.94117647058823,"y":609.7794117647059},{"id":1,"pressure":1,"x":327.05882352941177,"y":670.2205882352941}],"action":2},{"events":[{"id":0,"pressure":1,"x":392.94117647058823,"y":612.1323529411765},{"id":1,"pressure":1,"x":327.05882352941177,"y":667.8676470588235}],"action":2},{"events":[{"id":0,"pressure":1,"x":392.94117647058823,"y":616.8382352941177},{"id":1,"pressure":1,"x":327.05882352941177,"y":663.1617647058823}],"action":2},{"events":[{"id":0,"pressure":1,"x":392.94117647058823,"y":626.25},{"id":1,"pressure":1,"x":327.05882352941177,"y":653.75}],"action":2},{"events":[{"id":0,"pressure":1,"x":392.94117647058823,"y":630.9558823529412},{"id":1,"pressure":1,"x":327.05882352941177,"y":649.0441176470589}],"action":2},{"events":[{"id":0,"pressure":1,"x":395.29411764705884,"y":635.6617647058823},{"id":1,"pressure":1,"x":324.70588235294116,"y":644.3382352941177}],"action":2},{"events":[{"id":0,"pressure":1,"x":397.64705882352945,"y":642.7205882352941},{"id":1,"pressure":1,"x":322.3529411764706,"y":637.2794117647059}],"action":2},{"events":[{"id":0,"pressure":1,"x":400,"y":649.7794117647059},{"id":1,"pressure":1,"x":320,"y":630.2205882352941}],"action":2},{"events":[{"id":0,"pressure":1,"x":402.3529411764706,"y":656.8382352941177},{"id":1,"pressure":1,"x":317.64705882352945,"y":623.1617647058823}],"action":2},{"events":[{"id":0,"pressure":1,"x":402.3529411764706,"y":661.5441176470589},{"id":1,"pressure":1,"x":317.64705882352945,"y":618.4558823529412}],"action":2},{"events":[{"id":0,"pressure":1,"x":404.7058823529412,"y":668.6029411764706},{"id":1,"pressure":1,"x":315.29411764705884,"y":611.3970588235294}],"action":2},{"events":[{"id":0,"pressure":1,"x":404.7058823529412,"y":673.3088235294118},{"id":1,"pressure":1,"x":315.29411764705884,"y":606.6911764705883}],"action":2},{"events":[{"id":0,"pressure":1,"x":404.7058823529412,"y":680.3676470588235},{"id":1,"pressure":1,"x":315.29411764705884,"y":599.6323529411765}],"action":2},{"events":[{"id":0,"pressure":1,"x":407.05882352941177,"y":685.0735294117648},{"id":1,"pressure":1,"x":312.94117647058823,"y":594.9264705882354}],"action":2},{"events":[{"id":0,"pressure":1,"x":407.05882352941177,"y":687.4264705882354},{"id":1,"pressure":1,"x":312.94117647058823,"y":592.5735294117648}],"action":2},{"events":[{"id":0,"pressure":1,"x":409.4117647058824,"y":689.7794117647059},{"id":1,"pressure":1,"x":310.5882352941177,"y":590.2205882352941}],"action":2},{"events":[{"id":0,"pressure":1,"x":411.7647058823529,"y":694.4852941176471},{"id":1,"pressure":1,"x":308.2352941176471,"y":585.5147058823529}],"action":2},{"events":[{"id":0,"pressure":1,"x":411.7647058823529,"y":699.1911764705883},{"id":1,"pressure":1,"x":308.2352941176471,"y":580.8088235294118}],"action":2},{"events":[{"id":0,"pressure":1,"x":414.11764705882354,"y":706.25},{"id":1,"pressure":1,"x":305.88235294117646,"y":573.75}],"action":2},{"events":[{"id":0,"pressure":1,"x":416.47058823529414,"y":713.3088235294118},{"id":1,"pressure":1,"x":303.5294117647059,"y":566.6911764705883}],"action":2},{"events":[{"id":0,"pressure":1,"x":418.8235294117647,"y":715.6617647058824},{"id":1,"pressure":1,"x":301.1764705882353,"y":564.3382352941177}],"action":2},{"events":[{"id":0,"pressure":1,"x":418.8235294117647,"y":718.0147058823529},{"id":1,"pressure":1,"x":301.1764705882353,"y":561.9852941176471}],"action":2},{"events":[{"id":0,"pressure":1,"x":418.8235294117647,"y":720.3676470588235},{"id":1,"pressure":1,"x":301.1764705882353,"y":559.6323529411765}],"action":2},{"events":[{"id":0,"pressure":1,"x":421.1764705882353,"y":727.4264705882354},{"id":1,"pressure":1,"x":298.8235294117647,"y":552.5735294117648}],"action":2},{"events":[{"id":0,"pressure":1,"x":421.1764705882353,"y":732.1323529411765},{"id":1,"pressure":1,"x":298.8235294117647,"y":547.8676470588235}],"action":2},{"events":[{"id":0,"pressure":1,"x":423.5294117647059,"y":739.1911764705883},{"id":1,"pressure":1,"x":296.47058823529414,"y":540.8088235294118}],"action":2},{"events":[{"id":0,"pressure":1,"x":425.88235294117646,"y":746.25},{"id":1,"pressure":1,"x":294.11764705882354,"y":533.75}],"action":2},{"events":[{"id":0,"pressure":1,"x":425.88235294117646,"y":753.3088235294118},{"id":1,"pressure":1,"x":294.11764705882354,"y":526.6911764705883}],"action":2},{"events":[{"id":0,"pressure":1,"x":428.2352941176471,"y":758.0147058823529},{"id":1,"pressure":1,"x":291.7647058823529,"y":521.9852941176471}],"action":2},{"events":[{"id":0,"pressure":1,"x":435.29411764705884,"y":765.0735294117648},{"id":1,"pressure":1,"x":284.70588235294116,"y":514.9264705882354}],"action":2},{"events":[{"id":0,"pressure":1,"x":440,"y":769.7794117647059},{"id":1,"pressure":1,"x":280,"y":510.22058823529414}],"action":2},{"events":[{"id":0,"pressure":1,"x":440,"y":779.1911764705883},{"id":1,"pressure":1,"x":280,"y":500.80882352941177}],"action":2},{"events":[{"id":0,"pressure":1,"x":444.7058823529412,"y":788.6029411764706},{"id":1,"pressure":1,"x":275.29411764705884,"y":491.39705882352945}],"action":2},{"events":[{"id":0,"pressure":1,"x":451.7647058823529,"y":800.3676470588235},{"id":1,"pressure":1,"x":268.2352941176471,"y":479.63235294117646}],"action":2},{"events":[{"id":0,"pressure":1,"x":456.47058823529414,"y":812.1323529411765},{"id":1,"pressure":1,"x":263.5294117647059,"y":467.86764705882354}],"action":2},{"events":[{"id":0,"pressure":1,"x":461.1764705882353,"y":821.5441176470589},{"id":1,"pressure":1,"x":258.8235294117647,"y":458.4558823529412}],"action":2},{"events":[{"id":0,"pressure":1,"x":465.88235294117646,"y":833.3088235294118},{"id":1,"pressure":1,"x":254.11764705882354,"y":446.69117647058823}],"action":2},{"events":[{"id":0,"pressure":1,"x":470.5882352941177,"y":840.3676470588235},{"id":1,"pressure":1,"x":249.41176470588235,"y":439.63235294117646}],"action":2},{"events":[{"id":0,"pressure":1,"x":475.29411764705884,"y":847.4264705882354},{"id":1,"pressure":1,"x":244.7058823529412,"y":432.5735294117647}],"action":2},{"events":[{"id":0,"pressure":1,"x":477.64705882352945,"y":854.4852941176471},{"id":1,"pressure":1,"x":242.3529411764706,"y":425.5147058823529}],"action":2},{"events":[{"id":0,"pressure":1,"x":482.3529411764706,"y":863.8970588235294},{"id":1,"pressure":1,"x":237.64705882352942,"y":416.1029411764706}],"action":2},{"events":[{"id":0,"pressure":1,"x":484.7058823529412,"y":870.9558823529412},{"id":1,"pressure":1,"x":235.29411764705884,"y":409.04411764705884}],"action":2},{"events":[{"id":0,"pressure":1,"x":489.4117647058824,"y":875.6617647058824},{"id":1,"pressure":1,"x":230.58823529411765,"y":404.3382352941177}],"action":2},{"events":[{"id":0,"pressure":1,"x":489.4117647058824,"y":878.0147058823529},{"id":1,"pressure":1,"x":230.58823529411765,"y":401.9852941176471}],"action":2},{"events":[{"id":0,"pressure":1,"x":491.764705882353,"y":882.7205882352941},{"id":1,"pressure":1,"x":228.23529411764707,"y":397.2794117647059}],"action":2},{"events":[{"id":0,"pressure":1,"x":494.11764705882354,"y":885.0735294117648},{"id":1,"pressure":1,"x":225.88235294117646,"y":394.9264705882353}],"action":2},{"events":[{"id":0,"pressure":1,"x":496.47058823529414,"y":892.1323529411765},{"id":1,"pressure":1,"x":223.52941176470588,"y":387.86764705882354}],"action":2},{"events":[{"id":0,"pressure":1,"x":501.1764705882353,"y":899.1911764705883},{"id":1,"pressure":1,"x":218.82352941176472,"y":380.80882352941177}],"action":2},{"events":[{"id":0,"pressure":1,"x":503.5294117647059,"y":908.6029411764706},{"id":1,"pressure":1,"x":216.47058823529412,"y":371.39705882352945}],"action":2},{"events":[{"id":0,"pressure":1,"x":505.88235294117646,"y":908.6029411764706},{"id":1,"pressure":1,"x":214.11764705882354,"y":371.39705882352945}],"action":2},{"events":[{"id":0,"pressure":1,"x":505.88235294117646,"y":910.9558823529412},{"id":1,"pressure":1,"x":214.11764705882354,"y":369.04411764705884}],"action":2},{"events":[{"id":0,"pressure":1,"x":505.88235294117646,"y":913.3088235294118},{"id":1,"pressure":1,"x":214.11764705882354,"y":366.69117647058823}],"action":2},{"events":[{"id":0,"pressure":1,"x":505.88235294117646,"y":913.3088235294118}],"action":1},{"events":[{"id":0,"pressure":1,"x":505.88235294117646,"y":913.3088235294118},{"id":1,"pressure":1,"x":214.11764705882354,"y":366.69117647058823}],"action":262}],"eventType":"MOTION"}

最佳答案

您可以使用 adb geteventsendevent 来完成。
使用 adb 连接您的设备。按照以下步骤操作。

  1. 识别您的输入设备:
    在您的设备上打开任何图像。要列出输入设备,请运行

    $ adb shell getevent   
    add device 1: /dev/input/event7
    name: "msm8226-tapan9302-snd-card Headset Jack"
    add device 2: /dev/input/event6
    name: "msm8226-tapan9302-snd-card Button Jack"
    add device 3: /dev/input/event2
    name: "synaptics_dsx_i2c"
    add device 4: /dev/input/event4
    name: "qpnp_pon"

    放大/缩小图像,您应该看到一些连续的日志,如

    /dev/input/event2: 0003 0030 00000005
    /dev/input/event2: 0000 0000 00000000
    /dev/input/event2: 0003 002f 00000000
    /dev/input/event2: 0003 0036 00000144
    /dev/input/event2: 0003 003a 00000079
    /dev/input/event2: 0000 0000 00000000
    /dev/input/event2: 0003 0036 00000142

    确认 /dev/input/event2 是我的目标设备的输入设备名称。

  2. 获取准确的getevent并将getevent转换为sendevent:

    确保您的屏幕已打开并打开了一些图像,
    在提示符下运行以下命令。

    $ adb shell getevent | grep dev/input/event2 > getevent_input.txt

    当上述程序运行时,在您手机上的图像上捏合/捏合。

    完成后,终止上述命令 Ctrl + C
    打开文件 getevent_input.txt 并从中删除第一行 "add device X:/dev/input/eventX"

    由于 getevent 返回十进制值,而 sendevent 获取十六进制值。
    我们要做上面的转换。
    此脚本 hex_to_dec.py这是工作。感谢this家伙!

    $./hex_to_dec.py  getevent_input.txt 

    生成文件getevent_input.scr,现在将此文件重命名为.sh

    $ mv getevent_input.scr  sendevent_input.sh

    打开文件sendevent_input.sh,删除第二行"echoing – drawing function"并保存。

  3. 在设备上运行。
    传输 sendevent_input.sh 到设备。

    $ adb push sendevent_input.sh /sdcard/
    1615 KB/s (64379 bytes in 0.038s)

    确保您的设备已打开图像,并且屏幕未关闭。

    $ adb shell sh /sdcard/sendevent_input.sh

对我来说非常好,如果这就是你要找的。
对于可见的结果,启用 Show touches在开发人员选项中。

环境:Motorola Moto G (Android 4.4.4)Ubuntu 12.04 上使用 ADB (v 1.0.31)

关于android - 使用 adb 向 Android 手机发出捏合/捏合命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25363526/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com