We describe a nonempirical procedure for achieving accurate band gaps of extended systems through the insertion of suitably defined potential probes. By enforcing Koopmans' condition on the resulting localized electronic states, we determine the optimal fraction of Fock exchange to be used in the adopted hybrid functional. As potential probes, we consider point defects, the hydrogen interstitial, and various adjustable potentials that allow us to vary the energy level of the localized state in the band gap. By monitoring the delocalized screening charge, we achieve a measure of the degree of hybridization with the band states, which can be used to improve the band-gap estimate. Application of this methodology to AlP, C, and MgO yields band gaps differing by less than 0.2 eV from experiment.