Windows lose focus, seemingly at random

Anonymous
2009-11-23T19:36:32+00:00

Since upgrading from Vista Business to 7 Business, I've run into an intermittent issue. Windows seem to lose focus at random. It may be happening more than I realize, since I have to be actively using the window to notice when it stops accepting my input. For instance, I might be scrolling to the bottom of a web page when I realize that moving the scroll wheel on my mouse no longer has any effect, or I might be typing something in Word while looking away from the screen, only to realize upon looking back that half of the sentence I'd typed was ignored because of a shift in focus. If I'm reading a particularly long web page, I'll occasionally notice the color of the transparent title bar change slightly when the focus changes, as though I'd clicked over to another program. I haven't been able to figure out what is stealing the focus whenever this happens, and it's a new occurrence under 7. Unfortunately, it's sporadic enough that trying to turn off programs running in the background to determine if they're the cause may prove kind of tricky. Has anyone else run into anything like this? If so, any fixes? I have a feeling the culprit may be the GMail Notifier or Trillian Astra, since they both pop up notices from time to time, but many (if not all) of those notices typically don't cause problems.

Any help you can offer would be great.

Windows for home | Previous Windows versions | Accessibility

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
Anonymous
2009-11-24T13:55:20+00:00

Hey karpar,

Any third party software conflicting with Windows components can result to this behavior. Hence, putting your system in clean boot state can help in determining the culprit application or program. A clean boot loads only those files and programs that are absolutely required by the Operating System. Upon determining the background application causing the issue, you may contact the vendor for assistance.

Steps to perform clean boot:

1)       Click Start, type msconfig in the Start Search box, and then press ENTER.

2)       If you are prompted for an administrator password or for a confirmation, type the password, or click Continue.

3)       On the General tab, click Selective Startup.

4)       Under Selective Startup, click to clear the Load Startup Items check box.

5)       Click the Services tab, click to select the Hide All Microsoft Services check box, and then click Disable All.

6)       Click OK.

7)       When you are prompted, click Restart.

After the computer starts, test and see whether the sporadic behavior of Windows loosing focus continues.

If not, we definitely know for sure that the behavior is contributed by third party software conflicts.

To determine which application, follow the steps mentioned in the article below.

How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

http://support.microsoft.com/kb/929135

After you determine the startup item or the service that causes the problem, contact the program manufacturer to determine whether the problem can be resolved

Having done so, don’t forget to return your computer to start normally.

Reset the computer to start as usual

1)       Click Start, type msconfig.exe in the Start Search box, and then press ENTER.

2)       If you are prompted for an administrator password or for confirmation, type your password, or click Continue.

3)       On the General tab, click the Normal Startup option, and then click OK.

4)       When you are prompted to restart the computer, click Restart.

Hope this resolves the issue.


Regards,

Shinmila H - Microsoft Support

Visit our Microsoft Answers Feedback Forumand let us know what you think

Was this answer helpful?

90+ people found this answer helpful.
0 comments No comments

74 additional answers

Sort by: Newest
  1. Anonymous
    2014-05-07T14:33:43+00:00

    Just had the same problem on Windows 8.1; here's how I found the issue fixed it:

    1. Task Manager
    2. Services Tab
    3. Sort by status
    4. Found a service that was running then stopping periodically - HP Connected Remote Service
    5. Start menu
    6. Type "Services"
    7. Click "View Local Services"
    8. Right click HP Connected Remote Service
    9. Properties
    10. Startup type: Disabled
    11. OK
    12. Fixed

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-04-03T15:16:51+00:00

    The code to display the active process helped me solve my problem. I let the browser idle at an input field until it lost focus and checked the process ID. There was no active window title, which was perfect because that's what I was noticing -- it wasn't another window popping up, the current window simply lost focus.

    I pulled up Task Manager, chose select columns, and added the PID column to the display. I sorted based on that column, tracked down the program and discovered it was app running in the system tray that I didn't need any longer. I gave it the heave-ho. Brilliant.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2014-03-01T21:19:42+00:00

    This was very useful for me. I modified the code a little bit so that it only prints when the active process switches, and it also prints the Process object itself. This helps because not all processes have an active window, so printing out the active window title may not help. The process that was stealing the focus for me turned out to be one of those background processes. 

    (Credit to M Razavi, this is his code that I copy-pasted and added to)

    If you want to compile it, it is C#. I did it in Visual Studio 2013.

    Here is a version that I compiled on Windows 7, 64-bit.

    https://docs.google.com/file/d/0B8J3t9FgHn13NU54Q29JS0dOZ3c/edit

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;

    using System.Diagnostics;

    using System.Runtime.InteropServices;

    using System.Threading;

    namespace GetActiveProcess

    {

        class Program

        {

            [DllImport("user32.dll")]

            private static extern IntPtr GetForegroundWindow();

            [DllImport("user32.dll")]

            private static extern Int32 GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);

            private static Process GetActiveProcess()

            {

                IntPtr hwnd = GetForegroundWindow();

                return hwnd != null ? GetProcessByHandle(hwnd) : null;

            }

            private static Process GetProcessByHandle(IntPtr hwnd)

            {

                try

                {

                    uint processID;

                    GetWindowThreadProcessId(hwnd, out processID);

                    return Process.GetProcessById((int)processID);

                }

                catch { return null; }

            }

            static void Main(string[] args)

            {

                Process old_process = null;

                while (true)

                {

                    Process activeProcess = GetActiveProcess();

                    if (old_process == null || (activeProcess != null && activeProcess.Id != old_process.Id))

                    {

                        if (activeProcess.Id != Process.GetCurrentProcess().Id)

                        {

                            Console.WriteLine("PID=" + activeProcess.Id + "\nTitle=" + activeProcess.MainWindowTitle + "\n"+ activeProcess.ToString() + "\n");

                            old_process = activeProcess;

                        }

                    }

                    Thread.Sleep(10);

                }

            }

        }

    }

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2014-02-18T23:44:40+00:00

    I spent ages on this tonight and found my cure to be in the accessibility options:

    control panel>ease of access>ease of access center>make the mouse easier to use

    uncheck "activate a window by hovering over it with the mouse"

    no idea how this got turned on but whenever I pushed the mouse to move the pointer out of the way for typing and it landed on another window it would shift focus to that window after a second or two

    this is by design but I didn't switch it on myself maybe something else did?

    Was this answer helpful?

    0 comments No comments