Replace GetForegroundWindow() with GetWindowHandle() call to the browser to fix issue 2534.