Thanks for your answer! It seems to work!
But I have one question: when I use the scriptListerner, and draw a selection with the QuickSelection tool, the listener records this:
// =======================================================
var idslct = charIDToTypeID( "slct" );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idquickSelectTool = stringIDToTypeID( "quickSelectTool" );
ref1.putClass( idquickSelectTool );
desc2.putReference( idnull, ref1 );
executeAction( idslct, desc2, DialogModes.NO );
How did you manage to record the other stuff?