I used mouse_ent:
http://www.conitec.net/beta/amouse_ent.htm

If you want to have a look at some code to get further ideas, there is a free ingame editor in the contributions thread, you can have a look at its code, copy and past etc. It is a bit cumbersome, but it could give you a start.