にかこつけて・を機に: the difference
にかこつけてN1
Meaning
In the name of, Using the excuse of, To use as a pretext of, Under the guise or pretense of
Past papers
Example
「花子ったら部活動に託けて、部室に潜り込んでひとり遊んでばかりいるよ。」
'Honestly, Hanako! She sneaks into the club room under the pretext of club activities and just plays there by herself.'
を機にN1
Meaning
Opportunity, Occasion
Past papers
Tested 3 times in past papers
Example
妻の妊娠を機にタバコを止めることにした。
I decided to quit smoking when my wife became pregnant.
How to tell them apart
「〜にかこつけて」: clearly negative; the excuse does not match the real motive, a chance to profit.
「〜を口実に(して)」: similar, a bit more neutral; can also be used for excuses in diplomacy or strategy.
「〜を機に / を契機に」: positive or neutral; a big event as a turning point, not a fake excuse.