  Coherent control over electron dynamics in atoms and molecules using
high-intensity circularly-polarized laser pulses gives rise to current loops,
resulting in the emission of magnetic fields. We propose and demonstrate with
ab-initio calculations ``current-gating" schemes to generate direct or
alternating-current magnetic pulses in the infrared spectral region, with
highly tunable waveform and frequency, and showing femtosecond-to-attosecond
pulse duration. In optimal conditions, the magnetic pulse can be highly
isolated from the driving laser and exhibits a high flux density ($\sim1$ Tesla
at few hundred nanometers from the source, with a pulse duration of 787
attoseconds) for application in forefront experiments of ultrafast
spectroscopy. Our work paves the way toward the generation of attosecond
magnetic fields to probe ultrafast magnetization, chiral responses, and spin
dynamics.
