WQO event trigger on closing document?

I have searched the forum and found the same problem had been experienced before but there is no solution on that.

I need to execute some codes on WQO agent when opening a document on read mode from a view, however, the WQO codes run again when I close the document using a button with simply @PostedCommand([FileCloseWindow]).

However if the document is open in edit mode, on closing the document using a button with @PostedCommand([FileSave]);

@PostedCommand([FileCloseWindow]), the WQO agent will not be run again (I got a $$Return Field on my form to direct back to target view)

Another question is that when I click the button with @Command([EditDocument]) on the web, WQO codes will be executed again, how can I check editmode on the web so that to prevent the execution? I try to look up EditMode property but is on UIDocument only.

Thanks in advance.

Subject: WQO event trigger on closing document ???

Sorry me again, any ideas?