Hi, first post ;D
I used to use Direct Folders, but had to switch to Folder Menu after I got tired of dealing with various bugs. One thing I sorely missed was the QuickSwitch feature, so I hacked up a LinkExplorerPathToFileDialog Autohotkey script. It's been briefly tested in Window XP only. If anyone would like to take a stab at any of the "NEEDS HELP WITH" or offer suggestions it would be greatly appreciated! I'm an AHK newbie...
I used to use Direct Folders, but had to switch to Folder Menu after I got tired of dealing with various bugs. One thing I sorely missed was the QuickSwitch feature, so I hacked up a LinkExplorerPathToFileDialog Autohotkey script. It's been briefly tested in Window XP only. If anyone would like to take a stab at any of the "NEEDS HELP WITH" or offer suggestions it would be greatly appreciated! I'm an AHK newbie...
Code: (autoit)
; LinkExplorerPathToFileDialog.ahk v0.01 WIP by koomi
; *** WARNING: Alpha code! Use at your own risk! ***
; Makes a file dialog instantly jump to the folder of any Explorer Window you click
; Idea stolen from Direct Folders' "QuickSwitch" feature.
;
; How to use:
; 1) Open a file dialog (Open/Save, also works with 7-Zip Extract and so forth)
; 2) Switch to an open Windows Explorer window
; 3) The Open/Save dialog will change to same path as the Explorer window
; *) Autohotkey_L is recommended if your system has non-Western foldernames
;
; NEEDS HELP WITH:
; User testing
; Windows Vista/7 compatibility
; Better sanity checking to make sure we're really dealing with a file dialog
; Maybe by matching the window title against a list of known good ones?
; Work with folder tree dialogs as well (like Direct Folders)
; .INI file to allow specifying custom class+control+title combinations
; Microsoft Office compatibility
; Allow modification of the filename after the dialog first opens
; Pretty icon and menu stuff like "Disable/Enable"
; Flash taskbar/caption of dialog parent when path is changed or something
#SingleInstance Force
#Persistent
SetBatchLines,-1
Gui +LastFound
shWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,shWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
HookProcAdr := RegisterCallback( "HookProc", "F" )
hWinEventHook := SetWinEventHook( 0x3, 0x3, 0, HookProcAdr, 0, 0, 0 )
; Globals that need to be shared between ShellMessage() and HookProc()
ControlText =
ControlHwnd =
LastCharacter =
OnExit, HandleExit
Return
; See http://www.autohotkey.com/forum/post-123323.html
ShellMessage( wParam,lParam )
{
global ControlText
global ControlHwnd
global LastCharacter
; See http://msdn.microsoft.com/en-us/library/ms644989.aspx
If ( wParam = 1 || wParam = 4 ) ; HSHELL_WINDOWCREATED := 1 OR HSHELL_WINDOWACTIVATED := 4
{
WinGetClass, Class, ahk_id %lParam%
; Is this an Explorer window?
If (Class = "CabinetWClass" OR Class = "ExploreWClass") ; Might need adjustment for Vista/Win7
{
; Do we have a Open/Save control handle available?
If (ControlHwnd)
{
WinGetTitle, ExplorerTitle, ahk_id %lParam%
If (LastCharacter <> "\")
{
; Change the path to the Explorer path
ControlSetText,, %ExplorerTitle%, ahk_id %ControlHwnd%
ControlSend,, {Enter}, ahk_id %ControlHwnd%
; Put the original filename back in the dialog edit control
ControlSetText,, %ControlText%, ahk_id %ControlHwnd%
}
; For cases like 7-Zip "Extract" dialog which contain pathnames, not filenames
else
{
ControlSetText,, %ExplorerTitle%\, ahk_id %ControlHwnd%
}
; If Dialog is gone, reset globals to avoid extra work next time around
If ErrorLevel
{
ControlText =
ControlHwnd =
LastCharacter =
Exit
}
}
}
}
}
; See http://www.autohotkey.com/forum/topic35659.html
HookProc( hWinEventHook, Event, hWnd, idObject, idChild, dwEventThread, dwmsEventTime )
{
global ControlText
global ControlHwnd
global LastCharacter
If Event ; EVENT_SYSTEM_FOREGROUND = 0x3
{
; Windows and dialog boxes need time to "settle". See AHK manual
Sleep, 120
WinGetClass, DialogClass, ahk_id %hWnd%
; Is this a typical Open/Save dialog box?
If (DialogClass = "#32770")
{
; Populate globals for use in ShellMessage
ControlGet, ControlHwnd, Hwnd,, Edit1, ahk_id %hWnd%
ControlGetText, ControlText, Edit1, ahk_id %hWnd%
StringRight, LastCharacter, ControlText, 1
}
}
}
SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags)
{
DllCall("CoInitialize", Uint, 0)
return DllCall("SetWinEventHook"
, Uint,eventMin
, Uint,eventMax
, Uint,hmodWinEventProc
, Uint,lpfnWinEventProc
, Uint,idProcess
, Uint,idThread
, Uint,dwFlags)
}
UnhookWinEvent()
{
Global
DllCall( "UnhookWinEvent", Uint,hWinEventHook )
DllCall( "GlobalFree", UInt,&HookProcAdr ) ; free up allocated memory for RegisterCallback
}
HandleExit:
UnhookWinEvent()
ExitApp
Return












