Truck refuses to run

I have a 2002 F250 4 whl drive 7,3 L Diesel with auto tranny.
It refuses to run unless the foot is on the brake pedal. I have replaced the brake stop switch and A L L the fuel filters. It will start at times and idle near perfect and at other times it will start and then stop. When it does idle there is not a skip but when you put it in drive it shuts down unless you keep your foot on the brake.
Any ideas would be greatly appreciated as I think I only have 2 hairs on me head I have not pulled out

Sounds like the lockup torque converter may be locking up when it’s not supposed to. Stepping on the brake interrupts the voltage to the lockup solenoid and causes it to disengage. In this case it wouldn’t be the torque converter itself but it would be getting a false signal to lockup.