I figured out how to emulate key presses

31,147 views
Skip to first unread message

HypnoToad

unread,
Jan 29, 2011, 12:45:10 PM1/29/11
to Tasker
Yesterday I figured out how to emulate key presses. I was trying to
write a task that simply pushed the number 4 during a call. Everything
that I read online said that this couldn't be done, not only does
Tasker not have this capability but Android won't accept input from
other programs during a call. But, as with all things Android, where
there's a will there's a way.

The only drawback to my method is that you need root permissions.
Sorry.

Here are the steps to start emulating key presses with Tasker.

1. Root your phone

universal androot and the cyanogen wiki are good sources for
this. google it.

2. Download the needed software

you will need Tasker (duh) and the "Locale execute plugin"

http://www.appbrain.com/app/locale-execute-plug-in/de.elmicha.app.LocaleExecute

3. Create your task

to create your task in tasker open the "plugin" section, select
"execute", then select "edit"
enter your key emulation commands.

there are two different commands that you can use to do this the
first command is "input keyevent <event_code>
" (without quotes and the <event_code> represents a number from the
following list)

0 --> "KEYCODE_UNKNOWN"
1 --> "KEYCODE_MENU"
2 --> "KEYCODE_SOFT_RIGHT"
3 --> "KEYCODE_HOME"
4 --> "KEYCODE_BACK"
5 --> "KEYCODE_CALL"
6 --> "KEYCODE_ENDCALL"
7 --> "KEYCODE_0"
8 --> "KEYCODE_1"
9 --> "KEYCODE_2"
10 --> "KEYCODE_3"
11 --> "KEYCODE_4"
12 --> "KEYCODE_5"
13 --> "KEYCODE_6"
14 --> "KEYCODE_7"
15 --> "KEYCODE_8"
16 --> "KEYCODE_9"
17 --> "KEYCODE_STAR"
18 --> "KEYCODE_POUND"
19 --> "KEYCODE_DPAD_UP"
20 --> "KEYCODE_DPAD_DOWN"
21 --> "KEYCODE_DPAD_LEFT"
22 --> "KEYCODE_DPAD_RIGHT"
23 --> "KEYCODE_DPAD_CENTER"
24 --> "KEYCODE_VOLUME_UP"
25 --> "KEYCODE_VOLUME_DOWN"
26 --> "KEYCODE_POWER"
27 --> "KEYCODE_CAMERA"
28 --> "KEYCODE_CLEAR"
29 --> "KEYCODE_A"
30 --> "KEYCODE_B"
31 --> "KEYCODE_C"
32 --> "KEYCODE_D"
33 --> "KEYCODE_E"
34 --> "KEYCODE_F"
35 --> "KEYCODE_G"
36 --> "KEYCODE_H"
37 --> "KEYCODE_I"
38 --> "KEYCODE_J"
39 --> "KEYCODE_K"
40 --> "KEYCODE_L"
41 --> "KEYCODE_M"
42 --> "KEYCODE_N"
43 --> "KEYCODE_O"
44 --> "KEYCODE_P"
45 --> "KEYCODE_Q"
46 --> "KEYCODE_R"
47 --> "KEYCODE_S"
48 --> "KEYCODE_T"
49 --> "KEYCODE_U"
50 --> "KEYCODE_V"
51 --> "KEYCODE_W"
52 --> "KEYCODE_X"
53 --> "KEYCODE_Y"
54 --> "KEYCODE_Z"
55 --> "KEYCODE_COMMA"
56 --> "KEYCODE_PERIOD"
57 --> "KEYCODE_ALT_LEFT"
58 --> "KEYCODE_ALT_RIGHT"
59 --> "KEYCODE_SHIFT_LEFT"
60 --> "KEYCODE_SHIFT_RIGHT"
61 --> "KEYCODE_TAB"
62 --> "KEYCODE_SPACE"
63 --> "KEYCODE_SYM"
64 --> "KEYCODE_EXPLORER"
65 --> "KEYCODE_ENVELOPE"
66 --> "KEYCODE_ENTER"
67 --> "KEYCODE_DEL"
68 --> "KEYCODE_GRAVE"
69 --> "KEYCODE_MINUS"
70 --> "KEYCODE_EQUALS"
71 --> "KEYCODE_LEFT_BRACKET"
72 --> "KEYCODE_RIGHT_BRACKET"
73 --> "KEYCODE_BACKSLASH"
74 --> "KEYCODE_SEMICOLON"
75 --> "KEYCODE_APOSTROPHE"
76 --> "KEYCODE_SLASH"
77 --> "KEYCODE_AT"
78 --> "KEYCODE_NUM"
79 --> "KEYCODE_HEADSETHOOK"
80 --> "KEYCODE_FOCUS"
81 --> "KEYCODE_PLUS"
82 --> "KEYCODE_MENU"
83 --> "KEYCODE_NOTIFICATION"
84 --> "KEYCODE_SEARCH"
85 --> "TAG_LAST_KEYCODE"

I was trying to press the number 4 so the command I used to do this
was "input keyevent 11"

As you can see it's possible to emulate just about any key which makes
this very powerful. you can now write a task to open a program and
navigate around it.

The second command is a bit easier but less powerful. The syntax is
"input text <string>" < string > being whatever you want to send to
your phone. So, for me, the command was "input text 4" but had I been
trying to enter the number 4000 I could have used "input text 4000".
Using this method you can't send commands to emulate keys such a menu
or back but, depending on what your trying to emulate, you can
accomplish in one command what might take several "input keyevent"
commands.

IMPORTANT: put an exclamation point before all of your commands.
(example: !input keyevent 11) This tells Locale Execute Plug-in to run
the command a root.

You can run several commands in a row by placing each of them on a
separate line.

After you have your command(s) typed out press the back button to save
then run you task to test it out. The first time it runs you may be
prompted to grant superuser permissions.

Let me know if you found this useful or if you need help. Thanks.

Sean

unread,
Jan 29, 2011, 1:00:25 PM1/29/11
to tas...@googlegroups.com
Nice find.

baudi

unread,
Jan 29, 2011, 1:14:36 PM1/29/11
to Tasker
This is fantastic! Playing with it now.

On Jan 29, 12:45 pm, HypnoToad <pimpdaddysh...@gmail.com> wrote:
> Yesterday I figured out how to emulate key presses. I was trying to
> write a task that simply pushed the number 4 during a call. Everything
> that I read online said that this couldn't be done, not only does
> Tasker not have this capability but Android won't accept input from
> other programs during a call. But, as with all things Android, where
> there's a will there's a way.
>
> The only drawback to my method is that you need root permissions.
> Sorry.
>
> Here are the steps to start emulating key presses with Tasker.
>
> 1. Root your phone
>
>      universal androot and the cyanogen wiki are good sources for
> this. google it.
>
> 2. Download the needed software
>
>      you will need Tasker (duh) and the "Locale execute plugin"
>
>      http://www.appbrain.com/app/locale-execute-plug-in/de.elmicha.app.Loc...

baudi

unread,
Jan 29, 2011, 1:19:32 PM1/29/11
to Tasker
Now if we could emulate a button-click...

On Jan 29, 12:45 pm, HypnoToad <pimpdaddysh...@gmail.com> wrote:
> Yesterday I figured out how to emulate key presses. I was trying to
> write a task that simply pushed the number 4 during a call. Everything
> that I read online said that this couldn't be done, not only does
> Tasker not have this capability but Android won't accept input from
> other programs during a call. But, as with all things Android, where
> there's a will there's a way.
>
> The only drawback to my method is that you need root permissions.
> Sorry.
>
> Here are the steps to start emulating key presses with Tasker.
>
> 1. Root your phone
>
>      universal androot and the cyanogen wiki are good sources for
> this. google it.
>
> 2. Download the needed software
>
>      you will need Tasker (duh) and the "Locale execute plugin"
>
>      http://www.appbrain.com/app/locale-execute-plug-in/de.elmicha.app.Loc...

HypnoToad

unread,
Jan 29, 2011, 2:45:20 PM1/29/11
to Tasker
I've got you covered.

23 --> "KEYCODE_DPAD_CENTER"

that's the code for a click.

fubaya

unread,
Jan 29, 2011, 7:27:22 PM1/29/11
to Tasker
This may or may not be helpful. This will write the key you want to a
file then use the execute plugin to look up it's code and run the
"input keyevent <code>"

Save this list in a file named /sdcard/Tasker/keycode. I reordered it
to make it easier to look up the codes visually, but it can be in any
order. But the rest of the edits are important for this to work. The
edits were also to simplify it visually and for looking things up. '54
--> "KEYCODE_Z" was edited to 'z 54' for example so you can just type
a Z instead of KEYCODE_Z.

a 29
b 30
c 31
d 32
e 33
f 34
g 35
h 36
i 37
j 38
k 39
l 40
m 41
n 42
o 43
p 44
q 45
r 46
s 47
t 48
u 49
v 50
w 51
x 52
y 53
z 54
0 7
1 8
2 9
3 10
4 11
5 12
6 13
7 14
8 15
9 16
menu 1
soft_right 2
home 3
back 4
call 5
endcall 6
star 17
pound 18
dpad_up 19
dpad_down 20
dpad_left 21
dpad_right 22
dpad_center 23
volume_up 24
volume_down 25
power 26
camera 27
clear 28
comma 55
period 56
alt_left 57
alt_right 58
shift_left 59
shift_right 60
tab 61
space 62
sym 63
explorer 64
envelope 65
enter 66
del 67
grave 68
minus 69
equals 70
left_bracket 71
right_bracket 72
backslash 73
semicolon 74
apostrophe 75
slash 76
at 77
num 78
headsethook 79
focus 80
plus 81
notification 83
search 84
tag_last_keycode 85

Then use this as the line of code for the Locale Execute Plugin:

@! input keyevent $(grep -i "^$(cat sdcard/Tasker/keyin) " /sdcard/
Tasker/keycode | awk '{ print $1 }')

Now make this task:

1- Write File: Tasker/keyin [text or variable]
The text or variable will be anything from the left column of the
list, so it could be Z, plus, camera, 5, b ...etc (not case sensitive)

2- Execute: @! input keyevent grep -i "^$(cat sdcard/Tasker/keyin) " /
sdcard/Tasker/keycode | awk '{ print $1 }'

3-(optional) Variable Clear (if you use a variable in step 1)

If you want to type a z, you can put a z in the first step and the
plugin will look up it's code and run the right command.

For more flexibility you can make the first step write a variable,
like %KEY, then you can use this task in a couple different ways.
First, you could be writing a different task and set %KEY then call
this task. Second, you can set a "variable set" profile to run this
task when %KEY is set, just make sure to use the optional third step
to clear the variable when it's done. So then to use the key press
trick, all you'd need to do in a task is set the variable to the key
you want pressed and it will automatically do it.

fubaya

unread,
Jan 29, 2011, 7:38:34 PM1/29/11
to Tasker
err, sorry, you need to change a "1" with a "2" in that command:
Change:
awk '{ print $1 }
to:
awk '{ print $2 }

Peter Radcliffe

unread,
Jan 30, 2011, 9:28:37 AM1/30/11
to Tasker
fubaya <jdm...@gmail.com> probably said:
>err, sorry, you need to change a "1" with a "2" in that command:
>Change:
>awk '{ print $1 }
>to:
>awk '{ print $2 }

Pet peeve. If you're piping grep into awk it can always be more
efficient. You can also read directly from files with awk, do
caseless matching and exit once you've found the right line (no need
to scan the rest of the file if the answer you wanted was on the first
line).

It gets a little more complicated but you can do it all in one process
rather than three. Even if you don't want to use the full complicated
line it'll me marginally faster if you put '; exit' after the print $2.

] @! input keyevent $(grep -i "^$(cat sdcard/Tasker/keyin) " /sdcard/
] Tasker/keycode | awk '{ print $2 }')

becomes

@! input keyevent $(awk 'BEGIN {getline k < "/sdcard/Tasker/keyin)"} {if (match($0,tolower(k)" ")==1) {print $2; exit}}' /sdcard/Tasker/keycode)


Though I would also hope there was a better way to get the input
character into the execute plugin. Can it not access tasker variables?

P.

--
pir

fubaya

unread,
Jan 30, 2011, 11:50:34 AM1/30/11
to Tasker
On Jan 30, 9:28 am, Peter Radcliffe <p...@pir.net> wrote:
> Though I would also hope there was a better way to get the input
> character into the execute plugin. Can it not access tasker variables?

Unfortunately it can't.

I normally have the same pet peeve, but the two commands are easier
for people to understand and execution time is about the same.

mike p

unread,
Jan 30, 2011, 10:37:33 PM1/30/11
to tas...@googlegroups.com


On Saturday, January 29, 2011 12:45:10 PM UTC-5, HypnoToad wrote:


I was trying to press the number 4 so the command I used to do this
was "input keyevent 11"


Having some trouble with this. I'm starting up SK Sync with a tasker task and I'd like to Start Sync.

Problem is, I can't even get a Menu press to work.  None of the Execute emulations see to do anything :(
I do get the SU permissions Allow screen, and I get the toast notification, but the keypresses don't seem to trigger.

Any ideas?

fubaya

unread,
Jan 31, 2011, 12:06:17 AM1/31/11
to Tasker
On Jan 30, 10:37 pm, mike p <m...@nocompany.org> wrote:
> Having some trouble with this.

There are two menu codes, "input keyevent 82" works for me, "input
keyevent 1" doesn't seem to do anything. Have you tried 82? (crossing
fingers that it's that simple)

HypnoToad

unread,
Jan 31, 2011, 12:54:19 AM1/31/11
to Tasker
I downloaded SK Sync and checked it out. It looks like, after tasker
launches the app, you need to emulate the down button on the D-pad
twice, then emulate the center button on the D-pad (aka "click").

!input keyevent 20
!input keyevent 20
!input keyevent 23

That's what I used to get syncing started. Let me know if this works
for you or if you need more help.

HypnoToad

unread,
Jan 31, 2011, 1:00:49 AM1/31/11
to Tasker
That's a good catch. keyevent 1 doesn't seem to do anything for me
either. keyevent 82 works like a charm.

mike p

unread,
Jan 31, 2011, 9:43:28 AM1/31/11
to tas...@googlegroups.com
Thanks for looking so far into this.

I had the D-pad combo figured out, but it wasn't working so I figured I'd try something simple (the Menu-press).

I'll give this a try.

Incidentally, is there any way to "star" a thread, or see threads where I've posted?

mike p

unread,
Jan 31, 2011, 3:04:25 PM1/31/11
to tas...@googlegroups.com
I created a Tasker entry that will check for my home wifi SSID and run the sync task every 3 hours.

Working great now, thanks much.

Muad

unread,
Feb 1, 2011, 7:47:41 AM2/1/11
to Tasker
I'm trying with this method to enable mobile data by emulating click
on power physical button and enable Mobile data.

1) emulate power physical button click would be 26? (don't works
after allowing superuser keyevent 26)
2) d-pad down 20 Ok
3) d-pad down 20 Ok
4) d-pad center 23 Ok

And... it's really slow! I'm running in Galaxy S and this 4 steps in a
single task lasts 1min 10sec to finish...

HypnoToad

unread,
Feb 1, 2011, 2:55:40 PM2/1/11
to Tasker
keyevent 26 doesn't seem to do anything for me either. Tasker has the
ability to turn your phone's screen on though so you shouldn't have to
emulate the power button anyway. As for the speed, you might try using
an app called ASE. It's available from Google Code and it integrates
with Tasker. Just put all those commands into a shell script and run
them that way. I haven't tried this myself so I don't know if it runs
faster but I'd imagine that it would.

HypnoToad

unread,
Feb 1, 2011, 3:01:04 PM2/1/11
to Tasker
I just looked and Tasker has the ability to enable/disable mobile data
built in so you shouldn't have to use this method at all.

Muad

unread,
Feb 1, 2011, 3:59:49 PM2/1/11
to Tasker
Thanks for the tip, but I can't find it, is SL4A?
And its a little more complicated cause I'm trying to get the power
menu (holding power button) and then select 2nd option that is "enable/
disable" mobile data...
And using that SL4A... I don't need that execute plugin?

Thanks in advance.

On 1 feb, 20:55, HypnoToad <pimpdaddysh...@gmail.com> wrote:
> keyevent 26 doesn't seem to do anything for me either. Tasker has the
> ability to turn your phone's screen on though so you shouldn't have to
> emulate the power button anyway. As for the speed, you might try using
> an app called ASE. It's available from Google Code and it integrates
> with Tasker. Just put all those commands into a shell script and run
> them that way. I haven't tried this myself so I don't know if it runs
> faster but I'd imagine that it would.



Yep, but only if you use APN Droid, which I'm trying to avoid (for no
particular reason, just don't want more apps to do it).
And I've tried without APN Droid and is a no-way. (search this forum)

baudi

unread,
Feb 1, 2011, 4:03:21 PM2/1/11
to Tasker
See this page for info about using SL4A with Tasker: http://tasker.wikidot.com/sl4a

HypnoToad

unread,
Feb 1, 2011, 4:57:49 PM2/1/11
to Tasker
Sorry SL4A is the new name but, as I said before, everything that
you're trying to do is built into Tasker already so there is no need
for you to use this method.

Muad

unread,
Feb 2, 2011, 4:05:00 AM2/2/11
to Tasker
I sorry to say that I've trying for a long time with different
approaches without success.

visit in this forum (search is my friend)
-> http://groups.google.com/group/tasker/msg/efb39e3ba91bb71f
-> http://groups.google.com/group/tasker/msg/2347b8d5f38fe799

And without APNDroid there is no way to do it (IMHO-AFAIK).
If anyone manage to do it without APNDroid and without losing manual
control of the enable/disable mobile data, please let me know.

Thanks in advance.

Verboten

unread,
Feb 1, 2011, 7:30:46 PM2/1/11
to Tasker
Can you give a couple examples of useful things that can be
accomplished with this? When you say "you can now write a task to
open a program and navigate around it" does that mean you can launch
an app and simulate finger presses within it, such as at a specified
screen location?


On Jan 29, 10:45 am, HypnoToad <pimpdaddysh...@gmail.com> wrote:
> Yesterday I figured out how to emulate key presses. I was trying to
> write a task that simply pushed the number 4 during a call. Everything
> that I read online said that this couldn't be done, not only does
> Tasker not have this capability but Android won't accept input from
> other programs during a call. But, as with all things Android, where
> there's a will there's a way.
>
> The only drawback to my method is that you need root permissions.
> Sorry.
>
> Here are the steps to start emulating key presses with Tasker.
>
> 1. Root your phone
>
>      universal androot and the cyanogen wiki are good sources for
> this. google it.
>
> 2. Download the needed software
>
>      you will need Tasker (duh) and the "Locale execute plugin"
>
>      http://www.appbrain.com/app/locale-execute-plug-in/de.elmicha.app.Loc...

HypnoToad

unread,
Feb 2, 2011, 10:57:30 AM2/2/11
to Tasker
With this method navigation is limited to d-pad/trackball movements.
Most apps allow this form of navigation so it is possible to have
Tasker open an app and then move 4 dpad movements down, 3 over, click,
2 up, enter text, one over, click... You get the idea. There is a user
in this thread that wrote a script to get SK Sync to backup his phone
every 3 hours by having Tasker launch the app and then emulating 2 d-
pad movements down and then emulating a click. But use your
imagination there is a tremendous number of possibilities. As for
simulating finger presses, it is possible but much more complicated.
If there is enough interest I can write another how-to and explain how
to do this.

HypnoToad

unread,
Feb 2, 2011, 3:26:46 PM2/2/11
to Tasker
This is a different method from what I documented above but here are
the commands to press the power button

sendevent /dev/input/event5 1 116 1
sendevent /dev/input/event5 1 116 0

The first command presses the button down, the second command releases
it. You will need to put a sleep command in between those commands to
emulate pushing the button down for a few seconds. From what I can
tell from the photo you posted in those other threads you will then
need to emulate 2 movements down and then a click. Let me know if you
need anymore help.

Pent

unread,
Feb 3, 2011, 10:50:33 AM2/3/11
to Tasker
I had to install Cyanogen on my trusty N1 to test the GPS action and
now have a working shell API so it shouldn't be ages until this kind
of thing can be done with 'native' Tasker actions on rooted devices.

I was aware of the input command but not sendevent, thanks HypnoToad.

Pent

Muad

unread,
Feb 3, 2011, 3:09:46 PM2/3/11
to Tasker
Thanks HypnoToad, given my android skills, would be *absolutely*
necesary your help to achieve it. 've been googling about that sleep
command without finding anything I can manage to do.
That commands must be "sent" using locale execute or via sl4a+python?

Thanks in advance.

HypnoToad

unread,
Feb 3, 2011, 3:32:03 PM2/3/11
to Tasker
I commend you for trying to figure this out yourself. I think you're
right though, your going to need my help. The sleep command is "sleep
<# of seconds>" so if you wanted to sleep for 1 second the command
would be "sleep 1" without the quotes. This command doesn't need to be
run as root so there is no need to put an ! in front of it if you're
using the locale execute plugin. Your code should look like the
following

!sendevent /dev/input/event5 1 116 1
!sendevent /dev/input/event5 1 116 0
!sendevent /dev/input/event5 1 116 1
sleep 1
!sendevent /dev/input/event5 1 116 0
!input keyevent 20
!input keyevent 20
input keyevent 23

The first line pushes down the power button and the second one
releases it. This should turn on your screen. The third line pushes
down your power button, the forth line waits 1 second, the fifth line
releases the power button. That should bring up the "Phone options"
menu. The next three lines move the cursor down 2 spaces and then
clicks.

If the locale execute plugin is too slow which, based on a prior
comment you made, I suspect it will be. Then I'll help you run this in
SL4A but it's going to be a bit more complex because SL4A doesn't
support running commands as root so we'll have to use a workaround.

Let me know if this works of if you need further assistance.

HypnoToad

unread,
Feb 3, 2011, 3:41:31 PM2/3/11
to Tasker
You can get email updates when there is a new entry in a thread by
going to the top of the thread, clicking on "options" to the right of
the thread title, then clicking on "Email updates to me".

Muad

unread,
Feb 4, 2011, 4:30:28 AM2/4/11
to Tasker
I'm on the run :) HypnoToad.
First try I added two actions via locale execute with
!sendevent /dev/input/event5 1 116 1
!sendevent /dev/input/event5 1 116 0
After first run (few seconds later) I got superuser prompt for each
action, with no more results (my guess superuser prompr arrived late)
On the second run, satisfied the required superuser permission, all I
got is 2 consecutive flash text (Tasker alert flash text) with each of
the commands... nothing else.
And yes, I double-checked spaces in commands.

Richard Kemp

unread,
Feb 4, 2011, 9:33:11 AM2/4/11
to Tasker
I'm looking to emulate a long-press of the menu button, so I guess I
need a command similar to this mentioned above for the power button:

!sendevent /dev/input/event5 1 116 1
!sendevent /dev/input/event5 1 116 0

Is there somewhere we can look up a list of codes for use with this
command (I presume they are different to the codes you gave in the
first post HypnoToad?)

Cheers

Richard Kemp

unread,
Feb 4, 2011, 9:45:58 AM2/4/11
to Tasker
Also for the record, I found I didn't have an event5 in /dev/input/,
but sending the commands you wrote above to event4 instead worked
fine.

Muad

unread,
Feb 4, 2011, 2:50:38 PM2/4/11
to Tasker
Tried too with event4, and after su prompt, just having 2 flash text
with
!sendevent /dev/input/event4 1 116 1
and
!sendevent /dev/input/event4 1 116 0
(Galaxy S, Android 221, no stock rom)

HypnoToad

unread,
Feb 4, 2011, 3:16:15 PM2/4/11
to Tasker
Using sendevent to emulate a long press on the menu button is much
more complex than emulating a press of the power button. The reason
why is that the power button is a hardware key so there isn't much too
it. One command to press it down, another command to release it. The
menu button, as well as the back, home, and search, buttons are
actually part of the touch screen. At least this is the case for my
phone (Nexus One) and most other phones. This means that you need to
emulate a touch on the screen. There is almost no documentation for
the getevent/sendevent commands the best I could find was here:

http://groups.google.com/group/android-beginners/browse_thread/thread/8a5d8fa9229114d2/ce6e604f52b5318f?pli=1

(If you find any more please let me know).

This is the method that I use to figure out the commands I need to
emulate a touch. Keep in mind that my PC is running Linux so you will
also need a Linux box if you want to use the same commands that I use
to sort and convert a lot of this data.

Please note that I upgraded to CM7 yesterday and the sendevent command
is broken on it so I'm currently unable to test my final results.

Here we go.

1. Fire up ADB on your PC and connect your phone.

2. Turn your phone's screen on and unlock it.

3. While your phone is unlocked with the screen on and nobody/nothing
touching the screen, run the following command

adb shell getevent

4. If you see a bunch of messages flying by the screen then take note
of what event# they're going to. I get a bunch of stuff that looks
like this:

/dev/input/event2: 0003 0000 00000000
/dev/input/event2: 0003 0001 fffffd1f
/dev/input/event2: 0000 0000 00000000
/dev/input/event2: 0003 0000 00000003

As you can see, it's all going to event2. I have no idea what
these events mean but they have nothing do do with what I'm looking
for so I filter them with grep to make my life easier. So the command
I use to get the data I need is:

adb shell getevent | grep -v event2

NOTE: This will only work on Linux or some other variant of UNIX
that has grep installed.

5. With the getevent command running, do what you're trying to emulate
and only what you're trying to emulate. For this example I'm going to
try to emulate a press of the menu key so I navgate home, start
getevent on my PC, press and release the menu key (we just have to
press and release it. We can emulate holding it down with a sleep
command later), then stop getevent with a Ctrl+c. You will see a bunch
more commands streaming by. I will will now try and make sense of some
of these commands.

/dev/input/event3: 0003 0000 0000070f

/dev/input/event3: 0003 0001 00001a22
/dev/input/event3: 0000 0000 00000000

Anything that starts with a 0003 0000 is the X position of a touch,
the 0000070f is the position itself.
Anything that starts with a 0003 0001 is the Y position of a touch,
the 00001a22 is the position itself.
These commands are always followed by 0000 0000 00000000. I'm not sure
what this means but we'll emulate it just to be safe.

/dev/input/event3: 0001 014a 00000001
/dev/input/event3: 0000 0000 00000000
/dev/input/event3: 0001 014a 00000000
/dev/input/event3: 0000 0000 00000000

0001 014a 00000001 is the command for a touch of the screen.
I still have no Idea what the 0000 0000 00000000 is all about but it
shows up after every press so we'll emulate it.
0001 014a 000000010 is the command for an untouch (that's not a word
but I don't know what else to call it).

Note: You'll most likely get a lot of the x position and y position
commands because your finger will move around a bit but there all
going to be in the area that you need so you can just pick 2 for your
emulation.

6. Convert the results of the getevent command to a sendevent command.
For some reason the output of the get event command is given in hex
but the sendevent command requires decimal. So, for example, /dev/
input/event3: 0001 014a 00000001
would translate to sendevent /dev/input/event3 1 330 1. You should
only have to convert 7 commands and the one that are all zero's will
be extra easy. Still, I'm lazy so I save the commands I'm going to
emulate to a file and run the following command on my PC:

gawk --non-decimal-data '{print $1, ("0x"$2)+0, ("0x"$3)+0,
("0x"$4)+0}' name-of-file.txt | sed 's/://g;s/^/sendevent /g'

This will give us this:

sendevent /dev/input/event3 3 0 1807
sendevent /dev/input/event3 3 1 6690
sendevent /dev/input/event3 0 0 0
sendevent /dev/input/event3 1 330 1
sendevent /dev/input/event3 0 0 0
sendevent /dev/input/event3 1 330 0
sendevent /dev/input/event3 0 0 0

To emulate holding down you would put a sleep command after the touch

sendevent /dev/input/event3 3 0 1807
sendevent /dev/input/event3 3 1 6690
sendevent /dev/input/event3 0 0 0
sendevent /dev/input/event3 1 330 1
sendevent /dev/input/event3 0 0 0
sleep 1
sendevent /dev/input/event3 1 330 0
sendevent /dev/input/event3 0 0 0

7. If you want to try these commands out before you go through the
trouble of making them into a Tasker script then you can send them to
your device by typing “adb shell” into your terminal then pasting the
commands. You can paste them all at once.


NOTE: The locale execute plugin seems pretty crappy for this sort of
thing so I'll try and post a how-to for using these commands with SL4A
pretty soon.

I want to thank Kent Yip for his great post which can be found in the
link toward the top of this post.
I would also like to thank my buddy jreppiks for that fancy gawk
command to convert hex to dec.

HypnoToad

unread,
Feb 4, 2011, 3:23:14 PM2/4/11
to Tasker
You're in luck. My friend has a Galaxy phone that I was able to test
with. This is the output that I got with pressing the power button.

/dev/input/event1: 0001 001a 00000001
/dev/input/event1: 0001 001a 00000000
/dev/input/event1: 0000 0000 00000000

Which converts to the following:

sendevent /dev/input/event1 1 26 1
sendevent /dev/input/event1 1 26 0
sendevent /dev/input/event1 0 0 0

HypnoToad

unread,
Feb 4, 2011, 3:26:20 PM2/4/11
to Tasker
I guess this explains why I'm unable to find a list of commands like
with the keyevent command. Sendevent commands aren't standardized. : (

Muad

unread,
Feb 5, 2011, 8:45:19 AM2/5/11
to Tasker
Well, thanks HypnoToad (and to your friend).
I've been doing some test and I'll resume you...
1st: It works! :) and too fast compared with the tests made before.
(to be clear, the action is fast, but the flash texts are showed too
late, think its 1 sec for each one)

1st Task tested:
vibrate 200
sendevent /dev/input/event1 1 26 1
sendevent /dev/input/event1 1 26 0
sendevent /dev/input/event1 0 0 0
(via execute plugin)

But, still some problem.
One, flash texts still appearing (maybe this is a feature of tasker or
locale plugin, don't know)
Two, if task brings succesfully "power menu" screen and then you tap
any option or click physical button BACK, next time you test the task,
it won't work, and even pressing phys. power button won't work. In
this last case, you'll need to press again phys. power button to get
power menu in screen. (seems that something is waiting for this extra
pulsation to get the status of the phys. button as "ready" some kind
of reset?) (sorry for the terms used in this lucubration)

2nd Task tested:
vibrate 200
sendevent /dev/input/event1 1 26 1
sendevent /dev/input/event1 1 26 0
sendevent /dev/input/event1 0 0 0
sendevent /dev/input/event1 ****** (****** here tried all the
precedent commands, one by one, looking for the supposed reset)
(via execute plugin)

The same result. Always you need to do an extra pulsation on phys.
power menu to allow a new succesfully execution of the task.

3rd Task tested:
vibrate 200
sendevent /dev/input/event1 1 26 1
sendevent /dev/input/event1 1 26 0
sendevent /dev/input/event1 0 0 0
input keyevent 20
input keyevent 20
input keyevent 23

It works first time. Then after extra pulsation of phys. power button
(to make the "reset" mentioned above), if I repeat the task, the first
input keyevent 20 starts in the second row of power menu (Mobile data
option, last used), then very obedient jumps to next row and clicks
(airplane mode). Then, even doing the mentioned extra pulsation of
power button, if I use the task again, the first keyevent 20 will
start in the last used, so the third time you test the task, the
click will fall over fourth row in power menu which is Switch off :)

Conclusion: We're near :)
I'll test it more later.

(And thanks)

fubaya

unread,
Feb 5, 2011, 9:34:29 AM2/5/11
to Tasker
On Feb 5, 8:45 am, Muad <rgisb...@gmail.com> wrote:
> But, still some problem.
> One, flash texts still appearing (maybe this is a feature of tasker or
> locale plugin, don't know)

You can add "@" to the commands to keep the plugin from flashing the
text, like:

@! sendevent /dev/input/event1 1 26 1

You can also put all your commands in a file and use the plugin to
execute the file with this command:

@! sh /sdcard/yourfile.txt

That may make it easier to edit the commands, and you won't have to
grant su rights every time you edit them.

Muad

unread,
Feb 5, 2011, 10:55:05 AM2/5/11
to Tasker
Good to know!
Thanks!

joeviocoe

unread,
Feb 10, 2011, 12:55:08 AM2/10/11
to Tasker
I don't have anything in my /dev/input/ folder. Is there something
that is supposed to be in there?

I am looking with "Root Explorer" app and am running CM7 nb38 (Nexus
One Gingerbread 2.3.2)

HypnoToad

unread,
Feb 10, 2011, 11:11:42 AM2/10/11
to Tasker
Weird. I'm also running CM7 on my Nexus One and I have files named
event0 through event 6 in /dev/input/. I'm going to go out on a limb
and say that it's an issue with root explorer. Connect to your phone
via ADB, run the getevent command and see where the events are going
to.

joeviocoe

unread,
Feb 10, 2011, 12:00:43 PM2/10/11
to Tasker
You were right, it was something with root explorer. I went to file
manager, which came with cm, and can see all of the files there now,
they all have file sizes of 0 bytes though. Adb getevents show them
coming from the same dev/input.

However, nothing I do with send event, seems to work. I can do
keyevent just fine and get event just fine , but sendevent never
works

HypnoToad

unread,
Feb 10, 2011, 1:21:57 PM2/10/11
to Tasker
I think the most accurate way to get byte size is with adb.

shawn@shawn-laptop:~$ adb shell ls -al /dev/input/
drwxr-xr-x 2 root root 180 Feb 10 08:29 .
drwxr-xr-x 12 root root 1.3K Feb 10 08:29 ..
crw-rw---- 1 root input 13, 64 Feb 10 08:29 event0
crw-rw---- 1 root input 13, 65 Feb 10 08:29 event1
crw-rw---- 1 root input 13, 66 Feb 10 08:29 event2
crw-rw---- 1 root input 13, 67 Feb 10 08:29 event3
crw-rw---- 1 root input 13, 68 Feb 10 08:29 event4
crw-rw---- 1 root input 13, 69 Feb 10 08:29 event5
crw-rw---- 1 root input 13, 70 Feb 10 08:29 event6


As you can see my event files are small but not 0 bytes (size is the
column just before the month). I also can't get sendevent to work on
my phone. Sendevent appears to be broken on CM7. I'm sure this will be
fixed in a future release.

Hagure

unread,
Feb 10, 2011, 7:05:06 PM2/10/11
to Tasker
Thanks for this! I used this to help me turn on/off TuneSync synching
when I'm not at home.

Task:
1. Launch Tunesync
2. keyevent 20 (down)
3. keyevent 23 (click)



On Jan 29, 9:45 am, HypnoToad <pimpdaddysh...@gmail.com> wrote:
> Yesterday I figured out how to emulate key presses. I was trying to
> write a task that simply pushed the number 4 during a call. Everything
> that I read online said that this couldn't be done, not only does
> Tasker not have this capability but Android won't accept input from
> other programs during a call. But, as with all things Android, where
> there's a will there's a way.
>
> The only drawback to my method is that you need root permissions.
> Sorry.
>
> Here are the steps to start emulating key presses with Tasker.
>
> 1. Root your phone
>
>      universal androot and the cyanogen wiki are good sources for
> this. google it.
>
> 2. Download the needed software
>
>      you will need Tasker (duh) and the "Locale execute plugin"
>
>      http://www.appbrain.com/app/locale-execute-plug-in/de.elmicha.app.Loc...
>
> 3. Create your task
>
>     to create your task in tasker open the "plugin" section, select
> "execute", then select "edit"
>     enter your key emulation commands.
>
>     there are two different commands that you can use to do this the
> first command is "inputkeyevent<event_code>
> (example: !inputkeyevent11) This tells Locale Execute Plug-in to run

fubaya

unread,
Feb 11, 2011, 1:22:01 AM2/11/11
to Tasker
If you guys are having problems finding the correct /dev/input/event
to use, try just typing "getevent" in a shell and not touching
anything. Before all the hex scrolls by, it maps out the input
devices. Alternately, you can use "getevent -c 1" to stop after
outputting one event.

# getevent
add device 1: /dev/input/event6
name: "mahimahi-nav"
add device 2: /dev/input/event5
name: "mahimahi-keypad"
add device 3: /dev/input/event4
name: "proximity"
add device 4: /dev/input/event3
name: "synaptics-rmi-touchscreen"
add device 5: /dev/input/event2
name: "compass"
add device 6: /dev/input/event1
name: "h2w headset"
add device 7: /dev/input/event0
name: "lightsensor-level"
^C
#

I assume that will give the correct output for your phone. You can
also look in /proc/bus/input/devices, that's probably what getevent
uses. Note the paths aren't the same, but the event number should be.
Here's a command to make it nice and readable:

# cat /proc/bus/input/devices | egrep "N:|S:|^$"
N: Name="lightsensor-level"
S: Sysfs=/devices/virtual/input/input0

N: Name="h2w headset"
S: Sysfs=/devices/virtual/input/input1

N: Name="compass"
S: Sysfs=/devices/virtual/input/input2

N: Name="synaptics-rmi-touchscreen"
S: Sysfs=/devices/virtual/input/input3

N: Name="proximity"
S: Sysfs=/devices/virtual/input/input4

N: Name="mahimahi-keypad"
S: Sysfs=/devices/virtual/input/input5

N: Name="mahimahi-nav"
S: Sysfs=/devices/virtual/input/input6

#

fubaya

unread,
Feb 11, 2011, 1:26:56 AM2/11/11
to Tasker
On Feb 11, 1:22 am, fubaya <jdm...@gmail.com> wrote:
> Note the paths aren't the same, but the event number should be.

Er, should have proofread...

I mean the event number should be the same as the input number from
that file. /devices/virtual/input/input0 appears to be the same as /
dev/input/event0, so input3 should clue you in to using event3 for the
touchscreen, for example.

HypnoToad

unread,
Feb 11, 2011, 11:08:47 AM2/11/11
to Tasker
Great work fubaya. Thanks for sharing this.

joeviocoe

unread,
Mar 1, 2011, 2:07:54 PM3/1/11
to Tasker
Sendevent commands now work on the latest CM7 nightly (#8) for my
Nexus One
:)

HypnoToad

unread,
Mar 2, 2011, 10:49:18 AM3/2/11
to Tasker
If you're running Cyanogen, all of the "input keyevent" stuff can be
natively through Tasker in the "input" category as of the latest
release. No more need for 3rd party plugins.
Thanks to the dev for implementing this so quickly.

Pawci0

unread,
Mar 21, 2011, 7:18:02 AM3/21/11
to Tasker
Hi! Recently I tried this Locale Excecute plugin to simulate some
keypresses on my Galaxy S (using the input keyevent command), but this
method was very slow - one keypress was taking over 10 seconds to
generate!
I'm using the stock 2.2 ROM from Samsung - would switch to CyanogenMod
for this function, but it's still unfinished for i9000. Anyone knows a
faster method of generating keypresses in other apps?

Martín Alejandro Gomez

unread,
Apr 30, 2011, 4:03:05 PM4/30/11
to Tasker
I have the very same problem. Two keyevent 4 (back key) take like 1
minute to generate, or sometimes don't seem to generate at all!

Any idea why this happens, why this isn't instantaneous and if it can
be fixed somehow? Running it on a Galaxy S I9000.

Thanks

Pent

unread,
Apr 30, 2011, 4:09:40 PM4/30/11
to Tasker
> I have the very same problem. Two keyevent 4 (back key) take like 1
> minute to generate, or sometimes don't seem to generate at all!
>
> Any idea why this happens, why this isn't instantaneous and if it can
> be fixed somehow? Running it on a Galaxy S I9000.

Why not use the Tasker action ?

Pent

Martín Alejandro Gomez

unread,
Apr 30, 2011, 5:44:06 PM4/30/11
to Tasker
Because I didn't know it existed... I've seen the "Go home" and such,
but I only saw the back key in the action that needs Cyanogen Mod
installed (not available for I9000)

Is that the one you were talking about or is it somewhere else?

Thanks Pent

Martín Alejandro Gomez

unread,
May 1, 2011, 4:15:23 AM5/1/11
to tas...@googlegroups.com
Well, I've tried the Tasker input action an it worked, even though the help said that it would only work in CyanogenMod. (I'm running stock, rooted 2.2.1 in I9000)

The thing is that it's as slow as with the execute plugin. The first "back" executes right away and after that, it seems to be stuck forever (even the "kill all" button shows, as if the tasks is still running).

Anyway to fix this?

Martín Alejandro Gomez

unread,
May 1, 2011, 4:16:55 AM5/1/11
to tas...@googlegroups.com
By the way, the following keys don't execute at all; it just hangs there, with the "kill all" button displaying

Pent

unread,
May 1, 2011, 4:36:15 AM5/1/11
to Tasker
> Well, I've tried the Tasker input action an it worked, even though the help
> said that it would only work in CyanogenMod. (I'm running stock, rooted
> 2.2.1 in I9000)

Sorry, help text needs changing.

> The thing is that it's as slow as with the execute plugin. The first "back"
> executes right away and after that, it seems to be stuck forever (even the
> "kill all" button shows, as if the tasks is still running).

Try a Wait in-between ?

If not, could you send me a log ?

http://tasker.dinglisch.net/faq-how.html#x

Pent

Martín Alejandro Gomez

unread,
May 1, 2011, 4:20:07 PM5/1/11
to Tasker
Thanks Pent. I was about to send you the log but before I tryed adding
a Wait of 1 second in between every back button and it worked.

I tried that before with the Execute plugin but didn't worked, so I
though that here it would be the same.

I got so excited that I just bought the app from the Market. Thanks
man :)

On May 1, 5:36 am, Pent <supp...@apps.dinglisch.net> wrote:
> > Well, I've tried the Tasker input action an it worked, even though the help
> > said that it would only work in CyanogenMod. (I'm running stock, rooted
> > 2.2.1 in I9000)
>
> Sorry, help text needs changing.
>
> > The thing is that it's as slow as with the execute plugin. The first "back"
> > executes right away and after that, it seems to be stuck forever (even the
> > "kill all"buttonshows, as if the tasks is still running).

Martín Alejandro Gomez

unread,
May 1, 2011, 4:21:23 PM5/1/11
to Tasker
By the way, any idea why it doesn't work without the Wait? Should I
add a Wait in between, in every task with input commands?

On May 1, 5:20 pm, Martín Alejandro Gomez <martingomez...@gmail.com>
wrote:
> Thanks Pent. I was about to send you the log but before I tryed adding
> a Wait of 1 second in between everybackbuttonand it worked.

Martín Alejandro Gomez

unread,
May 1, 2011, 4:53:48 PM5/1/11
to Tasker
Well, after all the work, I noticed it wouldn't work when the device
was locked in my backpack, so I had to turn on the screen first, but
then it wouldn't get past the unlock screen.

The idea was to close the music player after the bluetooth headset
disconnected, and since in the I9000 there's no way to kill that app
but to stop the current track and back all the way to the home screen,
I think it can't be done.

I've tried killing the process (all four of them) with root access and
still, the app would restart after a while. Pretty sad.



On May 1, 5:21 pm, Martín Alejandro Gomez <martingomez...@gmail.com>

Pent

unread,
May 3, 2011, 5:22:02 AM5/3/11
to Tasker
> By the way, any idea why it doesn't work without the Wait?

No, I just have experience that Android has timing issues sometimes.

> Should I
> add a Wait in between, in every task with input commands?

If they don't work :-)

Could you do me a favour: there's a 'repeat' parameter for the Dpad
action. When you specify more than 1 repeat with that action, does it
work ? That might fix the Button problem if it was done the same way.

Pent

Pent

unread,
May 3, 2011, 5:23:56 AM5/3/11
to Tasker
> Well, after all the work, I noticed it wouldn't work when the device
> was locked in my backpack,

That's the purpose of the keyguard :-)

Pent

michel moalem

unread,
May 12, 2011, 5:53:22 PM5/12/11
to tas...@googlegroups.com
hi there - just came across this thread and i think i might finally manage to get my call recording going...
the problem i have is that:
my phone is a zte blade with modaco 2.2 rom. it is rooted.
i would like to record all my phone calls automatically, both sides of the conversation (i know there are legal issues but lets put that aside for now)
the only app that worked for me in recording both sides of the call without using the speaker-phone method is AllCallRecorder. it works but is not reliable (it sometimes stops recording after few seconds for no apparent reason)
pressing the menu button once the call connects and than pressing record works great but it requires me to do it manually so i was looking for a way to automate that. so i came across tasker and was hoping for the best but it falls short on executing macros (its audio record option does not work on my phone - something about 'cant init the audio')
and than i came across this thread and the LocaleExecute Plugin and my hopes are high again but i cant find any reference to the command i need to perform this two-events-macro - press menu and than record
can anyone here help with that
this is how far i got: profile in tasker, event: phone offhook, plugin: execute, script !inputkeyevent1
this does not bring the menu on screen as it happens when actually pressing the hardware button so not sure if it works..

Pent

unread,
May 13, 2011, 4:14:15 AM5/13/11
to Tasker
')
> and than i came across this thread and the LocaleExecute Plugin and my hopes
> are high again but i cant find any reference to the command i need to
> perform this two-events-macro - press menu and than record

Is 'record' a hard button ?

Pent

michel moalem

unread,
May 13, 2011, 4:38:25 AM5/13/11
to tas...@googlegroups.com
no - its on the pop up menu (on screen)

Pent

unread,
May 13, 2011, 6:20:37 AM5/13/11
to Tasker
> no - its on the pop up menu (on screen)

OK, then you use Input / Button, Menu to get the menu up, then use the
Dpad actions to go to the right item and Dpad, Centre to select.

Pent

michel moalem

unread,
May 13, 2011, 8:22:48 AM5/13/11
to tas...@googlegroups.com
hi there Pete and thank you very much for the help but i am lost on how to write the commands you suggested. all i know is the codes that are on the original post (ie inputkeyevent<number>) but there are no suggested numbers for your commands other than the dpad... 
cheers
michel

Pent

unread,
May 13, 2011, 9:22:10 AM5/13/11
to Tasker
> hi there Pete

<cough>
What numbers do you need ?

Action 1: Button / Menu
Action 2: Dpad / Down (or whatever dpad movements you do to select
the thing normally)
Action 3: Dpad / Center

You might need some Wait actions in-between.

Pent

michel moalem

unread,
May 13, 2011, 10:26:59 AM5/13/11
to tas...@googlegroups.com
hi there pent and sorry for the mispelling!
i think i have not made it clear how much clueless i am in regard to this plugin. all i know and found out is based on the first post. the only command i know off is the inputkeyevent and the number i was talking about is the number to put at the end on that command (from the list at the fist post)

so this is what i done. tasker and plugin installed, create new event in tasker (on 'phone offhook'). in the event added action>plugin>execute. in the text-input are i wrote !inputkeyevent1. that's how far i got. 

now i assume i need to write the command suggested by you in that text input area but i am not sure of the syntax...

Pent

unread,
May 13, 2011, 11:11:07 AM5/13/11
to Tasker
> i think i have not made it clear how much clueless i am in regard to this
> plugin. all i know and found out is based on the first post. the only
> command i know off is the inputkeyevent and the number i was talking about
> is the number to put at the end on that command (from the list at the fist
> post)

Ah, that's the confusion.

You don't need the plugin for the things I am describing. Just create
Tasker actions from the Input category.

Pent

golightly

unread,
May 14, 2011, 4:33:08 AM5/14/11
to Tasker
Make sure you have the latest version of Tasker. Lent added some
commands for control of the Dpad directly in the Input category.

You now longer need to use the Execute logging for moving and
sekecting.

golightly

unread,
May 14, 2011, 4:35:29 AM5/14/11
to Tasker
Of course I meant "Pent". I'm getting too dependent on SwiftKey
managing my typing :-)

michel moalem

unread,
May 14, 2011, 5:44:26 AM5/14/11
to tas...@googlegroups.com
hi again - the problem i have is that when trying to select input->button it says "sorry, this action is not supported on this device" - so i guess it's back to square one for me...

Pent

unread,
May 14, 2011, 7:22:04 AM5/14/11
to Tasker
> hi again - the problem i have is that when trying to select input->button it
> says "sorry, this action is not supported on this device" - so i guess it's
> back to square one for me...

Do you have a rooted device ?

Pent

michel moalem

unread,
May 14, 2011, 12:48:33 PM5/14/11
to tas...@googlegroups.com
hi again. 
sorted!
had to update to latest version for it to recognise the root permissions
cheers for all the help!

JB

unread,
Mar 19, 2012, 8:30:41 AM3/19/12
to tas...@googlegroups.com
Hello, I've been looking for a way to do this for quite some time. However, I'm having trouble getting this to work.

Do I need to have both commands in one execute box? And what's a sleep command? I have it set up like

!sendevent /dev/input/event5 1 116 1
Task -> wait 2 seconds.
!sendevent /dev/input/event5 1 116 0

I get asked for SU permissions then a toast confirms. Any help would be greatly appreciated. I have very basic programming knowledge. Thank you.
?
HTC incredible ICS if it matters

Edward Ned Harvey

unread,
Mar 19, 2012, 9:52:06 PM3/19/12
to tas...@googlegroups.com
> From: tas...@googlegroups.com [mailto:tas...@googlegroups.com] On
> Behalf Of JB

>
> Hello, I've been looking for a way to do this for quite some time. However,
> I'm having trouble getting this to work.
>
> Do I need to have both commands in one execute box? And what's a sleep
> command? I have it set up like
>
> !sendevent /dev/input/event5 1 116 1
> Task -> wait 2 seconds.
> !sendevent /dev/input/event5 1 116 0

How do you find the !sendevent?
Does this work for you?
I want to do it too. How do you do it?

V Oz

unread,
Mar 20, 2012, 2:49:16 AM3/20/12
to tas...@googlegroups.com
GREAT! That's what I look at for! thank You VERY much!

HypnoToad

unread,
Mar 20, 2012, 3:16:45 AM3/20/12
to tas...@googlegroups.com
On Tuesday, March 20, 2012 12:49:16 AM UTC-6, V Oz wrote:
> GREAT! That&#39;s what I look at for! thank You VERY much!

You're welcome. I'm glad someone found this useful.

JB

unread,
Mar 20, 2012, 12:00:05 PM3/20/12
to Tasker
How do you find the !sendevent?
> Does this work for you?
> I want to do it too.  How do you do it?


so, stupidly as soon as I posted I found the answer above that eluded
me.

I assume you have an incredible, so following the instructions above I
successfully was able to do so by changing event5 to event4. So,
creating a new task, hit plugin -> execute -> edit and type;


!sendevent /dev/input/event4 1 116 1
sleep 2
!sendevent /dev/input/event4 1 116 0



this will induce a power button hold. after running. it once it'll ask
for SU then try again and all should be well.

Edward Ned Harvey

unread,
Mar 21, 2012, 9:33:21 AM3/21/12
to Tasker
> From: tas...@googlegroups.com [mailto:tas...@googlegroups.com] On
> Behalf Of JB
>
> How do you find the !sendevent?
> > Does this work for you?
> > I want to do it too.  How do you do it?
>
>
> so, stupidly as soon as I posted I found the answer above that eluded
> me.
>
> I assume you have an incredible, so following the instructions above I
> successfully was able to do so by changing event5 to event4. So,
> creating a new task, hit plugin -> execute -> edit and type;

I don't have an incredible. Why would you assume that? I have some other
android phone.

When I look under tasks, plugins, I don't see "Execute" or "edit and type."
Did you install some 3rd party application to make that appear?

JB

unread,
Mar 22, 2012, 10:44:58 AM3/22/12
to Tasker
I assume you had an incredible because you quoted my post, and I
assumed that you did read the beginning of the post. So I suggest you
read the few posts my Hypnotoad that go into great detail, largely due
to the fact that each phone could require different codes.

The plugin you need is execute locale. You do not need to install
locale, just the plugin. Then going to execute and clicking edit, then
type the commands in the last post.

Edward Ned Harvey

unread,
Mar 22, 2012, 12:52:26 PM3/22/12
to Tasker
> From: tas...@googlegroups.com [mailto:tas...@googlegroups.com] On
> Behalf Of JB
>
> I assume you had an incredible because you quoted my post, and I
> assumed that you did read the beginning of the post.

hehehe, I did read your post. All you said was "HTC incredible ICS if it
matters." and I chopped that part out of my reply.


> So I suggest you
> read the few posts my Hypnotoad that go into great detail, largely due
> to the fact that each phone could require different codes.

I have no idea what you're talking about, I don't see any link or reference
to hypnotoad anywhere in this thread. Could you please re-post the link(s)?
You may think you sent some message(s) that didn't actually get sent, or
something like that.


> The plugin you need is execute locale. You do not need to install
> locale, just the plugin. Then going to execute and clicking edit, then
> type the commands in the last post.

Thanks, I'll look into that.

JB

unread,
Mar 22, 2012, 1:13:13 PM3/22/12
to Tasker
Sorry. lol I'm not familiar with Google groups, I thought it was much
like a traditional forum.

groups.google.com/group/tasker/browse_thread/thread/2c98667f14f69a3f

Hopefully that works for you. Let me know.

Bob Loblaw

unread,
Apr 3, 2012, 11:18:52 AM4/3/12
to tas...@googlegroups.com
Great! My weather app usually has me click a couple of times before I can get into the radar part and this solved that. Thanks Toad.

Task: 
1. Launch weather app
2. Wait 5 seconds (allowing to find my location and fully load)
3. keyevent 23 (click)  
3. keyevent 23 (click)   


On Thursday, February 10, 2011 6:05:06 PM UTC-6, Hagure wrote:
Thanks for this! I used this to help me turn on/off TuneSync synching
when I'm not at home.

Task:
1. Launch Tunesync
2. keyevent 20 (down)
3. keyevent 23 (click)

Shawn Zimmerman

unread,
Apr 3, 2012, 11:22:25 AM4/3/12
to tas...@googlegroups.com

  Glad I could help.

Doug T.

unread,
Apr 3, 2012, 11:26:49 AM4/3/12
to Tasker
Don't know if I'm posting this right...I'm new in this group. My
question is, and I have posted as a separate discussion, is whether or
not Tasker is able to perform a "click" when the screen is off. What
I'm basically looking for is to make a profile that will "manually"
check K9 mail at specific times. In other words, it opens K9, then
menu, and check mail. I'd like this to happen with the screen off.
I've control tested all the steps leading up to the actual click and
the other button inputs seem to work with the display off. I don't
know if I'm doing something wrong or if it just won't accept click
with screen off. I've installed the locale plugin and everything works
fine when the screen's on. I'm running CM7.

etstudent

unread,
Jun 27, 2012, 10:43:53 AM6/27/12
to tas...@googlegroups.com
Anyone an idea?

Am Montag, 25. Juni 2012 22:12:26 UTC+2 schrieb etstudent:
Hello, 

did anyone tried this with CM9?
It was working for me on original system with my Nexus S.
Now I've installed CM9 some months ago and it doesn't work anymore.

Stupifier

unread,
Sep 6, 2012, 4:17:10 AM9/6/12
to tas...@googlegroups.com
I just wanted to add these commands to the list for everyone....reason being, the Media Control commands through Tasker natively do not work for me....I have no idea why it doesn't work.  It always worked on CyanogenMod7 ROM.  Now I'm using CyanogenMod10 Jellybean ROM and it does not work.  Using the below commands, I am able to control my Music on my phone with Tasker.
87 ---> KEYCODE_MEDIA_NEXT

85 ---> KEYCODE_MEDIA_PLAY_PAUSE

88 ---> KEYCODE_MEDIA_PREVIOUS

89 ---> KEYCODE_MEDIA_REWIND

Stupifier

unread,
Sep 6, 2012, 4:37:34 AM9/6/12
to tas...@googlegroups.com
Out of curiosity, is there a way to remove the flash text message that appears each time one of these Execute commands is ran???  Its just a little annoying to see it.

Matt R

unread,
Nov 20, 2012, 1:16:02 PM11/20/12
to tas...@googlegroups.com
I don't think you can do that with SL4A.  You'd need to follow the methods posted above for touching at a certain location.
 
Matt

Arun

unread,
Nov 21, 2012, 12:54:16 AM11/21/12
to tas...@googlegroups.com

Hi Matt,

Thanks for answering!!  If you find any easy way for touch event on sl4a, plzz  tell me. . .

Arun

unread,
Nov 21, 2012, 2:47:20 AM11/21/12
to tas...@googlegroups.com
One more thing >>>

Can anyone tell how to do automation testing using python by Shell ??

Thanks

Kristof

unread,
Jan 31, 2013, 5:48:55 AM1/31/13
to tas...@googlegroups.com
Great find!

I'll try to use this to access my alarm system.

On Saturday, January 29, 2011 6:45:10 PM UTC+1, HypnoToad wrote:
Yesterday I figured out how to emulate key presses. I was trying to
write a task that simply pushed the number 4 during a call. Everything
that I read online said that this couldn't be done, not only does
Tasker not have this capability but Android won't accept input from
other programs during a call. But, as with all things Android, where
there's a will there's a way.

The only drawback to my method is that you need root permissions.
Sorry.

Here are the steps to start emulating key presses with Tasker.

1. Root your phone

     universal androot and the cyanogen wiki are good sources for
this. google it.

2. Download the needed software

     you will need Tasker (duh) and the "Locale execute plugin"

     http://www.appbrain.com/app/locale-execute-plug-in/de.elmicha.app.LocaleExecute

3. Create your task

    to create your task in tasker open the "plugin" section, select
"execute", then select "edit"
    enter your key emulation commands.

    there are two different commands that you can use to do this the
first command is "input keyevent <event_code>
" (without quotes and the <event_code> represents a number from the
following list)

0 -->  "KEYCODE_UNKNOWN"
1 -->  "KEYCODE_MENU"
2 -->  "KEYCODE_SOFT_RIGHT"
3 -->  "KEYCODE_HOME"
4 -->  "KEYCODE_BACK"
5 -->  "KEYCODE_CALL"
6 -->  "KEYCODE_ENDCALL"
7 -->  "KEYCODE_0"
8 -->  "KEYCODE_1"
9 -->  "KEYCODE_2"
10 -->  "KEYCODE_3"
11 -->  "KEYCODE_4"
12 -->  "KEYCODE_5"
13 -->  "KEYCODE_6"
14 -->  "KEYCODE_7"
15 -->  "KEYCODE_8"
16 -->  "KEYCODE_9"
17 -->  "KEYCODE_STAR"
18 -->  "KEYCODE_POUND"
19 -->  "KEYCODE_DPAD_UP"
20 -->  "KEYCODE_DPAD_DOWN"
21 -->  "KEYCODE_DPAD_LEFT"
22 -->  "KEYCODE_DPAD_RIGHT"
23 -->  "KEYCODE_DPAD_CENTER"
24 -->  "KEYCODE_VOLUME_UP"
25 -->  "KEYCODE_VOLUME_DOWN"
26 -->  "KEYCODE_POWER"
27 -->  "KEYCODE_CAMERA"
28 -->  "KEYCODE_CLEAR"
29 -->  "KEYCODE_A"
30 -->  "KEYCODE_B"
31 -->  "KEYCODE_C"
32 -->  "KEYCODE_D"
33 -->  "KEYCODE_E"
34 -->  "KEYCODE_F"
35 -->  "KEYCODE_G"
36 -->  "KEYCODE_H"
37 -->  "KEYCODE_I"
38 -->  "KEYCODE_J"
39 -->  "KEYCODE_K"
40 -->  "KEYCODE_L"
41 -->  "KEYCODE_M"
42 -->  "KEYCODE_N"
43 -->  "KEYCODE_O"
44 -->  "KEYCODE_P"
45 -->  "KEYCODE_Q"
46 -->  "KEYCODE_R"
47 -->  "KEYCODE_S"
48 -->  "KEYCODE_T"
49 -->  "KEYCODE_U"
50 -->  "KEYCODE_V"
51 -->  "KEYCODE_W"
52 -->  "KEYCODE_X"
53 -->  "KEYCODE_Y"
54 -->  "KEYCODE_Z"
55 -->  "KEYCODE_COMMA"
56 -->  "KEYCODE_PERIOD"
57 -->  "KEYCODE_ALT_LEFT"
58 -->  "KEYCODE_ALT_RIGHT"
59 -->  "KEYCODE_SHIFT_LEFT"
60 -->  "KEYCODE_SHIFT_RIGHT"
61 -->  "KEYCODE_TAB"
62 -->  "KEYCODE_SPACE"
63 -->  "KEYCODE_SYM"
64 -->  "KEYCODE_EXPLORER"
65 -->  "KEYCODE_ENVELOPE"
66 -->  "KEYCODE_ENTER"
67 -->  "KEYCODE_DEL"
68 -->  "KEYCODE_GRAVE"
69 -->  "KEYCODE_MINUS"
70 -->  "KEYCODE_EQUALS"
71 -->  "KEYCODE_LEFT_BRACKET"
72 -->  "KEYCODE_RIGHT_BRACKET"
73 -->  "KEYCODE_BACKSLASH"
74 -->  "KEYCODE_SEMICOLON"
75 -->  "KEYCODE_APOSTROPHE"
76 -->  "KEYCODE_SLASH"
77 -->  "KEYCODE_AT"
78 -->  "KEYCODE_NUM"
79 -->  "KEYCODE_HEADSETHOOK"
80 -->  "KEYCODE_FOCUS"
81 -->  "KEYCODE_PLUS"
82 -->  "KEYCODE_MENU"
83 -->  "KEYCODE_NOTIFICATION"
84 -->  "KEYCODE_SEARCH"
85 -->  "TAG_LAST_KEYCODE"

I was trying to press the number 4 so the command I used to do this
was "input keyevent 11"

As you can see it's possible to emulate just about any key which makes
this very powerful. you can now write a task to open a program and
navigate around it.

The second command is a bit easier but less powerful. The syntax is
"input text <string>" < string > being whatever you want to send to
your phone. So, for me, the command was "input text 4" but had I been
trying to enter the number 4000 I could have used "input text 4000".
Using this method you can't send commands to emulate keys such a menu
or back but, depending on what your trying to emulate, you can
accomplish in one command what might take several "input keyevent"
commands.

IMPORTANT: put an exclamation point before all of your commands.
(example: !input keyevent 11) This tells Locale Execute Plug-in to run
the command a root.

You can run several commands in a row by placing each of them on a
separate line.

After you have your command(s) typed out press the back button to save
then run you task to test it out. The first time it runs you may be
prompted to grant superuser permissions.

Let me know if you found this useful or if you need help. Thanks.

Kristof

unread,
Jan 31, 2013, 2:07:54 PM1/31/13
to tas...@googlegroups.com
How do make tasker place a call and then when it is connected (can be a fixed wait for that matter) send the DTMF codes, wait a couple of seconds and than send another DTMF sequence ?

Matt R

unread,
Jan 31, 2013, 6:15:58 PM1/31/13
to tas...@googlegroups.com
Try using the Tasker dial action and include the entire sequence, with commas for pauses (e.g. 1234567890,1234,1234).  Multiple commas can be used to increase the pause length.

Matt

Kristof

unread,
Feb 1, 2013, 4:16:14 AM2/1/13
to tas...@googlegroups.com
Thanks for your reply, will try this tonight when I get home.
But won't I have to 'confirm' this dial action ? I mean, I thought that it only brings up the dialer with the number, but won't dial itself.

Any idea how long a pause (,) takes ? Can't find it in the documentation

Kristof

unread,
Feb 1, 2013, 4:52:00 AM2/1/13
to tas...@googlegroups.com
From the documentation:

Call

Bring up the dialer screen with the specified phone number filled in.

Commas and Semi-Colons terminate the number currently, this is filed as an Android bug.

Matt R

unread,
Feb 1, 2013, 12:30:49 PM2/1/13
to tas...@googlegroups.com
Maybe that's out of date.  Did you try it?  It worked for me when I tried it yesterday.

Matt

GermainZ

unread,
Feb 16, 2013, 2:11:02 PM2/16/13
to tas...@googlegroups.com

mlesir

unread,
Mar 27, 2013, 10:46:35 PM3/27/13
to tas...@googlegroups.com

Germainz ( or anyelse) could you respond to me if its possible with tasker simulate a touch in the screen of Whatsapp, exactly what i want do its simulate a touch in the submenu, once you have touch the clip icon in any contact( you know the window in which you press for take a photo, send a photo, or send a audio). I try used trackball of tasker  and it fix right but when this submenu appears trackball don´t fix. Then I think perhaps trackball don´t fix because this submenu its not seems like a box, so i think perhaps i need simulate a "direct touch". I spend all the day trying and reading about execute pluging, linux, getintent, comands, etc. I try input keyevent but its the same as  with the trackball. Then i try send event but i don´t know how do it fix. I write send event in many emulators but they do nothing.
My english is very bad and second i don´t have idea about scripts or linux or similar, but i think i have a brain and i can search in google, but before i spend a week to found what i want to do its impossible can you please me and say me if i can emulate a press in whatsapp submenu or window ( with the icon of clip) that allows send a photo, ubication, voice record,etc, this window seems to be blocked or impossible to acces it. I have a rooted galaxy note 1, 4.0.4.

It is loading more messages.
0 new messages