In vivo imaging using two-photon microscopy is an essential tool to explore the dynamic of physiological events deep within biological tissues for short or extended periods of time. The new capabilities offered by this technology (e.g. high tissue penetrance, low toxicity) have opened a whole new era of investigations in modern biomedical research. However, the potential of using this promising technique in tissues of living animals is greatly limited by the intrinsic irregular movements that are caused by cardiac and respiratory cycles and muscular and vascular tone. Here, we show real-time imaging of the brain, spinal cord, sciatic nerve and myenteric plexus of living mice using a new automated program, named Intravital_Microscopy_Toolbox, that removes frames corrupted with motion artifacts from time-lapse videos. Our approach involves generating a dissimilarity score against precalculated reference frames in a specific reference channel, thus allowing the gating of distorted, out-of-focus or translated frames. Since the algorithm detects the uneven peaks of image distortion caused by irregular animal movements, the macro allows a fast and efficient filtering of the image sequence. In addition, extra features have been implemented in the macro, such as XY registration, channel subtraction, extended field of view with maximum intensity projection, noise reduction with average intensity projections, and automated timestamp and scale bar overlay. Thus, the Intravital_Microscopy_Toolbox macro for ImageJ provides convenient tools for biologists who are performing in vivo two-photon imaging in tissues prone to motion artifacts.