Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

New Context Menu Item Puts Any Folder Into a Dialog Window


  • Please log in to reply
16 replies to this topic
DAT
  • Members
  • 58 posts
  • Last active: Jul 17 2014 08:55 AM
  • Joined: 01 Dec 2008
In dialogue windows like ‘Save’ or ‘Save As’ in XP and Vista, or ‘Insert Picture from File’ in Word you have to navigate a folder tree to get to the folder you want. If you have the folder visible already, say in Windows Explorer or on the desktop, it’s annoying that you can’t quickly transfer its path into the window. This script provides a solution.

Here are some screenshots: http://docs.google.c...ck29f_8hr2nj3dz.

; ;;;;;;;;;;;	
; 
; 'Send To Dialog Window'
;  By DAT, 25-01-2009. 
;
;  Acknowledgement: 
;  The function f_Open_Target(target) is based on "Easy Access to Favorite 
;  Shortcuts" by ChrisM at http://www.autohotkey.com/forum/topic5414.html.
;  I modified it to work with Directory Opus, 'Move To' and 'Copy To',
;  and 'Export Registry File' in both Vista and XP. 
;
;  First you need to install a new item 'Send To Dialog Window' to the 
;  folder context menu (see below). After that, if you right-click on any 
;  folder icon and click 'Send To Dialog Window', the folder will be entered 
;  automatically in the 'Save in:' field in 'Save As' and other similar windows.
;
;  This bypasses the restricted navigation options in the dialog Window.
;  It's especially handy if you navigate to folders via popup cascaded menus. 
;  For example, the My Documents cascade in the XP Classic Start Menu 
;  after you enable 'Expand My Documents'. Or even better, popup toolbars from 
;  'True Launch Bar'.
;  
;  It works with all the dialog windows I've found (so far) in Windows XP and Vista, 
;  Office 2003, and Directory Opus. 
;
;  It also works with the 'Move Items' and 'Copy Items' dialog windows from 
;  'Move To' and 'Copy To'. [These are useful items that you can easily add 
;  to the context menu for files and folders in XP and Vista. See, eg,
;  http://technobabble.com.au/technobabble/html/tweaks/context-menus.htm]. 
;
;  To install the new 'Send To Dialog Window' item to the context menu for folders 
;  in Vista or XP use my associated script 'AddSDWtoRegistry.ahk', or do it manually
;  like this:
;
;  1. Create a new registry key "HKEY_CLASSES_ROOT\Folder\shell\Send to Dialog window".
;  2. In the Default variable enter the label that you want to see in the context 
;  menu, eg, "Send to Dialog Window". 
;  3.  Make a new subkey "HKEY_CLASSES_ROOT\Folder\shell\Send to Dialog Window\Command" 
;  4.  In its default variable enter 
;  ""C:\Program Files\AutoHotkey\AutoHotkey.exe" "C:\AutoHotkey Scripts\SendToDialogWindow.ahk" "%1"". 
;  [Don't type the outer quote marks; alter paths to suit your own setup].

Path = %1%		; parameter contains folder path
MsgboxTitle := "Send to Dialogue Window"

IfInString, Path , ::  
  Path:= ""    ; Avoids error message if CLSID sent to Word 'Save As'.
If (Path = "")
{
	Msg := "Sorry`, can't handle this type of folder"
	msgbox ,, %MsgboxTitle%, %Msg% , 4
	ExitApp
}
; Find the top-most dialog window, if any, and get details 
Gosub , Sort
If (Item = "")
{
	Msg := "Closing since no dialogue windows found"
    msgbox ,, %MsgboxTitle%, %Msg% , 4
    ExitApp
}
; Get ready for f_Open_Target()
f_window_id := Item1
WinGetClass, f_class, ahk_id %f_window_id%
ControlGetPos, f_Edit1Pos,,,, Edit1, ahk_id %f_window_id%
ControlGetPos, f_Edit2Pos,,,, Edit2, ahk_id %f_window_id% 
sleep , 200

; When 'folder' is a drive, %1% returns a value with 
; a trailing " tacked on, as in C:". So remove any " characters. 
; Also add a backslash to avoid warnings from XP 'Save As' windows
  
StringReplace , Path , Path , " 
Path = %Path%\  ; needed when sending drive names to 'Save As' in Word 2003 .
f_Open_Target(Path) ; Put the data into the window

If (Item > 1)  ; issue advisory message window
{
    WinGetPos ,  xloc, yloc , wloc, hloc, ahk_id %Item1%
    progw := 200
    progh := 100
  
    xloc := (xloc + wloc/2 - progw/2) 	;Calculate x coordinate of Progress window
    yloc := (yloc + hloc/2 - progh/2)	;Calculate y coordinate of Progress window
	Msg := "Multiple dialogue windows are open. `n`nMake sure this is the one you wanted."
    Progress, B2 x%xloc% Y%yloc% M zh0 w%progw% h%progh%,  , %Msg%
    #Persistent
}
SetTimer , KillProgress , 3000 
Exit
;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;
Sort:
; Get id of top-most dialog-type window
WinGet, Item, list,,, Program Manager   
index := ""                        ; counts number of windows in selection
Loop, %Item%                       ; loop thro' all current windows, top down.
{
	this_Item := Item%A_Index%  ; Item1 contains id of first window, etc
	WinGetClass, f_class, ahk_id %this_item%
	If f_class not contains #32770,f_class,bosa_sdm_  
    {
		Item%A_Index% := ""     
        continue                ; since not a suitable window
    }
    index++                     ; increment pointer 
    Item%index% = %this_Item%   
}
Item:= index    ; number of dialog-type windows collected 
return
;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;
KillProgress:
; Terminate the advisory message
Progress , off
SetTimer , killprogress , Off
ExitApp
;;;;;;;;;;;;
	
;;;;;;;;;;;;;;;;;;;;;;;;;
; Enter path of selected folder into dialog window
 
f_Open_Target( target )
  {
    global f_class, f_Edit1Pos, f_Edit2Pos, f_window_id
    WinGetTitle, Title , ahk_id %f_window_id%   

    ; It's a dialog
    If (f_class = "#32770") 
      {
        If (f_Edit1Pos <> "" And f_Edit2Pos <> "" And Title <> "Export Registry File") 
        ;  Has Edit1 and Edit2 so put folder into Edit2, except if title is 'Export Registry File'
        ;  eg could be 'Save As' in Vista or Browse in DOpus.
          {
            ControlClick ,ToolbarWindow324, ahk_id %f_window_id% ; needed for SaveAs in Vista
            ControlSetText, Edit2, %target%, ahk_id %f_window_id%
            ControlSend, Edit2, {Enter}, ahk_id %f_window_id%  
            Return
          }
        Else If (f_Edit1Pos <> "" And f_Edit2Pos <> "" And Title = "Export Registry File")  
          ; like Reg Export in XP and Vista
          {
            ControlGetText, text, Edit1, ahk_id %f_window_id% ; store filename
            ControlSetText, Edit1, %target%, ahk_id %f_window_id%
            ControlSend, Edit1, {Enter}, ahk_id %f_window_id%
            Sleep, 100  ; needs extra time on some dialogs or in some cases.
            ControlSetText, Edit1, %text%, ahk_id %f_window_id%   ; reinstate stored filename
            Return
          }
        Else If (f_Edit1Pos <> "" And f_Edit2Pos = "")  ; has Edit1 but not Edit2
          {
            ControlGetText, text, Edit1, ahk_id %f_window_id% ; store filename
            ControlSetText, Edit1, %target%, ahk_id %f_window_id% ; target folder into File Name
            If (A_OSVersion = "WIN_VISTA")
              Return
            
            Else        ; special treatment for XP
            ; Unlike 'SaveAs', Copy Items', 'Move Items', 'Browse' windows contain SysTreeView321 
              {
                winget , ctrls , ControlList , ahk_id %f_window_id%
                Loop, Parse, ctrls, `n
                  IfEqual , A_LoopField , SysTreeView321
                    {
                      WinGetText, FName, ahk_id %f_window_id%   ; Name of file to be moved or copied
                      StringSplit, FName, FName, '              ; is between single quotes
                      WinGetTitle, Title , ahk_id %f_window_id%   
                      StringSplit , Title , Title , %A_Space%   
                      Message=You selected %Target%
                      IfEqual , Title2 , Items                  
                        Message=Will %Title1% '%FName2%' to %Target%
                      MsgBox, 1, , %Message%
                      IfMsgBox Cancel
                        return
                    }
                ControlSend, Edit1, {Enter}, ahk_id %f_window_id% ; implement change of target folder
                Sleep, 100  ; It needs extra time on some dialogs or in some cases.
                ControlSetText, Edit1, %text%, ahk_id %f_window_id%   ; reinstate stored filename
                Return
              }
          }
      }
	  ; Microsoft Office application
		Else IfInString, f_class, bosa_sdm_
      {
        ; Retrieve any file name that might already be in the File name
        ; control, so that it can be restored after the switch to the new
        ; folder.
		ControlGetText, text, RichEdit20W2, ahk_id %f_window_id%
        ControlClick, RichEdit20W2, ahk_id %f_window_id%
        ControlSetText, RichEdit20W2, %target%, ahk_id %f_window_id%
        ControlSend, RichEdit20W2, {Enter}, ahk_id %f_window_id%
        Sleep, 100  ; It needs extra time on some dialogs or in some case
        ControlSetText, RichEdit20W2, %text%, ahk_id %f_window_id%
        Return
      }
  }
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

All you do is right-click on the folder icon and then click on a new context menu item called ‘Send to Dialog Window’. This runs the script which then copies the folder’s path into the dialogue window.

The folder icon can be anywhere, say on the desktop or in Explorer, but it’s especially quick and easy if you navigate to folders via cascaded menus. An example of these is the My Documents cascade in the XP Classic Start Menu (after you’ve enabled 'Expand My Documents'). Better still are the popup toolbars from 'True Launch Bar'. With this you just mouse over a folder icon in a toolbar and a cascade of menus unfolds instantly. If you populate the toolbar with a selection of key folders you can get to any sub-folder very quickly indeed. (See screenshots for an illustration).

I’ve made the script work with all the dialog windows I've found so far in Windows XP and Vista, Office 2003, and Directory Opus. Some of the menus in Vista, such as ‘Save’, 'Move To', 'Copy To’, work differently to those in XP. The script handles both versions. It also works with the dialog windows 'Move Items' and 'Copy Items' from 'Move To' and 'Copy To'. These are optional context menu entries that are available once you make the small registry edits described here <!-- m -->http://technobabble.... ... -menus.htm<!-- m -->. I find them very useful and have had no problems using them.

If you have more than one dialog window open when you click ‘Send to Dialog Window’, a message asks you to close all except one.

Adding ‘Send to Dialog Window’ to the context menu requires adding a new subkey to the registry. If you’re comfortable about editing the registry you can do it manually using Regedit. Otherwise you can run the accompanying script ‘AddSDWtoRegistry.ahk’ and do it automatically. The script will also undo the change if required. I’ve tested it in W2k, XP and Vista, but that’s all.

Note: AddSDWtoRegistry assumes that you've stored SendToDialogWindow.ahk in the folder C:\AutoHotkey Scripts\. If not you'll need to edit the variable PathToScript as shown at the beginning of the script.

;;;;;;;;;;;;;;
; Title: 	AddSDWtoRegistry.ahk	
; AutoHotkey Version: 1.0.47
; Language:     English
; Platform:     Win9x/NT
; Author:       DAT 07-02-2009
;
; Apply registry changes to add new context menu item 'Send To Dialog Window'

#NoEnv
SendMode Input 

;;;;;;;;;;;;;;;;;;;;;;;;;
; User input may be required here:
; The next line should show the location of the main script, 'SendToDialogWindow.ahk'.
; If yours is located somewhere other than 'C:\AutoHotkey Scripts\'  you'll need to 
; edit the line. 
;
PathToScript = C:\AutoHotkey Scripts\SendToDialogWindow.ahk
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
WaitFor = 30 ; seconds
ResultMsg = Will wait %WaitFor%s for user input
Delay := 	(WaitFor*1000)		
SetTimer , ButtonCancel , %Delay%
Gosub , GuiSetup

GuiEscape:		; User pressed escape.
GuiClose:		; User closed the window.
ButtonCancel:	; User clicked Cancel button.
gui , Destroy
ExitApp

ButtonGo:
SetTimer , ButtonCancel , off
Gui , Submit ; stores gui selection
gui , Destroy
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;  !!!! Caution: The next section alters the registry, which is	!!!!
;  !!!!	potentially harmful. Don't alter anything in RegWrite	!!!! 
;  !!!! or RegDelete unless you know what you're doing.			!!!! 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
If (var1 = 1)
{
	RegWrite , REG_SZ, HKEY_CLASSES_ROOT, Folder\shell\Send to Dialog Window ,, Send to Dialog Window
	RegWrite , REG_SZ, HKEY_CLASSES_ROOT, Folder\shell\Send to Dialog Window\Command ,, "C:\Program Files\AutoHotkey\AutoHotkey.exe" "%PathToScript%" "`%1"

	ResultMsg = Registry key added - waiting %WaitFor%s for more input
    SoundBeep, 800, 25  
    SoundBeep, 1200,  25  
	SetTimer , ButtonCancel , %Delay%
	Gosub , GuiSetup
}
If (var2 = 1)
{
	RegDelete , HKEY_CLASSES_ROOT, Folder\shell\Send to Dialog Window
	ResultMsg = Registry key removed - waiting %WaitFor%s for more input
    SoundBeep, 1200,  25  
    SoundBeep, 800,  25  
	SetTimer , ButtonCancel , %Delay%
	Gosub , GuiSetup
}
SetTimer , ButtonCancel , %Delay%

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  Set up the GUI
;
GuiSetup:
Gui, Font, S10 CDefault , Verdana
	Gui, Add, Radio, x56 y132w320 h20  checked0 vvar1,  Add registry key
	Gui, Add, Radio, x56 y172 w320 h20 vvar2 , Remove registry key
Gui, Add, Button, x96 y222 w100 h30 Default, Cancel
Gui, Add, Button, x216 y222 w100 h30 , Go
Gui, Add, Text, x16 y22 w360  +Left, Will add or remove a new registry key to put 'Send to Dialog Window' in the context menu of folders.`n`nSelect which you want to do and then click 'Go'.  To escape with no action click 'Cancel'.
Gui, Add, Text, x16 y272 w360  +Center, %ResultMsg%
Gui, Show, x318 y368 h316 w400, 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
To install the key manually,

1. Make a new registry key "HKEY_CLASSES_ROOT\Folder\shell\Send to Dialog window".
2. In the Default variable enter the label that you want to see in the context menu, eg, "Send to Dialog window".
3. Make a new subkey "HKEY_CLASSES_ROOT\Folder\shell\Send to Dialog Window\Command".
4. In its default variable enter ""C:\Program Files\AutoHotkey\AutoHotkey.exe" "C:\AutoHotkey Scripts\SendToDialogWindow.ahk" "%1"". [Don't type the outer quote marks and alter the paths to suit your own setup].

Disclaimer: Modifying the registry is potentially dangerous so don’t do it unless you know what you’re doing. I usually make a System Restore point first just in case.

Acknowledgement: I got the idea for this script after enjoying using ‘Easy Access to Favorite Shortcuts’ by Savage and ChrisM. This is great but restricts itself to a menu of shortcuts to favourite folders. I was wondering if I could make the shortcuts bring up a cascade of menus to ‘drill’ down further, but then realised I already had perfectly good cascades in my True Launch Bar menus. So adding the new context menu item to these seemed a better idea. It’s also handy if you already have the folder you want visible in Explorer.

Deep-Silence
  • Members
  • 89 posts
  • Last active: May 03 2015 05:54 AM
  • Joined: 24 Apr 2009
Hi DAT,
i am wondering how you did the "Highlight-Headline"
within the menu shown in the first picture in purple colour.

Can yo help me with that?
Do you got the code for that?

Here are some screenshots: http://docs.google.c...ck29f_8hr2nj3dz.


With Best Regards, Deep-Silence

aaffe
  • Members
  • 1045 posts
  • Last active: Jan 16 2014 01:32 PM
  • Joined: 17 May 2007
Look here:
<!-- m -->http://www.autohotke... ... enfavorite<!-- m -->
Greetings, aaffe

Deep-Silence
  • Members
  • 89 posts
  • Last active: May 03 2015 05:54 AM
  • Joined: 24 Apr 2009
Thank you aaffe

I asked rexx to add this feature to his FolderMenu,
but he do not know how to add this feature.
Therefore i had some research but did not found anything.

basicly i know the link you postet.
I did not found the solution yet.

Thank you very much.
With Best Regards, Deep-Silence

DAT
  • Members
  • 58 posts
  • Last active: Jul 17 2014 08:55 AM
  • Joined: 01 Dec 2008
The cascaded menu belongs to my favourite third-party program, TrueLaunchBar (see <!-- m -->http://www.truelaunchbar.com/<!-- m -->). TLB always highlights the menu that's been selected.

'My bit' was just the extra item 'Send to Dialog Window' in the context menu of the folder 'Test Folder 1'. After adding the new registry entry this item should appear in the main right-click menu of any folder no matter where it is (eg in Windows Explorer, Desktop, TrueLaunchBar menu, etc).

Hope that helps, and sorry for not making it clearer. I've used TLB for so long I forget that not everybody is familiar with it.

DLJ
  • Members
  • 2 posts
  • Last active: Aug 06 2009 01:41 PM
  • Joined: 06 Aug 2009
DAT

Just tried your script and noticed it doesn't work when Windows Task Manager is running. It looks like the script finds an edit box inside WTM (each of the tabs are dialog windows, the same as the Save As dialog). Do you have a fix for this?

DLJ

DAT
  • Members
  • 58 posts
  • Last active: Jul 17 2014 08:55 AM
  • Joined: 01 Dec 2008
DLJ

Thanks for pointing out the issue with Task Manager. I've put a trap into the Sort subroutine to make it ignore Task Manager completely. This seems to have solved the problem in both XP and Vista. Here's the modified version:

; ;;;;;;;;;;;	
; 
; 'Send To Dialog Window'
;  By DAT, 25-01-2009. 
;
;  06-08-2009.  Modified so as to ignore Windows Task Manager. Otherwise WTM 
;               is detected as a dialog window even when minimised. 
;
;  Acknowledgement: 
;  The function f_Open_Target(target) is based on "Easy Access to Favorite 
;  Shortcuts" by ChrisM at http://www.autohotkey.com/forum/topic5414.html.
;  I modified it to work with Directory Opus, 'Move To' and 'Copy To',
;  and 'Export Registry File' in both Vista and XP. 
;
;  First you need to install a new item 'Send To Dialog Window' to the 
;  folder context menu (see below). After that, if you right-click on any 
;  folder icon and click 'Send To Dialog Window', the folder will be entered 
;  automatically in the 'Save in:' field in 'Save As' and other similar windows.
;
;  This bypasses the restricted navigation options in the dialog Window.
;  It's especially handy if you navigate to folders via popup cascaded menus. 
;  For example, the My Documents cascade in the XP Classic Start Menu 
;  after you enable 'Expand My Documents'. Or even better, popup toolbars from 
;  'True Launch Bar'.
;  
;  It works with all the dialog windows I've found (so far) in Windows XP and Vista, 
;  Office 2003, and Directory Opus. 
;
;  It also works with the 'Move Items' and 'Copy Items' dialog windows from 
;  'Move To' and 'Copy To'. [These are useful items that you can easily add 
;  to the context menu for files and folders in XP and Vista. See, eg,
;  http://technobabble.com.au/technobabble/html/tweaks/context-menus.htm]. 
;
;  To install the new 'Send To Dialog Window' item to the context menu for folders 
;  in Vista or XP use my associated script 'AddSDWtoRegistry.ahk', or do it manually
;  like this:
;
;  1. Create a new registry key "HKEY_CLASSES_ROOT\Folder\shell\Send to Dialog window".
;  2. In the Default variable enter the label that you want to see in the context 
;  menu, eg, "Send to Dialog Window". 
;  3.  Make a new subkey "HKEY_CLASSES_ROOT\Folder\shell\Send to Dialog Window\Command" 
;  4.  In its default variable enter 
;  ""C:\Program Files\AutoHotkey\AutoHotkey.exe" "C:\AutoHotkey Scripts\SendToDialogWindow.ahk" "%1"". 
;  [Don't type the outer quote marks; alter paths to suit your own setup].

Path = %1%		; parameter contains folder path
MsgboxTitle := "Send to Dialogue Window"

IfInString, Path , ::  
  Path:= ""    ; Avoids error message if CLSID sent to Word 'Save As'.
If (Path = "")
{
	Msg := "Sorry`, can't handle this type of folder"
	msgbox ,, %MsgboxTitle%, %Msg% , 4
	ExitApp
}
; Find the top-most dialog window, if any, and get details 
Gosub , Sort
If (Item = "")
{
	Msg := "Closing since no dialogue windows found"
    msgbox ,, %MsgboxTitle%, %Msg% , 4
    ExitApp
}
; Get ready for f_Open_Target()
f_window_id := Item1
WinGetClass, f_class, ahk_id %f_window_id%
ControlGetPos, f_Edit1Pos,,,, Edit1, ahk_id %f_window_id%
ControlGetPos, f_Edit2Pos,,,, Edit2, ahk_id %f_window_id% 
sleep , 200

; When 'folder' is a drive, %1% returns a value with 
; a trailing " tacked on, as in C:". So remove any " characters. 
; Also add a backslash to avoid warnings from XP 'Save As' windows
  
StringReplace , Path , Path , " 
Path = %Path%\  ; needed when sending drive names to 'Save As' in Word 2003 .
f_Open_Target(Path) ; Put the data into the window

If (Item > 1)  ; issue advisory message window
{
    WinGetPos ,  xloc, yloc , wloc, hloc, ahk_id %Item1%
    progw := 200
    progh := 100
  
    xloc := (xloc + wloc/2 - progw/2) 	;Calculate x coordinate of Progress window
    yloc := (yloc + hloc/2 - progh/2)	;Calculate y coordinate of Progress window
	Msg := "Multiple dialogue windows are open. `n`nMake sure this is the one you wanted."
    Progress, B2 x%xloc% Y%yloc% M zh0 w%progw% h%progh%,  , %Msg%
    #Persistent
}
SetTimer , KillProgress , 3000 
Exit
;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;
Sort:
; Get id of top-most dialog-type window
WinGet, Item, list,,, Program Manager   
index := ""                        ; counts number of windows in selection
Loop, %Item%                       ; loop thro' all current windows, top down.
{
	this_Item := Item%A_Index%  ; Item1 contains id of first window, etc
    WinGetTitle , Title , ahk_id %this_item%
	WinGetClass, f_class, ahk_id %this_item%
    If Title contains Windows Task Manager ; Ignore Task Manager 06-08-2009
      Continue
	If f_class not contains #32770,f_class,bosa_sdm_  
    {
		Item%A_Index% := ""     
        continue                ; since not a suitable window
    }
    index++                     ; increment pointer 
    Item%index% = %this_Item%   
}
Item:= index    ; number of dialog-type windows collected 
return
;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;
KillProgress:
; Terminate the advisory message
Progress , off
SetTimer , killprogress , Off
ExitApp
;;;;;;;;;;;;
	
;;;;;;;;;;;;;;;;;;;;;;;;;
; Enter path of selected folder into dialog window
 
f_Open_Target( target )
  {
    global f_class, f_Edit1Pos, f_Edit2Pos, f_window_id
    WinGetTitle, Title , ahk_id %f_window_id%   

    ; It's a dialog
    If (f_class = "#32770") 
      {
        If (f_Edit1Pos <> "" And f_Edit2Pos <> "" And Title <> "Export Registry File") 
        ;  Has Edit1 and Edit2 so put folder into Edit2, except if title is 'Export Registry File'
        ;  eg could be 'Save As' in Vista or Browse in DOpus.
          {
            ControlClick ,ToolbarWindow324, ahk_id %f_window_id% ; needed for SaveAs in Vista
            ControlSetText, Edit2, %target%, ahk_id %f_window_id%
            ControlSend, Edit2, {Enter}, ahk_id %f_window_id%  
            Return
          }
        Else If (f_Edit1Pos <> "" And f_Edit2Pos <> "" And Title = "Export Registry File")  
          ; like Reg Export in XP and Vista
          {
            ControlGetText, text, Edit1, ahk_id %f_window_id% ; store filename
            ControlSetText, Edit1, %target%, ahk_id %f_window_id%
            ControlSend, Edit1, {Enter}, ahk_id %f_window_id%
            Sleep, 100  ; needs extra time on some dialogs or in some cases.
            ControlSetText, Edit1, %text%, ahk_id %f_window_id%   ; reinstate stored filename
            Return
          }
        Else If (f_Edit1Pos <> "" And f_Edit2Pos = "")  ; has Edit1 but not Edit2
          {
            ControlGetText, text, Edit1, ahk_id %f_window_id% ; store filename
            ControlSetText, Edit1, %target%, ahk_id %f_window_id% ; target folder into File Name
            If (A_OSVersion = "WIN_VISTA")
              Return
            
            Else        ; special treatment for XP
            ; Unlike 'SaveAs', Copy Items', 'Move Items', 'Browse' windows contain SysTreeView321 
              {
                winget , ctrls , ControlList , ahk_id %f_window_id%
                Loop, Parse, ctrls, `n
                  IfEqual , A_LoopField , SysTreeView321
                    {
                      WinGetText, FName, ahk_id %f_window_id%   ; Name of file to be moved or copied
                      StringSplit, FName, FName, '              ; is between single quotes
                      WinGetTitle, Title , ahk_id %f_window_id%   
                      StringSplit , Title , Title , %A_Space%   
                      Message=You selected %Target%
                      IfEqual , Title2 , Items                  
                        Message=Will %Title1% '%FName2%' to %Target%
                      MsgBox, 1, , %Message%
                      IfMsgBox Cancel
                        return
                    }
                ControlSend, Edit1, {Enter}, ahk_id %f_window_id% ; implement change of target folder
                Sleep, 100  ; It needs extra time on some dialogs or in some cases.
                ControlSetText, Edit1, %text%, ahk_id %f_window_id%   ; reinstate stored filename
                Return
              }
          }
      }
	  ; Microsoft Office application
		Else IfInString, f_class, bosa_sdm_
      {
        ; Retrieve any file name that might already be in the File name
        ; control, so that it can be restored after the switch to the new
        ; folder.
		ControlGetText, text, RichEdit20W2, ahk_id %f_window_id%
        ControlClick, RichEdit20W2, ahk_id %f_window_id%
        ControlSetText, RichEdit20W2, %target%, ahk_id %f_window_id%
        ControlSend, RichEdit20W2, {Enter}, ahk_id %f_window_id%
        Sleep, 100  ; It needs extra time on some dialogs or in some case
        ControlSetText, RichEdit20W2, %text%, ahk_id %f_window_id%
        Return
      }
  }
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Regards,
DAT.

DLJ
  • Members
  • 2 posts
  • Last active: Aug 06 2009 01:41 PM
  • Joined: 06 Aug 2009
DAT

That's worked perfectly and thanks for your speedy response!

I'm finding it is a real time saver when saving attachements on emails (it works with Thunderbird).

DLJ

qwerty_uk
  • Members
  • 5 posts
  • Last active: Nov 20 2012 10:59 PM
  • Joined: 07 Aug 2009
This is great - got it all set up and looking forward to using it for the first time!

Just one thought - it would be even better to have it work the opposite way. So a right-click in a dialog box would give you a list of open explorer windows to choose from.

That would save having to leave the dialog box at all.

But I don't know if that is even possible.

DAT
  • Members
  • 58 posts
  • Last active: Jul 17 2014 08:55 AM
  • Joined: 01 Dec 2008
qwerty_uk,

I guess you mean by right-clicking empty space in the folder window in the dialog box - and I suppose it would be a bit more intuitive than the way I did it. However you soon get used to it.

To do it as you suggest we'd need to locate that particular context menu in the registry. Anyone know where it lives...?

DAT.

HeWhoWas
  • Members
  • 85 posts
  • Last active: Feb 02 2012 04:53 AM
  • Joined: 03 Aug 2009
I think what he wants is so that when the "Save As" dialog box is open, you can right click anywhere in the dialog box, and it will list the folders that are currently open in explorer. I think WinGetText would help there. Under SlowVisibleText in the AU3 Spy the path can be found. I'm unsure as to how you actually retrieve that text specifically. Maybe Regex?
There are 10 kinds of people in the world. Those who understand binary and those who don't.

qwerty_uk
  • Members
  • 5 posts
  • Last active: Nov 20 2012 10:59 PM
  • Joined: 07 Aug 2009
I think HeWhoWas and DAT have both got the right idea.

It doesn't matter to me where in the dialog box I need to right-click (white space, folder dropdown... or anywhere).

But yes, this would bring up a list of the folder locations of open explorer windows to select from.

This would be equally useful for Save As... and Open... dialogs. I don't know if there is any difference as far as Windows is concerned.


While you're thinking about that, here's a further challenge which would be fantastically useful for me; Some way to replace drive mappings with full network locations. For example:
1. I have an explorer window open at B:\Databases\Sources
2. My B: drive is mapped to \\NET-LOC\MyDepartment\
3. I open a Link Table dialog box from an Access database and right-click to get the list of Explorer windows
4. When the list appears, I can left-click to navigate to B:\Databases\Sources, or right-click to navigate to \\NET-LOC\MyDepartment\Databases\Sources

The distinction is important, because I need someone without the B drive mapping to be able to use the linked table in the database.

I would think that all the drive mapping information is also available in the registry somewhere...

Edit: Found it! Oh please add this feature... please please!
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Map Network Drive MRU

DAT
  • Members
  • 58 posts
  • Last active: Jul 17 2014 08:55 AM
  • Joined: 01 Dec 2008
Well one could avoid using context menus by bringing up a list of the folder locations of open explorer windows with, say, 'ctrl + click' in a specific part of a dialog box, say the titlebar.

Andreone's function IsOverTitleBar, or one of the others, would help with that (http://www.autohotke...topic22178.html).

I'll be away for the next week but maybe someone else wants to have a go ...

qwerty_uk
  • Members
  • 5 posts
  • Last active: Nov 20 2012 10:59 PM
  • Joined: 07 Aug 2009
I'm still keen to get my two suggestions working, namely:

- Reversing the process so that a right-click in a dialog window shows a list of open explorer windows

- Allowing the list to return either the mapped or UNC path

However, I just haven't had any time to work on this myself.

Also, the registry key I mentioned above does seem to list mapped drive locations, but I can't see where it relates them to the actual mapped drive letter. So maybe this isn't the right place afterall.

I've built a workaround for now that simply outputs the clipboard contents while replacing mapped letters with UNC path (or vice-versa) from a hardcoded list. So at least it's easy for me to just copy and paste/convert.

DAT
  • Members
  • 58 posts
  • Last active: Jul 17 2014 08:55 AM
  • Joined: 01 Dec 2008
Hi qwerty_uk,

I just got back to working on it, altho' I haven't tried to address your second suggestion yet.

I've added code so that a left click in the left half of the title bar of a dialog window puts up a list of all the paths currently open in explorer windows together with an automatically compiled list of previous windows that have been used, weighted as to the amount of usage. Hoping to post the new version within a week or so.