I found this example in a japanese textbook:
外を歩いている人はみんな傘をさしています: Everyone is using umbrellas outside.
Why is を in that sentence?, and because it is a japanese textbook I doubt that it is inconrrect, shouldn't be like this?
Verb of movement can take を to express the idea of moving about within that space. So here, 外を歩いている expresses the idea of "walk around outside". In a similar vein 空を飛ぶ means "to fly through the sky".
外に歩く isn't quite grammatical in the sense which you seem to have in mind; instead it means "to walk toward the outside". It would be better to say, 外で歩く but it doesn't have quite the same feel as 外を歩いている. 外で歩く seems to suggest that there are other places where you could have chosen to walk--maybe you're at a convention and you could walk inside the convention center or outside. But, 外を歩いている carries a connotation of walking about outside with perhaps no particular destination in mind.
There are no methods to distinguish exceptions, or how to distinguish between "Nを" and "Nに" clearly.
外を歩く： "他に働きかける"動詞に接続 Walk in the outdoor space. * 頂上を目指す * 人を愛する
外に歩く: "他に働きかける"動詞に接続 but 方向性が見られる場合がある Walk in the direction of the outdoor space. * 写真に撮る * 図に表す