An intelligent pinhole for confocal microscopy consisting of four position controlled blades forming a rectangular aperture from 3x3μm to 500 x 500 μm was built. This aperture can be positioned without drift under computer control in a positioning range with a sub-micrometer precision. Each blade is suspended by an elastic hinges and moved by a linear magnetic actuator. An integrated position transducer with a reproducibility of better than 40 nm allows a settling time of less than 75 ms. The whole pinhole system is small sized (40x40x20 mm) with an electrical consumption of less than 2W. A first application in a scanning confocal microscope demonstrated the usefulness of such a micro-opto-mechanical system.