Window face wall

The video example is with a lamp but idea is the same

When i move a Window static mesh close to the wall it must face the wall correctly by rotating the (Z), how to do it

Thanx in advance

Question to old