maestrith / AHK-Studio

Created with AHK Studio
http://www.maestrith.com
363 stars 68 forks source link

AHK-Studio doesn't select file when opens the folder #195

Open jollycoder opened 5 years ago

jollycoder commented 5 years ago

Hi, maestrith When I launch the "Open Folder" menu item, the folder opens, but the current file does not become selected. Just in case, there is code which can do that:

SelectFilePath(filePath)
{
   SplitPath, filePath,, dir
   for window in ComObjCreate("Shell.Application").Windows  {
      ShellFolderView := window.Document

      try if ((oFolder := ShellFolderView.Folder).Self.Path != dir)
         continue
      catch
         continue

      for item in oFolder.Items
         if (item.Path = filePath && found := true)
            break 2
   }
   if !found
      Run, explorer /select`, "%FilePath%"
   else  {
      WinActivate, % "ahk_id" window.hwnd
      ShellFolderView.SelectItem(item, 1|4|8|16)
   }
}