Grammar
N3AI-drafted〜ところに/〜ところへ/〜ところを
just at the moment when (something else happens)
Formation
V-ている/V-た/V-る + ところに・ところへ・ところを(い形容詞・Nの + ところを)
Usage
These mark a precise moment in one action at which another event cuts in, usually unexpectedly. ところに and ところへ are nearly interchangeable and are followed by verbs of arrival or occurrence: 電話がかかってきた, 来た, 現れた. ところを is used when the person in that situation becomes the object of the second verb: 見られる, 呼び止められる, 助けられる. ところを also appears in set polite phrases such as お忙しいところをすみません.
Examples
出かけるところに、友達が遊びに来た。
でかけるところに、ともだちがあそびにきた。
Just as I was about to go out, a friend dropped by.
昼ご飯を食べているところへ、部長から電話がかかってきた。
ひるごはんをたべているところへ、ぶちょうからでんわがかかってきた。
Right while I was eating lunch, the department head called.
授業中に寝ているところを先生に見られた。
じゅぎょうちゅうにねているところをせんせいにみられた。
The teacher caught me sleeping during class.