Getting a programatically-controlled, constant 12 V from one of the motor outputs
It is easy. Leave the driver in. Connect to the first two wires usually used by the motor output. I.e. this is usually where the nema 17 motor goes. The first two wires are your output to the valve.

Use M42 to control the ENABLE pin. Bringing the pin high creates a 0V output. Bringing the pin low creates a 12V output.