title: c# how to get window explorer Directory path under mouse cursor
body: <p>I want to get window explorer Directory path under mouse cursor.
  I tried <code>AutomationElement</code> but it only detect name or process id etc that I dont want. I
  also tried <code>SHDocVw.ShellWindows</code> It seems working but I cant define which one is choosen.</p>
  
  <p>here is a source i tried</p>
  
  <pre><code>string GetDropPath(AutomationElement element){
              string dir = element.Current.Name;
  
              if (dir.Split('.').Length &gt;= 2) return null;
  
              string desktop = CommonDir["Desktop"];
              if (Directory.Exists(desktop + "\\" + dir))
              {
                  dir = desktop + "\\" + dir;
              }
              else
              {
                  if (CommonDir.ContainsKey(dir))
                  {
                      dir = CommonDir[dir];
                  }
                  else if (!Directory.Exists(dir))
                  {
  
  
                      foreach (InternetExplorer item in new SHDocVw.ShellWindows())
                      {
                          //uint ppid = 0;
                          //GetWindowThreadProcessId(item.HWND, out ppid);
                          if (item.LocationURL.ToString().StartsWith("file:///"))
                          {
                              List&lt;int&gt; children = GetAllChildrenWindowHandles(item.HWND, 100);
                              if (item.HWND == element.Current.NativeWindowHandle || children.Contains(element.Current.NativeWindowHandle))
                              {
                                  string pth = item.LocationURL.Replace("file:///", "");
                                  if (Directory.Exists(pth + "\\" + dir))
                                  {
                                      dir = pth + "\\" + dir;
                                  }
                                  else
                                  {
                                      dir = pth;
                                  }
                                  break;
                              }
                          }
                      }
  
                  }
              }
              if (Directory.Exists(dir))
              {
                  return dir;
              }
              else
              {
                  return null;
              }
          }
  </code></pre>