Hello to ALL.
I see nobody has anything to say

So, after head crash and putting out some part of the hair and taking chat GPT for assistant I got working script.
Have save it as M101.mcs
I have use SMART.MER/2 – signal merger with probe guard function by topcom, he is able to generate ESTOP signal, when connected probe is triggered in the
unexpected moment. It can protect a probe from damage.
This board has inputs that blocks guard function, so I need to provide high level from motion controller while probing process.
Here my script, maybe will useful for somebody else

local inst = mc.mcGetInstance() -- Get the Mach4 instance
local outputSig = mc.OSIG_OUTPUT45 -- Define OUTPUT45 signal
local prevState = -1 -- Variable to store the previous state
-- Function to check probing state and control OUTPUT45
function CheckProbingState()
local state = mc.mcCntlGetState(inst) -- Get the current system state
-- Check if the state has changed
if state ~= prevState then
mc.mcCntlSetLastError(inst, "Current State Changed: " .. tostring(state)) -- Log state change
-- Get the handle for OUTPUT45 signal
local hSig = mc.mcSignalGetHandle(inst, outputSig)
if state == 202 then
mc.mcSignalSetState(hSig, 1)
mc.mcCntlSetLastError(inst, "PoKeys57CNC: Probing Active, OUTPUT45 ON!")
else
mc.mcSignalSetState(hSig, 0)
mc.mcCntlSetLastError(inst, "PoKeys57CNC: Probing Completed, OUTPUT45 OFF!")
end
-- Update the previous state
prevState = state
end
end
-- Timer checks state but only updates OUTPUT45 on change
wxTimer = wx.wxTimer()
wxTimer:Start(100, wx.wxTIMER_CONTINUOUS)
wxTimer:Connect(wx.wxEVT_TIMER, function(event)
CheckProbingState()
end)
• OUTPUT45 turns on only when probing starts (state == 202).
• OUTPUT45 turns off when probing stops.
• The signal only changes when the state actually changes.
Best Wishes.