ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

IDEA: Insta-switch file dialog to any Explorer window's path (code included)

(1/3) > >>

koomi:
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...


--- 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#PersistentSetBatchLines,-1 Gui +LastFoundshWnd := 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, HandleExitReturn ; See http://www.autohotkey.com/forum/post-123323.htmlShellMessage( 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.htmlHookProc( 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()ExitAppReturn

MilesAhead:
I played around with Direct Folders a little bit. These dialog add-ons are interesting.  But what I could really use, is some small monitor that forces file save dialogs to open with Browse Folders extended sufficiently that I don't have to hit the button or resize the dialog with the mouse.  Seems like especially Firefox loves to drive me nuts with this on downloads. It pops up the file save collapsed and I have to mouse it 3 or 4 times a day.

Seems like the size and state won't stick.

AndyM:
Doesn't Skrommel have something that watch's windows and places/sizes them accordingly?

MilesAhead:
Doesn't Skrommel have something that watch's windows and places/sizes them accordingly?
-AndyM (April 02, 2010, 03:19 PM)
--- End quote ---

I think in this case, unless he has a macro to click the Browse Folders button, you'd have to whip up something.  I could probably throw something together in AutoIt3 but I'm curious why Windows doesn't remember it on its own.

Anyway koomi, sorry to hijack your thread.
I'm thinking instead of having an open Explorer window, how 'bout a Top 5 used folders that you could just zap into the dialog as current location?  Or is there a reason to switch as in swap source/destination?

koomi:
Well, I already have Folder Menu for access to favorites, and I use it a lot (except for the list of system recent folders, since it loads so slowly.) The reason I like "QuickSwitch" behaviour is that I often find myself with an explorer window open at the precise location I need to save or open something. I use the keyboard Alt-Tab a lot, so this kind of script is a natural extension to the way I work.

Navigation

[0] Message Index

[#] Next page

Go to full version