Take off your hat when you come into the room.

Literal

Room [to-に] enter [toward speaker-てくる] [when-ときに] [topic-は] hat [object-を] take-off [imperative-なさい].

Uses ~てくる (motion toward the speaker). Combined with ~ときには and ~なさい for a manners instruction.