Is this even possible? Maybe it's not from actionscript but extendscript? or a plugin?
ActionScript MouseEvents do contain mouse location information relative to the sprite and containing stage.
You should be able to get away with simply adding another mouseDown event hander to the ContextMenu class.
If that doesn't work for you, you might need to override the default mouseDown handler (subclass the ContextMenu class). Your override will need to extract the location info, and then either allow the normal (overridden) mouseDown handler to complete, or handle it all itself. Note that by overriding the mouseDown event handler the default action (showing the menu) will not happen unless you tell it to happen.
I've been away from extension development for a while now, so I'm not set up to create an example for you.
Thanks for the reply, sadly I'm still not able to add a mouse down or any other mouse events to the context menu.
I am talking about the inDesign default context menu which in creative suite extension builder has the class com.adobe.indesign.Menu
I added this menu item but as soon as it's pressed I want to create a rectangle at mouse coordinates. But I'm not able to find those.
it seems I'm not able to add a mouseEvent handler to a com.adobe.indesign.Menu or com.adobe.indesign.MenuItem. Maybe I could add a mouseDown handler to the window or layer or something but that's not straightforward either.
You pretty much can't get mouse position from InDesign; however, you can use the ContextMenu (and not use the ID flavor).