JScript code:if(Interop.Call("user32", "GetForegroundWindow") == ChatWnd.Handle){ // chatwnd is focused } else { // chatwnd is not focused }