the only way to programatically open a query window that i know of is /query NICK
I may be misunderstanding you, but i remember helping you with a different script, and if you have a script that closes the window on open, and your trying to read the text the user sent after the window is closed, that is impossible(unless the window contents are saved elsewhere before the close), when the window is closed all text is lost.