Back in 2014, SOLIDWORKS introduced the Slot Mate which allows you quickly insert a pin into a slot to have it free to slide along its length or fix it at a specific position. They can be straight or arc slots (but doesn’t require the Slot sketch tool). And it doesn’t have to circular pin either as you can select any axis to follow the slot.
However when the slots are more complex with more than one section, the slot mate cannot be used.
However this can be accomplished using the SOLIDWORKS Cam Mate. It needs to be round geometry as it essentially keeps the round surface tangent with the slot surfaces. It’s following tangent surface all the way around. But since the pin is the same size as the slot, you don’t notice if it follows the top or bottom surface of the slot.