Actually you might want to just type the following in an editbox:
/alias query !query $1- | whois $1 $1
This way it will even whois when you /query NICK in the editbox (if you ever do this), or if a popup does this to open a query window. Otherwise it will
only trigger on double clicks. The above alias will work in more scenarios.
Note that there is an option in Alt+O -> IRC to enable whoising when someone messages you, which you should enable even if you use the above alias, but
not if you use the ON OPEN script.