xmacro is a basic macro-recorder/macro-player.. it is good for some things, but is not suited to monitoring your keystrokes dynamically (other than for recording)...
- xmacro: Record / Play keystrokes and mouse movements in X displays
You are probably better off using a tool like autokey.. You can find some tutorials at How-To Geek
Autokey Sample Scripts
Autokey Video
Autokey Features:
- KDE and GTK versions available, making AutoKey integrate well into any desktop environment.
- Write Python scripts to automate virtually any task that can be accomplished via the keyboard
- Built-in code editor (using QScintilla in KDE or GtkSourceView2 in GTK)
- Create phrases (blocks of text) to be pasted into any program on demand (uses the X selection)
- Create collections of phrases/scripts in folders, and assign a hotkey or abbreviation to the folder to display a popup menu
- Regular expressions can be used to filter windows by their title, to exclude hotkeys/abbreviations from triggering in certain applications
- Scripts, phrases and folders can be attached to the tray icon menu, allowing you to select them without assigning a hotkey or abbreviation
- AutoKey can track your usage patterns and present the most frequently used items at the top of the popup menu