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="http://en.wikipedia.org/wiki/Electronic_keyboard">keys on the <a class="zem_slink" title="Keyboard (computing)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Keyboard_%28computing%29">keyboard, it was used to fill out 100 odd entries on a <a class="zem_slink" title="Web page" rel="wikipedia" href="http://en.wikipedia.org/wiki/Web_page">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="http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard">/usr/bin/ with what ever file name you like, set the file to be <a class="zem_slink" title="Executable" rel="wikipedia" href="http://en.wikipedia.org/wiki/Executable">executable with <a class="zem_slink" title="Chmod" rel="wikipedia" href="http://en.wikipedia.org/wiki/Chmod">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="http://en.wikipedia.org/wiki/Filename">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="http://www.linux.com/community/blogs/auto-key-press-fill-forms-through-simulating-key-presses.html">http://www.linux.com/community/blogs/auto-key-press-fill-forms-through-simulating-key-presses.html<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="http://linux.byexamples.com/archives/407/google-search-in-command-line/">Google search in command line &#8221; Linux by Examples (linux.byexamples.com) <li class="zemanta-article-ul-li"><a href="http://maketecheasier.com/qjoypad-keyboard-to-gamepad-mapping-for-linux/2010/05/03">Qjoypad: Keyboard to Gamepad Mapping for Linux (maketecheasier.com) <li class="zemanta-article-ul-li"><a href="http://www.linuxjournal.com/article/3769">Emacs Macros and the Power-Macros Package | Linux Journal (linuxjournal.com) <div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/zemified_e10.png" alt="Enhanced by Zemanta" /><span class="zem-script more-related pretty-attribution">

Related Articles:

  • 2010/05/19  
  • 2010/07/11  
  • 2010/07/25  
  • 2010/07/20  
  • 2010/07/14  

author

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