Function sendWindowEvent