Playing back events into Event queue

Hello

I want to record events in my Java app and play them back later.

Using this to get into event queue

This is in main

Toolkit.getDefaultToolkit().

getSystemEventQueue().push(

new MyEventQueue());

Here we get create the class

class MyEventQueueextends EventQueue

{

public AWTEvent getNextEvent()throws InterruptedException

{

AWTEvent event =null;

event = super.getNextEvent();

System.out.println(event);

return event;

}

}

Also I have looked at the Robot object and was able to use that to play back mouse and button clicks.

My issue and question is that the eventQueue data does not match up exactly to the Robot methods.

Do I have to build a parser to take events from Eventqueue and rebuild them to play back (say after saving it to a file if I want).

Or does anyone know a way to save that event queue part out to an object or a file and play that directly back into the eventqueue or something that translates it back to the Robot object?

Thanks in Advance

[1445 byte] By [Maestro1025a] at [2007-10-2 21:52:00]
# 1

> Do I have to build a parser to take events from Eventqueue and rebuild them to play back (say after saving it to a file if I want).

Don't know if you will need to build a parser, but you will need to recreate the event since the Object that the event is to be performed on will obviously change over time. So you should be able to serialize the event and then recreate the event using the new Object as the source.

Once you recreate the event you should be able to use:

Component.dispatchEvent(...);

camickra at 2007-7-14 1:07:54 > top of Java-index,Desktop,Core GUI APIs...
# 2

You should check out Marathon.

It's a GUI testing tool that can record "user events" and replays them. The point is to replay the user actions (like clicking a button or dragging and dropping something) and not the individual AWT events.

This is because it's not helpful to reconstruct all the AWT events, since some are caused by the user's actions, some are translations of native async events from the underlying OS, and some only arise in a certain state. So if you keep an exact copy of the AWT events, it's a really dirty testing setup to reproduce anything. It's easier to record scripted user actions and replay those instead.

jvaudrya at 2007-7-14 1:07:54 > top of Java-index,Desktop,Core GUI APIs...