title: FindWindow GetLastError 5 ERROR_ACCESS_DENIED
body: <p>I'm calling WIN32 API FindWindow() within my low level Keyboard hook procedure, trying to set focus to my Python scripts GUI window(which is one of the tkinter toplevel window), but every time it gets the result NULL, and GetLastError() always returns 5(ERROR_ACCESS_DENIED), anybody knows the reason? it's running on WIN10 64bit system.</p>
  
  <pre><code>LRESULT CALLBACK MyllKeyboardProc(
      _In_ int    nCode,  
      _In_ WPARAM wParam,
      _In_ LPARAM lParam)
  {
      if (nCode &lt; 0)
      {
          return CallNextHookEx(hHookllkb, nCode, wParam, lParam);
      }
      else
      {
          //printf("Key paras:%d %d %d\n", nCode, wParam, lParam);
          KBDLLHOOKSTRUCT *Key_Info = (KBDLLHOOKSTRUCT*)lParam;
          if (HC_ACTION == nCode)
          {
              if (WM_KEYDOWN == wParam)  //如果按键为按下状态
              {
                  /*
                  if (Key_Info-&gt;vkCode == VK_LWIN || Key_Info-&gt;vkCode == VK_RWIN) //屏敝 WIN(左右) 键
                  {
                      return TRUE;
                  }
                  if (Key_Info-&gt;vkCode == 0x4D &amp;&amp; ((GetKeyState(VK_LWIN) &amp; 0x8000) ||
                      (GetKeyState(VK_RWIN) &amp; 0x8000))) //屏敝 WIN+D 组合键(左右)
                  {
                      return TRUE;
                  }
                  if (Key_Info-&gt;vkCode == 0x44 &amp;&amp; ((GetKeyState(VK_LWIN) &amp; 0x8000) ||
                      (GetKeyState(VK_LWIN) &amp; 0x8000)))  //屏敝 WIN+M 组合键(左右)
                  {
                      return TRUE;
                  }
                  */
                  if (Key_Info-&gt;vkCode == VK_F11 &amp;&amp; GetKeyState(VK_CONTROL) &amp; 0x8000) //屏敝 CTRL + F12 组合键
                  {
  
                      //printf("CTRL+F2 %x\n", wParam);
                      if (bHide)
                          bHide = FALSE;
                      else
                          bHide = TRUE;
                      HideTaskBar(bHide);
                      return TRUE;
                  }
                  if (Key_Info-&gt;vkCode == VK_F12 &amp;&amp; GetKeyState(VK_CONTROL) &amp; 0x8000) //屏敝 CTRL + F11 组合键
                  {
                      int nCmdShow;
                      if (bHideConsole)
                      {
                          nCmdShow = SW_SHOW;
                          bHideConsole = FALSE;
                      }
                      else
                      {
                          nCmdShow = SW_HIDE;
                          bHideConsole = TRUE;
                      }
                      ShowWindow(hWndConsole, nCmdShow);
                      if (hWndConsole &amp;&amp; !bHideConsole)
                      {
                          //Tricks for stealing keyboard input focus. it works
                          ShowWindow(hWndConsole, SW_HIDE);
                          ShowWindow(hWndConsole, SW_SHOW);
                          HWND hWndFocus = NULL;
                          if(bScriptRunning==TRUE){
                              HWND hWndRun = FindWindow(NULL, _T("The user interface for A - code supervision"));
                              if (hWndRun)
                              {
                                  printf("Py running GUI window found:%x\n", hWndRun);
                                  hWndFocus = hWndRun;
                                  SetForegroundWindow(hWndFocus);
                                  SetFocus(hWndFocus);
                                  SetActiveWindow(hWndFocus);
                                  EnableWindow(hWndFocus, TRUE);
                              }
                              else
                              {
                                  printf("Py running GUI window not found error code: %d\n", GetLastError());
                              }
                          }
                          else {
                              hWndFocus = hWndConsole;
                              SetForegroundWindow(hWndFocus);
                              SetFocus(hWndFocus);
                              SetActiveWindow(hWndFocus);
                              EnableWindow(hWndFocus, TRUE);
                          }
                      }
                      return TRUE;
                  }
                  /*
                  if (Key_Info-&gt;vkCode == VK_TAB &amp;&amp; Key_Info-&gt;flags &amp; LLKHF_ALTDOWN) //屏敝 ATL + TAB 组合键
                  {
                      return TRUE;
                  }
                  if (Key_Info-&gt;vkCode == VK_ESCAPE &amp;&amp; Key_Info-&gt;flags &amp; LLKHF_ALTDOWN) //屏敝 ATL + ESC 组合键
                  {
                      return TRUE;
                  }
                  */
              }
  
          }
          return CallNextHookEx(hHookllkb, nCode, wParam, lParam);
      }
  }
  </code></pre>