Light-gated ion channels and pumps have made it possible to probe intact neural circuits by manipulating the activity of groups of genetically similar neurons. What is needed now is a method for precisely aiming the stimulating light at single neuronal processes, neurons or groups of neurons. We developed a method that combines generalized phase contrast with temporal focusing (TF-GPC) to shape two-photon excitation for this purpose. The illumination patterns are generated automatically from fluorescence images of neurons and shaped to cover the cell body or dendrites, or distributed groups of cells. The TF-GPC two-photon excitation patterns generated large photocurrents in Channelrhodopsin-2-expressing cultured cells and neurons and in mouse acute cortical slices. The amplitudes of the photocurrents can be precisely modulated by controlling the size and shape of the excitation volume and, thereby, be used to trigger single action potentials or trains of action potentials.