You can for example use a macro called autoexample, with two lines:
SelectDBObject (you have to check the parameter saying that the object is in the DB window, I think it must be 'True')
HideDatabaseWindow
I may not be perfectly correct regarding the names of these two macro functions, since I hardly use macros at all.