Function to add full path to "Save As" dialog window title.

Post your working scripts, libraries and tools for AHK v1.1 and older
waveform
Posts: 14
Joined: 20 Dec 2016, 19:31

Function to add full path to "Save As" dialog window title.

15 Mar 2017, 20:59

Just a little function I made today because in Windows 7 the "Save As" dialog doesn't show the full path anywhere, which I thought was a bit silly. :)

Image

Image

Tested in Windows 7 Pro 64-bit using AutoHotkey_U64.exe v1.1.24.00

Code: Select all

ShowFullPathInSaveAsDialog()
{
  WinWaitActive Save File As ahk_class #32770,, 1
  If ErrorLevel <> 0
    Return
  savePath := "" ; this gets the resulting file path.
  ControlGet, comboList, List, , ComboBox1
  SendMessage, 0x147, 0, 0, ComboBox1 ; Get selected line #
  If ErrorLevel < 0
    Return
  comboLine := ErrorLevel
  arrLines := Array() ; remove previous values.
  arrLines := StrSplit(comboList, "`n")
  ; Get drive letter by going backwards to find first ":".
  Loop % comboLine
  {
    thisLine := arrLines[comboLine - A_Index + 2]
    If (Instr(thisLine, ":") > 0) {
      thisLine := RegExReplace(thisLine, "i)^.*([a-z]:).*$", "$1") ; remove everything from drive name except "X:"
      savePath := thisLine
      startLine := comboLine - A_Index + 2 ; line to start going forwards from (the one after the drive letter).
      Break
    }
  }
  If savePath = ""
    Return ; didn't work - possibly didn't find drive letter.
  ; Now loop forwards, adding path names.
  Loop % comboLine - startLine + 1
  {
    thisLine := arrLines[startLine + A_Index]
    fileType := FileExist(savePath . "\" . thisLine) ; ensure path exists.
    If (fileType = "D")
      savePath .= "\" . thisLine ; path exists, add to path string.
    Else
      savePath := RegExReplace(savePath, "\\[^\\]+$", "\" . thisLine) ; replace last path with this one (ie. folder name is on same level as previous one).
  }
  WinSetTitle, % "Save File As (in " . savePath . ")" ; note must include "Save File As" so dialog can be recognised again.
  Return
}
Usage:

Code: Select all

  ~^s::F_ShowFullPathInSaveAsDialog() ; global hotkey CTRL-S. Maybe also trap !f + s (File -> Save As)

; While in the Save As dialog, refresh the path upon keypresses or mouseclicks (ie. after changing folders).
#IfWinActive Save File As ahk_class #32770
{
  ~LButton::
  ~Enter::
  ~BS::
    F_ShowFullPathInSaveAsDialog()
    Return
}
Enjoy!

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 242 guests