~ようとする
(1) Try to …, attempt to … (2) Be about to … (just before an action)
N3
V-volitional + とする / としている / としたとき, としたら
~ようとする expresses attempting something or the moment just before an action: {出|で}ようとしたとき = just as I was about to leave. It often goes with ~とき or ~たら to tell what unexpectedly happened. Unlike ~ようと{思|おも}う (just an intention in your head), ~ようとする means the action has started or is very close. With a thing as the subject, e.g. {電車|でんしゃ}が{発車|はっしゃ}しようとしている, it only means "about to". Learners often mis-conjugate the volitional, e.g. {帰|かえ}る→{帰|かえ}ろう (group 1).
Examples
家を出ようとしたとき、電話が鳴った。
Just as I was about to leave home, the phone rang.
重い箱を一人で持ち上げようとして、腰を痛めた。
I hurt my back trying to lift a heavy box by myself.
寝ようとしていたら、隣の部屋から大きな音が聞こえた。
As I was about to fall asleep, I heard a loud noise from the next room.
Exercises
1.電車に乗ろう とき、ドアが閉まってしまった。
2.機械を としたら、先輩に「電源を切ってから!」と言われた。