How to Paste with Tasker (Root only)

487 views
Skip to first unread message

Rich D

unread,
Feb 20, 2013, 7:01:17 AM2/20/13
to Tasker Google Groups Post

Disclaimer:  This post is being written by someone who had to Google what a 'Terminal emulator' IS before downloading it and using it for this procedure. I do not know if this procedure can harm your device in any way. So as with most things root, please proceed At your own risk. Perhaps a more experienced user could chime in on any possible dangers.

110% of the credit for this goes to .. GermainZ..    It is his amazing script found here:

https://groups.google.com/group/tasker/browse_thread/thread/4c2a910ad4f51154/eb0172fc9a66981f?hl=en&lnk=gst&q=Helper+script%3A+reproduce#eb0172fc9a66981f

that makes it all possible..

I am Not sure this keyboard shortcut is available on all devices However if you 'Hold the menu button' and press "v" this should activate a Paste function.

Unfortunately GermainZ's helper script above is either device or manufacturer specific (I'm not sure wich)   so the event codes listed below are for a I moto droid 4 running 2.3.6.   rooted.

The thing that took me the longest time to figure out was  the actual number of the events per button push. Without looking it up I believe in the tutorial it states something like MOST Buttons have 4 events.  The key word obviously being most..  And the tricky part being Even if you send an incomplete Set of events you can still get a partially correct response. For example I thought I had found the correct 4 events for the letter "v" because a capital "V" was returned but it turns out to get the proper "v" I actually needed 10 events ( 5 for down press 5 for up) and the menu button was a total of 14 ( 7down 7 up)  on my device.

Here is what I found:

AGAIN.. THIS IS FOR A DROID 4.........

Menu.   Button

sendevent /dev/input/event4    3    53    95
sendevent /dev/input/event4    3    54  1017
sendevent /dev/input/event4    3    48    15
sendevent /dev/input/event4    3    50     1
sendevent /dev/input/event4    3    57     0
sendevent /dev/input/event4    0     2     0
sendevent /dev/input/event4    0     0     0
sendevent /dev/input/event4    3    53    95
sendevent /dev/input/event4    3    54  1017
sendevent /dev/input/event4    3    48     0
sendevent /dev/input/event4    3    50     1
sendevent /dev/input/event4    3    57     0
sendevent /dev/input/event4    0     2     0
sendevent /dev/input/event4    0     0     0

"v"  Button

sendevent /dev/input/event1    3     2   265
sendevent /dev/input/event1    0     0     0
sendevent /dev/input/event3    4     4    15
sendevent /dev/input/event3    1    47     1
sendevent /dev/input/event3    0     0     0
sendevent /dev/input/event1    3     2   269
sendevent /dev/input/event1    0     0     0
sendevent /dev/input/event3    4     4    15
sendevent /dev/input/event3    1    47     0
sendevent /dev/input/event3    0     0     0

So for the menu short cut simply put the first 7 events for the menu button (down press), then a 1 sec wait then the entire 'v'  button then the rest of the menu button

Hitch it all together for a 'Run shell' action in tasker and you get this:

sleep 10; sendevent /dev/input/event4    3    53    95; sendevent /dev/input/event4    3    54  1017; sendevent /dev/input/event4    3    48    15; sendevent /dev/input/event4    3    50     1; sendevent /dev/input/event4    3    57     0; sendevent /dev/input/event4    0     2     0; sendevent /dev/input/event4    0     0     0; sleep 1; sendevent /dev/input/event3    4     4    15; sendevent /dev/input/event3    1    47     1; sendevent /dev/input/event3    0     0     0; sendevent /dev/input/event1    3     1   998; sleep 0;  sendevent /dev/input/event4    3    53    95; sendevent /dev/input/event4    3    54  1017; sendevent /dev/input/event4    3    48     0; sendevent /dev/input/event4    3    50     1; sendevent /dev/input/event4    3    57     0; sendevent /dev/input/event4    0     2     0; sendevent /dev/input/event4    0     0     0

And we are now pasting with tasker.   All thanks to the tremendous work of 'The amazing Mr. Z'      

When i get a chance I will post this along with other newbie help tips over on GermainZ's post.....

Rich....

GermainZ

unread,
Feb 20, 2013, 11:48:34 AM2/20/13
to tas...@googlegroups.com
Glad you got it working :D

From Googling around (the documentation is seriously lacking for sendevent/getevent) and observation, it seems to be device specific. On the LMT Launcher thread (that's where I posted the script), people reported using different codes for same device manufacturers, depending on the device's model.

I highly doubt there are any dangers at all - the worse thing would be for some event to be missed if your device is seriously busy. In that case, it might cause unwanted long presses. Tapping again should release any touches that are still registered, so that's not a problem.

Anyway, you gave me an idea. I'm almost done testing it: specify a timeout instead of the number of events.

I could also add a vibration once it's done - all from within the script:
# vibrate for 500 ms
busybox echo 500 > "/sys/class/timed_output/vibrator/enable" 
 
Isn't that awesome? ;)

I'll also update the script to use busybox instead of relying on symlinks (e.g. "busybox echo" instead of "echo").

Rich D

unread,
Feb 20, 2013, 11:17:41 PM2/20/13
to Tasker Google Groups Post

Oooooooops........   I did do some testing before I posted this but as usual forgot to test with the slide out keyboard closed ...  I always have the keyboard out any time I use the phone so it is almost its natural state..  The Paste work around does not work when the keyboard is closed, so I would suspect that it would not work on devices without a slide out keyboard.  So unless I can figure out a way to emulate the keyboard being open the paste work around will have limited use.     :(     Sorry if I instilled any false hope.....    Rich.

Rich D

unread,
Feb 21, 2013, 7:34:56 PM2/21/13
to Tasker Google Groups Post

Here is some more disappointing  info on this subject  I found after a little more research.

- The google gods have decreed that we no longer need keyboard shortcuts. So from ICS and beyond they are no longer available. 

- In gingerbread and below you definitely need a physical keyboard and it needs to be open for the shortcuts to work..

So in short if you have a device running gingerbread or below, that has a physical keyboard and you would like to paste something with tasker. But only when the keyboard is open...... Then this is just the work around you have been looking for.

This will obviously be a very sought after procedure so please be patient when posting questions and comments. I will answer them as timely as I can..........      :)    ...

Rich..

GermainZ

unread,
Feb 21, 2013, 7:45:20 PM2/21/13
to tas...@googlegroups.com
Mhm. From what I've been reading on these forums, most people usually try to paste into specific apps to speed up, say, texting.

In that case, it's usually safe to assume that:
1- The text box will always be at the same position;
2- The (soft) keyboard's state will be known (it will either be always shown or always hidden: e.g. entering a conversation in Whatsapp never opens the keyboard by default) (which means point #1 is always valid);
3- The popup menu (when long pressing the text box) will always have the same amount and position of items.

In other words... you should be able to use the script to simply emulate a long press + a "Paste" tap.

By the way, I've read in a few topics on XDA that sometimes, pressing the Menu button + "v" on your soft keyboard also pastes text. Didn't work for me (running GB) and I didn't bother testing it much with different keyboard (wasn't using stock keyboard).

Also, adding a timeout option is much more tricky than expected. Simply put, the buffer isn't being, umm.. "pushed" fast enough so I can't get real time data from  getevent. Asked on SO for advice, we'll see.

Rich D

unread,
Feb 21, 2013, 8:05:05 PM2/21/13
to tas...@googlegroups.com

> In other words... you should be able to use the script to simply emulate a long press + a "Paste" tap.

Yup, that was the way I was heading but thought I had found a nice little short cut... a little more research up front would have been a good idea..

>
> Also, adding a timeout option is much more tricky than expected. Simply put, the buffer isn't being, umm.. "pushed" fast enough so I can't get real time data from  getevent. Asked on SO for advice, we'll see.
>

> Thanks for trying to improve.  Once you know what you are looking for the way it is now actually works quite well..  

Rich..

ScottS

unread,
Apr 16, 2013, 6:36:04 PM4/16/13
to tas...@googlegroups.com
@Rich, thought to come to you for this...

Run Log shows a run error when trying to execute my getevents. If this is the wrong syntax, let me know; I simply place the following into a 'Run Shell' Action:

sendevent /dev/input/event5 3 53 603; sendevent /dev/input/event5 3 54 184; sendevent /dev/input/event5 3 58 51; sendevent /dev/input/event5 3 50 5; sendevent /dev/input/event5 3 57 0; sendevent /dev/input/event5 0 2 0; sendevent /dev/input/event5 0 0 0; sendevent /dev/input/event5 3 53 603; sendevent /dev/input/event5 3 54 184; sendevent /dev/input/event5 3 58 56; sendevent /dev/input/event5 3 50 6; sendevent /dev/input/event5 3 57 0; sendevent /dev/input/event5 0 2 0; sendevent /dev/input/event5 0 0 0; sleep 1; sendevent /dev/input/event5 3 53 603; sendevent /dev/input/event5 3 54 184; sendevent /dev/input/event5 3 58 50; sendevent /dev/input/event5 3 50 4; sendevent /dev/input/event5 3 57 0; sendevent /dev/input/event5 0 2 0; sendevent /dev/input/event5 0 0 0; sendevent /dev/input/event5 3 53 603; sendevent /dev/input/event5 3 54 184; sendevent /dev/input/event5 3 58 42; sendevent /dev/input/event5 3 50 4; sendevent /dev/input/event5 3 57 0; sendevent /dev/input/event5 0 2 0; sendevent /dev/input/event5 0 0 0; sendevent /dev/input/event5 3 53 603; sendevent /dev/input/event5 3 54 184; sendevent /dev/input/event5 3 58 31; sendevent /dev/input/event5 3 50 1; sendevent /dev/input/event5 3 57 0; sendevent /dev/input/event5 0 2 0; sendevent /dev/input/event5 0 0 0; sendevent /dev/input/event5 3 53 603; sendevent /dev/input/event5 3 54 184; sendevent /dev/input/event5 3 58 26; sendevent /dev/input/event5 3 50 1; sendevent /dev/input/event5 3 57 0; sendevent /dev/input/event5 0 2 0; sendevent /dev/input/event5 0 0 0; sendevent /dev/input/event5 3 53 603; sendevent /dev/input/event5 3 54 184; sendevent /dev/input/event5 3 58 20; sendevent /dev/input/event5 3 50 1; sendevent /dev/input/event5 3 57 0; sendevent /dev/input/event5 0 2 0; sendevent /dev/input/event5 0 0 0; sendevent /dev/input/event5 0 2 0; sendevent /dev/input/event5 0 0 0

Rich D

unread,
Apr 16, 2013, 7:53:55 PM4/16/13
to tas...@googlegroups.com

> Run Log shows a run error when trying to execute my getevents. If this is the wrong syntax, let me know; I simply place the following into a 'Run Shell' Action:

With 'use root' selected of course... ?

It looks OK ......

Just curious, what buttons are you emulating?

Everything is working in emulator?

Do you get a error if you try to just emulate one button?

Rich..

>

ScottS

unread,
Apr 17, 2013, 11:35:45 AM4/17/13
to tas...@googlegroups.com
It works now...the code was a bit off, and I hadn't selected 'use root'. :-)

The events are for selecting 'None' in Android Settings/Security/Screen Lock. The problem I was encountering...when opening 'Setting', it is not always starting at the top. This forced me to first open the Setting page, then use the getevents for just the Screen Lock and None selections. It's a bit ackward, but it works.

Reply all
Reply to author
Forward
0 new messages