[SCRIPT] getevent -> sendevent - Easily automate screen/button taps from the shell

Search This thread

fabzbear

Senior Member
Nov 26, 2010
934
80
Can anyone help me. I'm have a galaxy s4 Sprint. I'm on jflte probam 1.3.7. I'm trying to get the Google now launder app drawer script but having no luck when I try using the script. I tried the original 4-10 but it just kept going for over three minutes. I tried reducing it n running the script but nothing happened.
What am I doing wrong?

Sent from my SPH-L720 using XDA Free mobile app
 

Top Liked Posts

  • There are no posts matching your filters.
  • 25
    Intro
    I originally wrote this script for LMT, but it has changed a lot since then and (hopefully) deserves its own thread.
    You can check the original script's post here, or read more about (part of) what this script is automating (and how it does it) here.
    You can also check the Tasker Google Groups thread about the script (clickie).

    So what does this do?
    It "listens" to your input actions (screen taps, button presses, etc) and turns them into a script you can use to reproduce them.
    Think of it as something similar to Excel's Macro Recording feature.

    Usage
    Run the script, pick the first option and enter the number of events to catch. Depending on the device, one button press ~ 4 events, sometimes more. A screen tap is unpredictable as you're never touching the screen in one spot but in many close spots.
    A neat trick would be to enter a high number of events (e.g. 500), do whatever you want to do then wait for ~X seconds (10 for example). Then copy the generated script but exclude everything after the line that says "sleep X".
    And if you still have any doubts... try it. That's probably the best way to understand what it does and how to use it.

    Custom toolbox
    You need a custom toolbox (instead of the default /system/bin/toolbox) in order to use Option 2 correctly. This is because the default "getevent" command isn't line buffered, so it usually sends its output every ~50 lines.
    I therefore re-compiled the toolbox (getevent is only a launcher for it) to enable line buffering. This enables the script to work at full speed - it might still be too slow, so do allow a few extra seconds (10 seconds should be safe) of no activity for it to finish.
    You'll need to download the modified version, linked below, place it in /tmp/ and give it the correct permissions (chmod 755). Note that it will not persist across reboots, so keep a backup somewhere else.
    Code:
    https://www.dropbox.com/s/t0xhxa3xuc8m92m/toolbox

    Download
    You can get the latest version here.

    Bugs/Suggestions
    Bugs? There are no bugs.
    Actually, I'm not an elite script writer, so chances are there are a few quirks. If you find any, please report them. :)
    Also post all your suggestions and I'll try to add them.

    To do
    • This list will be updated based on your feedback.

    Thanks
    • The guys at #bash helped me a lot.
    • zeppelinrox, learned plenty of stuff from his scripts.
    • Everyone who tested previous versions (mostly laufersteppenwol :p).


    Also feel free to ask any question, or answer any potentially interesting question that should be added to this post. I'll make sure to update it with a FAQ.

    Thanks ;)
    I've contacted a moderator and he said it was okay for me to post in this section instead of the Misc. Software Development section, so it wouldn't get buried within hundreds of ROMs/kernels for devices without forums. This section will be cleaned soon anyway.
    2
    Update:
    • You're now warned if you don't have busybox installed;
    • Busybox not automatically creating symlinks shouldn't be an issue any longer;
    • The timeout option should now work, but you'll need a custom toolbox (instead of /system/bin/toolbox) to run it. Read the OP for more info.

    I'm not sure if the custom toolbox will work on all devices. Please test it out, it's completely safe as you'll be placing it in /tmp/ anyway without overwriting the original, unmodified version on your device. :)
    1
    worked flawlessly thanks man , example with search button with filtered inputs for xperia play

    qezFkiI.png
    1
    Can you do a YouTube tutorial or just a written one one how to use it to get an event like opening the app draw of a launcher or something.
    You give some explanation but I'm still a bit lost after rereading twice.

    Sent from my SPH-L710 using xda app-developers app

    Choose option 1 or 2, wait for the countdown to finish. do whatever you want to do.
    For option 2, it should be simple enough - you just put a timeout. You'll need the modified toolbox from the first post, tho.

    For option 1, you have to input a certain number of events. It's just impossible to predict that (especially if you're dealing with screen taps and not just button presses), so I suggest you do this:
    1. Put a higher number (e.g. 500) (if you're only interested in button presses, 1 button press = ~4->~10 events, depending on the device).
    2. Do whatever you want to do.
    3. Wait for ~10s without doing anything.
    4. Check the script's output (by reopening the terminal emulator/script manager).
    5. If the script has finished (500 events have been reached already), it probably didn't record everything. Restart from step 1, with a higher number (e.g. 1000).
    6. If not, spam your touchscreen till it's done.
    7. Copy the outputted script and search for a line that looks like "sleep 10" (where "10" is approximately the amount of seconds you waited in step 3).
    8. Remove everything after that line.

    PS: If you get spam events from other input devices you're not interested in (e.g. compass), you can use Option 4 to only monitor the touchscreen device, for example.
    1
    I would like to make a script to copy current text line to clipboard. With Hackers soft keyboard, the keys to press are: HOME, SHIFT+END, CTROL+C. Anyway to do this
    simulation with either "input keyevent ..." or "sendevent...".

    I don't think so, not unless you have a hard keyboard.