From the help file
Quote:
on 1:OPEN:?:*:/echo -s Just opened $target query window

The above example triggers just after a query window is opened.