Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How to use bash command control a Keyboard.

e.g. what is a command in bash for pressing ctrl+c, ctrl+l, etc..?

share|improve this question
1  
There's no bash command for that, bash doesn't have anything to do with keyboards. There are external applications you can invoke from the command line. Are you running in a GUI? How do you plan to determine which window you'll send the key events to? –  Gilles Oct 24 '11 at 23:45

1 Answer 1

up vote 2 down vote accepted

AutoKey is a desktop automation utility for Linux and X11. It allows the automation of virtually any task by responding to typed abbreviations and hotkeys. It offers a full-featured GUI that makes it highly accessible for novices, as well as Python scripting .... Here is the link to Autokey's homepage.

Note: When I first looked at Autokey, its scripting interface could not handle Unicode fully. I forget exactly how that was, but it was something like it could process UTF-8 internally, but couldn't deliver it to the something-or-other. If it wasn't for that, I'd be using it today; it looks great, and it has a good reputation (I know it from Windows-land). Otherwise, it is quite comprehensive. I believe it is a fork of Autoit3 (again Windows).. I've used Autoit3 and it is absolutely fully featured. I think Autokey is similar.... Autokey is available in the Ubuntu repository..


xdotool lets you programatically (or manually) simulate keyboard input and mouse activity, move and resize windows, etc.

xdotool key  --clearmodifiers --delay 40 "ctrl+shift+u" 

Another option is package xmacro. It contains macroplay and xmacrorec (and xmacrorec2). xmacrorec can be used to record mouse and keyboard events on any X11 display. xmacroplay can be used to playback recorded events or send any other mouse/keyboard events you choose.

  echo -n "KeyStrPress Control_L 
           KeyStrPress Alt_L   
           KeyStrPress a    
           KeyStrRelease a    
           KeyStrRelease Alt_L   
           KeyStrRelease Control_L"|
           xmacroplay :0.0 &>/dev/null

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.