I have a system for doing exactly this but unfortunately in Mach 3! Since M4 uses a different macro language it wouldn't be usable directly. Anyway, it depends on three things.
First, an X axis home switch that gives me a machine coordinate zero on switch on. This means that you don't have to reference the tools to T1, and T1 can be a real tool.
Second, a system to detect contact between any tool and a workpiece in the chuck/spindle.
Third, a tool setter with a short MT4 taper to fit the headstock, with accurately measured OD and IDs machined on it concentric.
Then I have an extra Offsets screen with macros behind it that populates a row in the tool table with X and Z offsets. Basically you set the tool "N" close to the setter, both in diameter and near a reference shoulder, enter the tool number, then click a button, it takes 3 readings of the contact position and calculates the tool offsets from the average.
Also on the Manual screen I have an extra 3 buttons, Touch OD, Touch ID, and Touch Z. These can be used for more accurate setting to turn a final diameter (with OD and ID), and to find the end of the stock and set Z to zero on it. So if I rough turn a piece to say 12.1mm with a target of getting 12mm after the finish cut, and the actual diameter after rough turning is 12.07 measured with a mike, I can do a "Touch OD" which should say 12.1, type in 12.07 which is the actual diameter, and put on the finish cut.
Happy to provide more details if this is of interest. The macros might be a clue though they are in the wrong language, and the general workflow might be useful.