Oops! The previous code solves only half the problem i.e. to display the menu.
You would need to change following two functions for the complete thing.
Code:
;----Open the selected favorite
f_OpenFavorite:
; Fetch the array element that corresponds to the selected menu item:
StringTrimLeft, f_path, f_path%A_ThisMenuItemPos%, 0
if f_path =
return
if f_class contains #32770,bosa_sdm ; It's a dialog.
{
if f_Edit1Pos <> ; And it has an Edit1 control.
{
; Activate the window so that if the user is middle-clicking
; outside the dialog, subsequent clicks will also work:
WinActivate ahk_id %f_window_id%
; Retrieve any filename that might already be in the field so
; that it can be restored after the switch to the new folder:
ControlGetText, f_text, %f_EditClass%, ahk_id %f_window_id%
ControlSetText, %f_EditClass%, %f_path%, ahk_id %f_window_id%
ControlFocus, %f_EditClass%, ahk_id %f_window_id%
ControlSend, %f_EditClass%, {Enter}, ahk_id %f_window_id%
Sleep, 100 ; It needs extra time on some dialogs or in some cases.
ControlSetText, %f_EditClass%, %f_text%, ahk_id %f_window_id%
return
}
; else fall through to the bottom of the subroutine to take standard action.
}
else if f_class in ExploreWClass,CabinetWClass ; In Explorer, switch folders.
{
if f_Edit1Pos <> ; And it has an Edit1 control.
{
ControlSetText, %f_EditClass%, %f_path%, ahk_id %f_window_id%
ControlSend, %f_EditClass%, {Enter}, ahk_id %f_window_id%
return
}
; else fall through to the bottom of the subroutine to take standard action.
}
else if f_class = ConsoleWindowClass ; In a console window, CD to that directory
{
WinActivate, ahk_id %f_window_id% ; Because sometimes the mclick deactivates it.
SetKeyDelay, 0 ; This will be in effect only for the duration of this thread.
IfInString, f_path, : ; It contains a drive letter
{
StringLeft, f_path_drive, f_path, 1
Send %f_path_drive%:{enter}
}
Send, cd %f_path%{Enter}
return
}
; Since the above didn't return, one of the following is true:
; 1) It's an unsupported window type but f_AlwaysShowMenu is y (yes).
; 2) It's a supported type but it lacks an Edit1 control to facilitate the custom
; action, so instead do the default action below.
Run, Explorer %f_path% ; Might work on more systems without double quotes.
return
;----Display the menu
f_DisplayMenu:
; These first few variables are set here and used by f_OpenFavorite:
WinGet, f_window_id, ID, A
WinGetClass, f_class, ahk_id %f_window_id%
f_EditClass = Edit1 ;Default
if f_class contains #32770,ExploreWClass,CabinetWClass,bosa_sdm ; Dialog or Explorer.
{
ControlGetPos, f_Edit1Pos,,,, %f_EditClass%, ahk_id %f_window_id%
if f_Edit1Pos = ; The control doesn't exist, but check for Office 2003
{
f_EditClass = RichEdit20W2
ControlGetPos, f_Edit1Pos,,,, %f_EditClass%, ahk_id %f_window_id%
}
}
if f_AlwaysShowMenu = n ; The menu should be shown only selectively.
{
if f_class contains #32770,ExploreWClass,CabinetWClass,bosa_sdm ; Dialog or Explorer.
{
if f_Edit1Pos = ; The control doesn't exist, so don't display the menu
return
}
else if f_class <> ConsoleWindowClass
return ; Since it's some other window type, don't display menu.
}
; Otherwise, the menu should be presented for this type of window:
Menu, Favorites, show
return
Beware of MS implementation of Open/Save dialog boxes in Office 2003 and do not click middle button while your mouse is inside that big list view. I could not improve it
I am sorry for the hasty post earlier.