Simplest way to connect a proximity sensor to a PC
To use this sensor, connect ground and power (6..36V). The third wire will be connected to ground when something is detected, otherwise it will be floating.

Note that it does not output 300 mA, that figure is the maximum current it can handle (sink to ground).

If you have a 4-20mA input you could use a resistor to supply 20mA to it, and use the output wire to ground the 4-20mA input to ground, so it will get 0 mA (or at least a good deal less than 20) when the sensor detects something.

You could use a serial port if you know how to read a handshake signal in your programming language.