I assume this is a continuation of your other thread.
In addition to the encoder, you'll need a totalizing counter. Check companies like Durant, Veeder-Root, Red Lion, Omron. You wire your encoder to the counter's input. Get a counter with a normally closed or Form C contact output so the contact is closed from an accumulated count of zero up to the preset value and opens when the accumulated count reaches the preset. Wire the NC contact in series with the switch on your drill. You'll also need a DC power supply for the encoder, usually 5 VDC, but you need to make sure that the encoder and the counter operate at the same voltage level.
You'll need to do a little arithmetic to figure out the preset for the counter. For example, say you get an encoder with 360 counts per revolution and couple it to a piece of 1/2-13 threaded rod. In 12 inches of travel the rod will rotate 12 (inches) times 13 (revs per inch) times 360 (counts per rev) = 56,160 counts.
Enter your preset value into the counter and reset the accumulated count to zero. When you press the trigger on the drill, you should turn the rod and the accumulated count should begin to increase. When you reach the preset value, the NC contact will open, stopping the drill.
The drawback to this approach is that the drill is turning at maximum speed when you shut it off, so it will coast to a stop. You'll find that your stopping point is beyond where you wanted to stop. A little experimentation will show you that your actual stopping point varies over some range. If the stopping range is within an acceptable tolerance, great. If not, the next step would be to find some method of slowing down the speed of the drill as you approach your target position. That way, when you reach the counter's preset and stop the drill, you're running slower so you don't coast as far.