So, you afk yourself in the appropriate biome and leave the game opened, then when a legendary pokemon spawn the game automatically go to Esc menu. The gameplay freeze until you come and hit Esc again. So the Pokemon wont despawn.
Could this be possible somehow? Can we take advantage of the legendary Pokemon spawn message as a checker to auto-click a button?