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
I was trying to press the number 4 so the command I used to do this
was "input keyevent 11"
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
How do you find the !sendevent?
Does this work for you?
I want to do it too. How do you do it?
You're welcome. I'm glad someone found this useful.
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?
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.
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)
Glad I could help.
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.
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.