1

I want to keep the camera button pressed to take continuous snaps. I tried this code:

#!/system/bin/sh
am start -n com.android.camera2/com.android.camera.CameraLauncher
sleep 1
count=1
x=2
while [ $count -le 1 ]
do 
    input touchscreen tap 560 1800
    input touchscreen tap 560 1800
    input touchscreen tap 560 1800
    input touchscreen tap 560 1800
    input touchscreen tap 560 1800
    input touchscreen tap 560 1800
    input touchscreen tap 560 1800
    input touchscreen tap 560 1800
done

But it does not hold the button. It taps with a delay.

Then I tried this:

 sendevent /dev/input/event0 3 53 300
 sendevent /dev/input/event0 3 54 400
 sendevent /dev/input/event0 3 48 5
 sendevent /dev/input/event0 3 58 50
 sendevent /dev/input/event0 0 2 0
 sendevent /dev/input/event0 0 0 0
 sleep 1
 sendevent /dev/input/event0 0 2 0
 sendevent /dev/input/event0 0 0 0

this code gets executed but the effect is not seen on the touchscreen

Alex P.
  • 30,437
  • 17
  • 118
  • 169
user3659556
  • 21
  • 2
  • 4
  • This is the second code i tried . due to some reason the code is not indented properly sendevent /dev/input/event0 3 53 300 sendevent /dev/input/event0 3 54 400 sendevent /dev/input/event0 3 48 5 sendevent /dev/input/event0 3 58 50 sendevent /dev/input/event0 0 2 0 sendevent /dev/input/event0 0 0 0 sleep 1 sendevent /dev/input/event0 0 2 0 sendevent /dev/input/event0 0 0 0 – user3659556 May 22 '14 at 03:05
  • there is no common solution to your question. Devices have different /dev/input definitions. If you have the rooted device, you can use internal API of WindowsManager to inject events at Java level. – Jiang YD May 22 '14 at 04:00
  • your second attempt looks like the code from my answer here https://stackoverflow.com/a/17263093/1778421 - why didn't you go to the page linked in that answer? – Alex P. Dec 05 '17 at 19:56

3 Answers3

2

This will work adb shell input swipe 660 2200 660 2200 5000

The last value is duration

Bandu M
  • 139
  • 1
  • 4
1

You can swipe and hold with 'input motionevent'

input motionevent DOWN x y
input motionevent MOVE x y
input motionevent UP x y

"this code gets executed but the effect is not seen on the touchscreen"

try "adb shell su -c 'YOUR COMMAND'"

it helped me. if you send a command without su, then the code will not answer anything

NSeed
  • 11
  • 2
  • Welcome to Stack Overflow! While this code may solve the question, [including an explanation](//meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanations and give an indication of what limitations and assumptions apply. – Yunnosch Jan 04 '22 at 17:05
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 04 '22 at 21:59
-1

There is workaround for this, You can use swipe for long press: "adb shell input swipe 560 1800 560 1800 "

Its working for me