In this work, the TBTPY-Py aggregation-induced emission (AIE) molecules with N and S have been examined as a corrosion inhibitor for N80 mild steel in 15 wt.% HCl solution was evaluated using weight loss method and electrochemical measurements. The corrosion inhibition capability of TBTPY-Py increased with the rising concentration, and the optimal corrosion inhibition efficiency reached 96.98% at 50 mg/L. The real-time fluorescence observation combined with electrochemical impedance test revealed that the AIE intensity and corrosion inhibition efficiency increased synchronously, TBTPY-Py molecules can act as the fluorescence indicator to visualize the adsorption of TBTPY-Py molecule on metal surface. The adsorption behaviour and corrosion mechanism of inhibitor molecule were further studied using atomic force microscopy, water contact angle, X-ray photoelectron spectroscopy, Fourier transform infrared spectroscopy, scanning electron microscope and energy Dispersive Spectrometer. Results confirmed the chemisorption of TBTPY-Py molecules on the steel surface to form a hydrophobic protective layer, thus inhibiting metal corrosion.