If you are talking about a set series of fixed movements on a menu button then bypass the Gcode part altogether and add it to Marlin directly. Marlin is well structured for adding bespoke code.