Macro recorder/player

sinekonata picture sinekonata · Jan 6, 2012 · Viewed 7.3k times · Source

I am making a sort of Macro recorder/player

I have done the player part with utils such as java.awt.Robot() which emulates basic human mouse/keyboard output commands, reading an XML file.

I am stuck at the part where I have to record that XML file. I have no idea of which Class I can use to do the opposite of Robot() If yo have any FemaleRobot() for me I would be very happy :D

The only thing in this direction I have so far is :

   while (true) {
        Point pos = MouseInfo.getPointerInfo().getLocation();
        System.out.println(pos.x+" x "+pos.y);
   }

which is not much and not really what I want ^_^, I don't know how to use a Mouse/KeyListener since it would require a Component. If it is the only way, what Compoment do I use as I don't want any graphical java implementation? Should I create a phony Component anyway? Which one?

e.g. I want my recorder to write in the XML how I click on my ubuntu desktop or press enter on firefox.

I guess it's clear, if not I will be checking the answers a lot. Have a nice day and thanks for reading this.

Answer

Jovo Krneta picture Jovo Krneta · Jan 8, 2013

Try jnativehook lib: http://code.google.com/p/jnativehook/wiki/examples

It is very easy to use and may meet your needs.