This paper introduces a new Windowed Green Function (WGF) method for the numerical integral-equation solution of problems of electromagnetic scattering by obstacles in presence of dielectric or conducting half-planes. The WGF method, which is based on use of smooth windowing functions and integral kernels that can be expressed directly in terms of the free-space Green function, does not require evaluation of expensive Sommerfeld integrals. The proposed approach is fast, accurate, flexible and easy to implement. In particular, straightforward modifications of existing (accelerated or unaccelerated) solvers suffice to incorporate the WGF capability. The mathematical basis of the method is simple: the method relies on a certain integral equation posed on the union of the boundary of the obstacle and a small flat section of the interface between the penetrable media. Numerical experiments demonstrate that both the near-and far-field errors resulting from the proposed approach decrease faster than any negative power of the window size. In the examples considered in this paper the proposed method is up to thousands of times faster, for a given accuracy, than a corresponding method based on the layer-Green-function.