Android Tasker App Advance Input Shell command - android

I have this shell command in android input tap 653 100 using Tasker app to simulate a tap command. This one is working but how do i execute the command for say 50 times or 100 times? I know I can add more task in Tasker App but Thats a lot of work. So if you know anything or any command that i can input like for example input tap 653 100 -100 or input tap 653 100 -50 which is -100 and -50 are for how many times a command should execute or how do i loop and execute a task in Tasker app. Thanks

for q in `seq 1 50`; do input tap 653 100 ; done
Should do the trick...

Related

Fire double tap command to android device using adb

I have been trying to send a command to my device to double tap on the screen.
I tried to send this
adb shell input tap 600 1000
adb shell input tap 600 1000
However, it does not result into a doubletap.
Anyone willing to help me out?
This has worked for me pretty reliably until android 10; however, it no longer works on android 11 :(
I figured out a way to do it like this:
input tap <x> <y>&
sleep 0.1
input tap <x> <y>
as in
adb shell "input tap 520 1150& sleep 0.1; input tap 520 1150"
When digging around android 11 it seems that input command spawns up a JVM that is very slow, and it slowed down enough on android 11 to about 0.5 seconds, so the system does not recognize it as a double tap.
You can speed up the taps (or any user input) by including it in the same adb shell command. Previously I did this:
adb shell "input tap 520 1150; input tap 520 1150"
This will be easier on your system memory (as only one input command is executing at once) and may work pre android 11, but the one with & and explicit sleep between the two taps is what I switched to now.

Issues running multiple Shells on Tasker for Android

I'm currently using Tasker on Android and I want to create a task using 2 Run Shell's. The setup I have is...
1.Wait
MS 0 Seconds 10 Minutes 0 Hours 0
2.Run Shell
Command input tap 550 580
3.Wait
MS 0 Seconds 10 Minutes 0 Hours 0
4.Run Shell
Command input tap 550 1800
Currently the first Run Shell works fine but the second Run Shell never executes. Don't understand why it's not running the second Run Shell.
there might be few reasons for that:
you are pointing wrong coordinates
app, you're trying to interact with, does not support accessibility features
you do not have accessibility features enabled
other
to achieve your goal, I'd recommend using Tasker's plugin called AutoInput
as it gives you way more control over what you click, focus, type etc

how can i reduce the time lag to execute an adb shell command to perform swipe input on my android device

I want to input swipe commands back to back using a c program and adb shell to my android device .
But the lag between the commands is preventing me from achieving my goal.
Is there anyway to reduce this lag??
You can record some input and repeat it directly.
For example:
Record:
cat /dev/input/event0 > inputdata
Replay:
cat inputdata > /dev/input/event0
To find the correct event number you can use the getevent -p command.
There is no "lag between the commands". The input command is a java application and it takes about a second (depending on your device) to launch it. So you can not inject 2 events back to back faster than that.
You could either write your own input command which would accept multiple sets of coordinates in one take thus eliminating the need to run the command multiple times. Or you could use series of sendevent commands for emulating your gesture instead.

How do I clear notifications using ADB shell

I know I can unlock the screen, pull down the notifications, and press the clear notifications button, but there's got to be a way to clear the notifications through ADB, right? I'm guessing it's some Intent sent through the 'am' command, or maybe something even simpler, but I can't seem to find anything on the net. All I'm getting is Java code for use with an apk.
Edit: I should probably mention that I'm running on 4.3, sometimes commands may vary between versions.
Try:
adb shell service call notification 1
If you know the type of the device and Android version, you can clear notifications using ADB without having rooted device.
The idea is to pull down notifications and swipe away all notifications one by one.
Pull down:
adb shell input swipe 0 0 0 300
Swipe away:
adb shell input swipe 0 400 300 400
It is important to mention, that the (x,y) is something that vary between different type of devices and Android versions. You will need to find by several checks what is the best x,y for you.
The full script
adb shell input swipe 0 0 0 300
num=$(adb shell dumpsys notification | grep NotificationRecord | wc -l)
echo $num
while [ $num -gt 0 ]; do
adb shell input swipe 0 400 300 400
num=$(( $num - 1 ))
done
More details can be found here: https://www.sromku.com/blog/android-adb-clear-notifications

How can I use adb to send a longpress key event?

I can use something like:
adb shell input keyevent 4
and this will send a single 'Back' button press to my device. How can I send a longpress?
Thanks
You can try this command:
adb shell input touchscreen swipe 170 187 170 187 2000
Your application position on screen is
170, 187; delay time is 2000 (ms);
Long press HOME key:
adb shell sendevent /dev/input/event2 1 172 1
adb shell sendevent /dev/input/event2 0 0 0
timeout 1
adb shell sendevent /dev/input/event2 1 172 0
adb shell sendevent /dev/input/event2 0 0 0
You can goto cmd and type adb shell getevent | find "event2" ; long press HOME key to see more.
Since this commit in Android 4.4 it is possibile to use:
adb shell input keyevent --longpress KEYCODE_L
This other commit further improved the behaviour.
When you want to delete something or repeat some Event or just input a lot of numbers, you can use code like the following. It will imitate a longpress on a keyboard:
adb shell input keyevent KEYCODE_FORWARD_DEL KEYCODE_FORWARD_DEL KEYCODE_FORWARD_DEL //delete 3 times
adb shell input keyevent KEYCODE_1 KEYCODE_1 KEYCODE_1 //input value '111'
You can repeat the event or input things without limits, just like a Longpress on the key. It's the same thing. You can define your own longpass and times Now
This link discusses a similar problem, but the device in question (a Nexus One device)has the menu/home/back/search buttons as part of the touchscreen, not physical keys.
This other one appears to be more inline with injecting a physical key input, but requires accessing the *.kl file for your devices driver to determine the device, type, key-code, value-press, and value-release codes for that specific device.
However, the common link between the two appears to be
adb shell sleep n
, where n is the length (in seconds) of the press duration.
Hopefully this might be of some use.
Well, this developer link show the keycode is 128, which i already test, but no expected result
You can check this link and this link. They show how to find it.
This might be too late to answer but surely will help others.
Please use below cmd to achieve long press.
adb shell input keyevent 5 sleep 5

Categories

Resources