Monday, October 8, 2007

Automate your xsession and repetative tasks :XMacro

Xmacro consists of a few command-line programs that can record and playback mouse moves and key presses from and to xsession.

It also contains and assortment of script commands that can be edited in to the macro script (text file) to tune its performance.
eg. Delay [n] - where n is a number of seconds.

so to start, record a macro by running

xmacrorec2 >newmacro.mac

(where newmacro.mac is the filename that will capture all the recorded info)

then xmacro will ask you set a key that will be presses when you are done recording (a good choice is the escape key)

As soon as you select the key, the recording will being, every mouse move, click and keypress will be recorded until you press the done key.

* note the timings of the above events are not recorded, so you will have to add delay events into the macro file later if your application requires pauses.

When you have pressed the done key, the recording is terminated and you can edit your macro file adding and removing the simple script commands.

To playback the macro file :

xmacroplay -d 10 :0 < newmacro.mac

where "-d 10 " is a delay of 10 microseconds
":0" is the screen to run the macro on

Enjoy!

PS. you can even make the macro run from your desktop or toolbar by making a shell script etc.

No comments: