The invention relates to a device for automatically limiting position after a gear and a rack reciprocate in a straight line to a terminal under the action of force, in particular to an automatic position limiting device for a gear and a rack with a slideway groove structure when reciprocating to an end. Including housing, fixed seat, main shaft, gear, rack, automatic limit drive block, fixed slideway groove and dragging object, one side of the housing is provided with a fixed seat, the fixed seat is fixedly connected to the main shaft, and the main shaft passes through the housing Connected with the gear, the gear and the rack are meshed; the inside of the housing is equipped with an automatic limit drive block, the rack is set at the inner middle position of the automatic limit drive block, and there are fixed slideway grooves on both sides of the automatic limit drive block. The fixed slideway groove is fixed on the housing, and the end of the automatic limit drive block is connected with the dragging object. The automatic limit driving block of the device is the main structure, which is simple and practical in structure, and is convenient for maintenance; the automatic limit driving block connects different dragging objects at different positions, and is suitable for the connection of dragging objects in any equipment that does linear reciprocating motion.