Auto Key press fill forms through simulating key presses |

2010-07-31 253 words 2 mins read

This script can be used to repeatedly press <a class="zem_slink" title="Electronic keyboard" rel="wikipedia" href="">keys on the <a class="zem_slink" title="Keyboard (computing)" rel="wikipedia" href="">keyboard, it was used to fill out 100 odd entries on a <a class="zem_slink" title="Web page" rel="wikipedia" href="">web page while testing without having to physically enter the data.

Save the code below some where like <a class="zem_slink" title="Filesystem Hierarchy Standard" rel="wikipedia" href="">/usr/bin/ with what ever file name you like, set the file to be <a class="zem_slink" title="Executable" rel="wikipedia" href="">executable with <a class="zem_slink" title="Chmod" rel="wikipedia" href="">chmod +x /usr/bin/keyrepeat

you can then run the command keyrepeat 100 &#8221;1&#8221; or what ever you chose as the <a class="zem_slink" title="Filename" rel="wikipedia" href="">filename of your script.

You will have 5 seconds to focus a window, the program will then simulate a user pressing the keys on the keyboard.

sleep 5 #delay to allow the user to focus a window number=$1 #first parameter, number of times to repeat text=$2 #second parameter, text to repeat will interpret as tab for ((counter=1;counter< =$number;counter+=1)); do #loop required number of times xvkbd -xsendevent -text $text #this sends the text as key presses done

<a href=""><h6 class="zemanta-related-title" style="font-size: 1em;">Related articles by Zemanta <ul class="zemanta-article-ul"> <li class="zemanta-article-ul-li"><a href="">Google search in command line &#8221; Linux by Examples ( <li class="zemanta-article-ul-li"><a href="">Qjoypad: Keyboard to Gamepad Mapping for Linux ( <li class="zemanta-article-ul-li"><a href="">Emacs Macros and the Power-Macros Package | Linux Journal ( <div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href=""><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="" alt="Enhanced by Zemanta" /><span class="zem-script more-related pretty-attribution">


Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it