topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Monday December 2, 2024, 2:38 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: Insta-switch file dialog to any Explorer window's path (code included)  (Read 15770 times)

koomi

  • Participant
  • Joined in 2006
  • *
  • Posts: 4
    • View Profile
    • Donate to Member
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 [Select]
  1. ; LinkExplorerPathToFileDialog.ahk v0.01 WIP by koomi
  2. ; *** WARNING: Alpha code! Use at your own risk! ***
  3. ; Makes a file dialog instantly jump to the folder of any Explorer Window you click
  4. ; Idea stolen from Direct Folders' "QuickSwitch" feature.
  5. ;
  6. ; How to use:
  7. ;   1) Open a file dialog (Open/Save, also works with 7-Zip Extract and so forth)
  8. ;   2) Switch to an open Windows Explorer window
  9. ;   3) The Open/Save dialog will change to same path as the Explorer window
  10. ;   *) Autohotkey_L is recommended if your system has non-Western foldernames
  11. ;
  12. ; NEEDS HELP WITH:
  13. ;   User testing
  14. ;   Windows Vista/7 compatibility
  15. ;   Better sanity checking to make sure we're really dealing with a file dialog
  16. ;       Maybe by matching the window title against a list of known good ones?
  17. ;   Work with folder tree dialogs as well (like Direct Folders)
  18. ;   .INI file to allow specifying custom class+control+title combinations
  19. ;   Microsoft Office compatibility
  20. ;   Allow modification of the filename after the dialog first opens
  21. ;   Pretty icon and menu stuff like "Disable/Enable"
  22. ;   Flash taskbar/caption of dialog parent when path is changed or something
  23.  
  24. #SingleInstance Force
  25. #Persistent
  26. SetBatchLines,-1
  27.  
  28. Gui +LastFound
  29. shWnd := WinExist()
  30. DllCall( "RegisterShellHookWindow", UInt,shWnd )
  31. MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
  32. OnMessage( MsgNum, "ShellMessage" )
  33.  
  34. HookProcAdr := RegisterCallback( "HookProc", "F" )
  35. hWinEventHook := SetWinEventHook( 0x3, 0x3, 0, HookProcAdr, 0, 0, 0 )
  36.  
  37. ; Globals that need to be shared between ShellMessage() and HookProc()
  38. ControlText =
  39. ControlHwnd =
  40. LastCharacter =
  41.  
  42. OnExit, HandleExit
  43.  
  44. ; See http://www.autohotkey.com/forum/post-123323.html
  45. ShellMessage( wParam,lParam )
  46. {
  47.     global ControlText
  48.     global ControlHwnd
  49.     global LastCharacter
  50.  
  51.     ; See http://msdn.microsoft.com/en-us/library/ms644989.aspx
  52.     If ( wParam = 1 || wParam = 4 ) ;  HSHELL_WINDOWCREATED := 1 OR HSHELL_WINDOWACTIVATED := 4
  53.     {
  54.         WinGetClass, Class, ahk_id %lParam%
  55.         ; Is this an Explorer window?
  56.         If (Class = "CabinetWClass" OR Class = "ExploreWClass") ; Might need adjustment for Vista/Win7
  57.         {
  58.             ; Do we have a Open/Save control handle available?
  59.             If (ControlHwnd)
  60.             {
  61.                 WinGetTitle, ExplorerTitle, ahk_id %lParam%
  62.                 If (LastCharacter <> "\")
  63.                 {
  64.                     ; Change the path to the Explorer path
  65.                     ControlSetText,, %ExplorerTitle%, ahk_id %ControlHwnd%
  66.                     ControlSend,, {Enter}, ahk_id %ControlHwnd%
  67.                     ; Put the original filename back in the dialog edit control
  68.                     ControlSetText,, %ControlText%, ahk_id %ControlHwnd%
  69.                 }
  70.                 ; For cases like 7-Zip "Extract" dialog which contain pathnames, not filenames
  71.                 else
  72.                 {
  73.                     ControlSetText,, %ExplorerTitle%\, ahk_id %ControlHwnd%
  74.                 }
  75.                 ; If Dialog is gone, reset globals to avoid extra work next time around
  76.                 If ErrorLevel
  77.                 {
  78.                     ControlText =
  79.                     ControlHwnd =
  80.                     LastCharacter =
  81.                     Exit
  82.                 }
  83.             }
  84.         }
  85.     }
  86. }
  87.  
  88. ; See http://www.autohotkey.com/forum/topic35659.html
  89. HookProc( hWinEventHook, Event, hWnd, idObject, idChild, dwEventThread, dwmsEventTime )
  90. {
  91.     global ControlText
  92.     global ControlHwnd
  93.     global LastCharacter
  94.  
  95.     If Event ; EVENT_SYSTEM_FOREGROUND = 0x3
  96.     {
  97.         ; Windows and dialog boxes need time to "settle". See AHK manual
  98.         Sleep, 120
  99.         WinGetClass, DialogClass, ahk_id %hWnd%
  100.         ; Is this a typical Open/Save dialog box?
  101.         If (DialogClass = "#32770")
  102.         {
  103.             ; Populate globals for use in ShellMessage
  104.             ControlGet, ControlHwnd, Hwnd,, Edit1, ahk_id %hWnd%
  105.             ControlGetText, ControlText, Edit1, ahk_id %hWnd%
  106.             StringRight, LastCharacter, ControlText, 1
  107.         }
  108.     }
  109. }
  110.  
  111. SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags)
  112. {
  113.     DllCall("CoInitialize", Uint, 0)
  114.     return DllCall("SetWinEventHook"
  115.     , Uint,eventMin
  116.     , Uint,eventMax
  117.     , Uint,hmodWinEventProc
  118.     , Uint,lpfnWinEventProc
  119.     , Uint,idProcess
  120.     , Uint,idThread
  121.     , Uint,dwFlags)
  122. }
  123.  
  124. UnhookWinEvent()
  125. {
  126.     Global
  127.     DllCall( "UnhookWinEvent", Uint,hWinEventHook )
  128.     DllCall( "GlobalFree", UInt,&HookProcAdr ) ; free up allocated memory for RegisterCallback
  129. }
  130.  
  131. HandleExit:
  132. UnhookWinEvent()
  133. ExitApp

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
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

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 616
    • View Profile
    • Donate to Member
Doesn't Skrommel have something that watch's windows and places/sizes them accordingly?

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Doesn't Skrommel have something that watch's windows and places/sizes them accordingly?

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

  • Participant
  • Joined in 2006
  • *
  • Posts: 4
    • View Profile
    • Donate to Member
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.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
FlashFolder has this feature and apart from windows explorer, it also supports total commander. however FlashFolder has no support for windows 7 and isn't being actively developed.

Winkie

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 93
    • View Profile
    • Donate to Member
If anyone would like to take a stab at any of the "NEEDS HELP WITH" or offer suggestions it would be greatly appreciated!

Well, here is my input. (I've only been able to test it on a pc with WinXP and Office 2003.)

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?
Microsoft Office compatibility
-koomi

IMHO, Class #32770 is the only "real" one. MS Office has different ones. I added a check for them. But that won't probably work with Office 2007 and later.

Work with folder tree dialogs as well (like Direct Folders)
-koomi

Should be possible, but I don't how (yet?).

EDIT:
Code is in here: New Context Menu Item Puts Any Folder Into a Dialog Window. Also Vista is mentioned here.

Allow modification of the filename after the dialog first opens
-koomi

I implemented that by moving the text-grabbing after switching to Explorer.

Your code only works if Window Explorer has the full file path in it's title. I don't have set that option, so I made it grab the path from the edit field instead. I also added a check which should prevent using Control Panel and My Computer etc.

Here is my updated code, please test it:
Code: AutoIt [Select]
  1. ; LinkExplorerPathToFileDialog.ahk v0.02 WIP by koomi & Winkie
  2. ; *** WARNING: Alpha code! Use at your own risk! ***
  3. ; Makes a file dialog instantly jump to the folder of any Explorer Window you click
  4. ; Idea stolen from Direct Folders' "QuickSwitch" feature.
  5. ;
  6. ; How to use:
  7. ;   1) Open a file dialog (Open/Save, also works with 7-Zip Extract and so forth)
  8. ;   2) Switch to an open Windows Explorer window
  9. ;   3) The Open/Save dialog will change to same path as the Explorer window
  10. ;   *) Autohotkey_L is recommended if your system has non-Western foldernames
  11. ;
  12. ; NEEDS HELP WITH:
  13. ;   User testing
  14. ;   Windows Vista/7 compatibility
  15. ;   Better sanity checking to make sure we're really dealing with a file dialog
  16. ;       Maybe by matching the window title against a list of known good ones?
  17. ;   Work with folder tree dialogs as well (like Direct Folders)
  18. ;   .INI file to allow specifying custom class+control+title combinations
  19. ;   Microsoft Office 2007/2010 compatibility
  20. ;   Pretty icon and menu stuff like "Disable/Enable"
  21. ;   Flash taskbar/caption of dialog parent when path is changed or something
  22.  
  23. #SingleInstance Force
  24. #Persistent
  25. SetBatchLines,-1
  26.  
  27. Gui +LastFound
  28. shWnd := WinExist()
  29. DllCall( "RegisterShellHookWindow", UInt,shWnd )
  30. MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
  31. OnMessage( MsgNum, "ShellMessage" )
  32.  
  33. HookProcAdr := RegisterCallback( "HookProc", "F" )
  34. hWinEventHook := SetWinEventHook( 0x3, 0x3, 0, HookProcAdr, 0, 0, 0 )
  35.  
  36. OnExit, HandleExit
  37.  
  38. ; See http://www.autohotkey.com/forum/post-123323.html
  39. ShellMessage( wParam,lParam )
  40. {
  41.         global ControlHwnd
  42.         global DialogClass
  43.  
  44.         ; See http://msdn.microsoft.com/en-us/library/ms644989.aspx
  45.         If ( wParam = 1 || wParam = 4 ) ;  HSHELL_WINDOWCREATED := 1 OR HSHELL_WINDOWACTIVATED := 4
  46.         {
  47.                 WinGetClass, Class, ahk_id %lParam%
  48.                 ; Is this an Explorer window?
  49.                 If (Class = "CabinetWClass" OR Class = "ExploreWClass") ; Might need adjustment for Vista/Win7
  50.                 {
  51.                         ; Do we have a Open/Save control handle available?
  52.                         If (ControlHwnd)
  53.                         {
  54.                                 ; Get text from dialog now, user can edit it in the meantime
  55.                                 ControlGetText, ControlText, , ahk_id %ControlHwnd%
  56.                                 StringRight, LastCharacter, ControlText, 1
  57.                                
  58.                                 WinGetTitle, ExplorerTitle, ahk_id %lParam%
  59.                                 ; If full path in title is not set, try to catch path from edit
  60.                                 If ExplorerTitle Not Contains \
  61.                                         ControlGetText, ExplorerTitle, Edit1, A
  62.                                 If ExplorerTitle Contains \ ; if not, it's My Computer, Control Panel etc.
  63.                                 {
  64.                                         If (LastCharacter <> "\")
  65.                                         {
  66.                                                 ; Change the path to the Explorer path
  67.                                                 ControlSetText,, %ExplorerTitle%, ahk_id %ControlHwnd%
  68.                                                 ControlSend,, {Enter}, ahk_id %ControlHwnd%
  69.                                                 ; Put the original filename back in the dialog edit control
  70.                                                 ControlSetText,, %ControlText%, ahk_id %ControlHwnd%
  71.                                         }
  72.                                         ; For cases like 7-Zip "Extract" dialog which contain pathnames, not filenames
  73.                                         Else
  74.                                                 ControlSetText,, %ExplorerTitle%\, ahk_id %ControlHwnd%
  75.                                 }
  76.                         ; Back to where we started...
  77.                         WinActivate, ahk_class %DialogClass%
  78.                         ControlHwnd =
  79.                         DialogClass =
  80.                         }
  81.                 }
  82.         }
  83. }
  84.  
  85. ; See http://www.autohotkey.com/forum/topic35659.html
  86. HookProc( hWinEventHook, Event, hWnd, idObject, idChild, dwEventThread, dwmsEventTime )
  87. {
  88.         global ControlHwnd
  89.         global DialogClass
  90.  
  91.         If Event ; EVENT_SYSTEM_FOREGROUND = 0x3
  92.         {
  93.                 ; Windows and dialog boxes need time to "settle". See AHK manual
  94.                 Sleep, 120
  95.                 WinGetClass, DialogClass, ahk_id %hWnd%
  96.                 ; Is this a typical Open/Save dialog box?
  97.                 If DialogClass Contains bosa_sdm ; Might need adjustment for Office 2007 or 2010
  98.                         OfficeDialog := True
  99.                 If ( DialogClass = "#32770" || OfficeDialog )
  100.                 {
  101.                         ; Get control handle of edit for use in ShellMessage()
  102.                         EditClass = Edit1 ; Default
  103.                         If OfficeDialog
  104.                                 EditClass = RichEdit20W2 ; Might need adjustment for Office 2007 or 2010
  105.                         ControlGet, ControlHwnd, Hwnd,, %EditClass%, ahk_id %hWnd%
  106.                 }
  107.         }
  108. }
  109.  
  110. SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags)
  111. {
  112.         DllCall("CoInitialize", Uint, 0)
  113.         return DllCall("SetWinEventHook"
  114.         , Uint,eventMin
  115.         , Uint,eventMax
  116.         , Uint,hmodWinEventProc
  117.         , Uint,lpfnWinEventProc
  118.         , Uint,idProcess
  119.         , Uint,idThread
  120.         , Uint,dwFlags)
  121. }
  122.  
  123. UnhookWinEvent()
  124. {
  125.         Global
  126.         DllCall( "UnhookWinEvent", Uint,hWinEventHook )
  127.         DllCall( "GlobalFree", UInt,&HookProcAdr ) ; free up allocated memory for RegisterCallback
  128. }
  129.  
  130. HandleExit:
  131. UnhookWinEvent()
  132. ExitApp

Greetz Winkie

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
If anyone would like to take a stab at any of the "NEEDS HELP WITH" or offer suggestions it would be greatly appreciated!

Well, here is my input. (I've only been able to test it on a pc with WinXP and Office 2003.)

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?
Microsoft Office compatibility
-koomi

IMHO, Class #32770 is the only "real" one. MS Office has different ones. I added a check for them. But that won't probably work with Office 2007 and later.

Work with folder tree dialogs as well (like Direct Folders)
-koomi

Should be possible, but I don't how (yet?).

EDIT:
Code is in here: New Context Menu Item Puts Any Folder Into a Dialog Window. Also Vista is mentioned here.

Allow modification of the filename after the dialog first opens
-koomi

I implemented that by moving the text-grabbing after switching to Explorer.

Your code only works if Window Explorer has the full file path in it's title. I don't have set that option, so I made it grab the path from the edit field instead. I also added a check which should prevent using Control Panel and My Computer etc.

Here is my updated code, please test it:
Code: AutoIt [Select]
  1. ; LinkExplorerPathToFileDialog.ahk v0.02 WIP by koomi & Winkie
  2. ; *** WARNING: Alpha code! Use at your own risk! ***
  3. ; Makes a file dialog instantly jump to the folder of any Explorer Window you click
  4. ; Idea stolen from Direct Folders' "QuickSwitch" feature.
  5. ;
  6. ; How to use:
  7. ;   1) Open a file dialog (Open/Save, also works with 7-Zip Extract and so forth)
  8. ;   2) Switch to an open Windows Explorer window
  9. ;   3) The Open/Save dialog will change to same path as the Explorer window
  10. ;   *) Autohotkey_L is recommended if your system has non-Western foldernames
  11. ;
  12. ; NEEDS HELP WITH:
  13. ;   User testing
  14. ;   Windows Vista/7 compatibility
  15. ;   Better sanity checking to make sure we're really dealing with a file dialog
  16. ;       Maybe by matching the window title against a list of known good ones?
  17. ;   Work with folder tree dialogs as well (like Direct Folders)
  18. ;   .INI file to allow specifying custom class+control+title combinations
  19. ;   Microsoft Office 2007/2010 compatibility
  20. ;   Pretty icon and menu stuff like "Disable/Enable"
  21. ;   Flash taskbar/caption of dialog parent when path is changed or something
  22.  
  23. #SingleInstance Force
  24. #Persistent
  25. SetBatchLines,-1
  26.  
  27. Gui +LastFound
  28. shWnd := WinExist()
  29. DllCall( "RegisterShellHookWindow", UInt,shWnd )
  30. MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
  31. OnMessage( MsgNum, "ShellMessage" )
  32.  
  33. HookProcAdr := RegisterCallback( "HookProc", "F" )
  34. hWinEventHook := SetWinEventHook( 0x3, 0x3, 0, HookProcAdr, 0, 0, 0 )
  35.  
  36. OnExit, HandleExit
  37.  
  38. ; See http://www.autohotkey.com/forum/post-123323.html
  39. ShellMessage( wParam,lParam )
  40. {
  41.         global ControlHwnd
  42.         global DialogClass
  43.  
  44.         ; See http://msdn.microsoft.com/en-us/library/ms644989.aspx
  45.         If ( wParam = 1 || wParam = 4 ) ;  HSHELL_WINDOWCREATED := 1 OR HSHELL_WINDOWACTIVATED := 4
  46.         {
  47.                 WinGetClass, Class, ahk_id %lParam%
  48.                 ; Is this an Explorer window?
  49.                 If (Class = "CabinetWClass" OR Class = "ExploreWClass") ; Might need adjustment for Vista/Win7
  50.                 {
  51.                         ; Do we have a Open/Save control handle available?
  52.                         If (ControlHwnd)
  53.                         {
  54.                                 ; Get text from dialog now, user can edit it in the meantime
  55.                                 ControlGetText, ControlText, , ahk_id %ControlHwnd%
  56.                                 StringRight, LastCharacter, ControlText, 1
  57.                                
  58.                                 WinGetTitle, ExplorerTitle, ahk_id %lParam%
  59.                                 ; If full path in title is not set, try to catch path from edit
  60.                                 If ExplorerTitle Not Contains \
  61.                                         ControlGetText, ExplorerTitle, Edit1, A
  62.                                 If ExplorerTitle Contains \ ; if not, it's My Computer, Control Panel etc.
  63.                                 {
  64.                                         If (LastCharacter <> "\")
  65.                                         {
  66.                                                 ; Change the path to the Explorer path
  67.                                                 ControlSetText,, %ExplorerTitle%, ahk_id %ControlHwnd%
  68.                                                 ControlSend,, {Enter}, ahk_id %ControlHwnd%
  69.                                                 ; Put the original filename back in the dialog edit control
  70.                                                 ControlSetText,, %ControlText%, ahk_id %ControlHwnd%
  71.                                         }
  72.                                         ; For cases like 7-Zip "Extract" dialog which contain pathnames, not filenames
  73.                                         Else
  74.                                                 ControlSetText,, %ExplorerTitle%\, ahk_id %ControlHwnd%
  75.                                 }
  76.                         ; Back to where we started...
  77.                         WinActivate, ahk_class %DialogClass%
  78.                         ControlHwnd =
  79.                         DialogClass =
  80.                         }
  81.                 }
  82.         }
  83. }
  84.  
  85. ; See http://www.autohotkey.com/forum/topic35659.html
  86. HookProc( hWinEventHook, Event, hWnd, idObject, idChild, dwEventThread, dwmsEventTime )
  87. {
  88.         global ControlHwnd
  89.         global DialogClass
  90.  
  91.         If Event ; EVENT_SYSTEM_FOREGROUND = 0x3
  92.         {
  93.                 ; Windows and dialog boxes need time to "settle". See AHK manual
  94.                 Sleep, 120
  95.                 WinGetClass, DialogClass, ahk_id %hWnd%
  96.                 ; Is this a typical Open/Save dialog box?
  97.                 If DialogClass Contains bosa_sdm ; Might need adjustment for Office 2007 or 2010
  98.                         OfficeDialog := True
  99.                 If ( DialogClass = "#32770" || OfficeDialog )
  100.                 {
  101.                         ; Get control handle of edit for use in ShellMessage()
  102.                         EditClass = Edit1 ; Default
  103.                         If OfficeDialog
  104.                                 EditClass = RichEdit20W2 ; Might need adjustment for Office 2007 or 2010
  105.                         ControlGet, ControlHwnd, Hwnd,, %EditClass%, ahk_id %hWnd%
  106.                 }
  107.         }
  108. }
  109.  
  110. SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags)
  111. {
  112.         DllCall("CoInitialize", Uint, 0)
  113.         return DllCall("SetWinEventHook"
  114.         , Uint,eventMin
  115.         , Uint,eventMax
  116.         , Uint,hmodWinEventProc
  117.         , Uint,lpfnWinEventProc
  118.         , Uint,idProcess
  119.         , Uint,idThread
  120.         , Uint,dwFlags)
  121. }
  122.  
  123. UnhookWinEvent()
  124. {
  125.         Global
  126.         DllCall( "UnhookWinEvent", Uint,hWinEventHook )
  127.         DllCall( "GlobalFree", UInt,&HookProcAdr ) ; free up allocated memory for RegisterCallback
  128. }
  129.  
  130. HandleExit:
  131. UnhookWinEvent()
  132. ExitApp

Greetz Winkie

Winkie I received this error in the script

http://img692.imageshack.us/img692/761/screenshot18101203936.png
IDEA: Insta-switch file dialog to any Explorer window's path (code included)


Best Regards

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
oohhh my god
At final I got close the script.
Always getting the message of the window above.
Uuffff
 :-*

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Here's a small contribution. If the active window is an Explorer window, these functions will get the path without reading the edit control or requiring Show Full Path in Title Bar. However, I don't think they work with Shell namespaces like libraries. I got these from AHK forum. I use AHK_L 32 bit Unicode for compiling.

; use #IfWinActive ahk_group ExplorerGroup
; to make sure the active window is an
; Explorer window before calling this function
;
ActiveFolderPath()
{
   return PathCreateFromURL( ExplorerPath(WinExist("A")) )
}

; slightly modified version of function by jethrow
; on AHK forums.
;
ExplorerPath(_hwnd)
{
   for Item in ComObjCreate("Shell.Application").Windows
      if (Item.hwnd = _hwnd)
         return, Item.LocationURL
}

; function by SKAN on AHK forums
;
PathCreateFromURL( URL )
{
 VarSetCapacity( fPath, Sz := 2084, 0 )
 DllCall( "shlwapi\PathCreateFromUrl" ( A_IsUnicode ? "W" : "A" )
         , Str,URL, Str,fPath, UIntP,Sz, UInt,0 )
 return fPath
}

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
IMHO, Class #32770 is the only "real" one.

Trouble is MS uses that for just about every dialog. For example, if my MD5Hash program is open, it's window class is #32770 since it's a dialog based utility.

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
IMHO, Class #32770 is the only "real" one.

Trouble is MS uses that for just about every dialog. For example, if my MD5Hash program is open, it's window class is #32770 since it's a dialog based utility.


But MilesAhead i can't follow you. It's technical for me.
Can I use or not the above code ?

 :-*

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
IMHO, Class #32770 is the only "real" one.

Trouble is MS uses that for just about every dialog. For example, if my MD5Hash program is open, it's window class is #32770 since it's a dialog based utility.


But MilesAhead i can't follow you. It's technical for me.
Can I use or not the above code ?

 :-*

I haven't looked through the code. You can try it as well as I can.

What the #32770 means is that nearly any time you create a program that uses a dialog box as the main window, it has class name #32770.  That's just how Windows does it. That makes it difficult to distinguish one dialog from another. It could be a File Open dialog, or it could be just any program that's a dialog window.

It would probably be a better idea to make the user click on the dialog he wants to paste the folder path in. Even then it's likely to be funky. The Shell namespace crap makes it messy.


Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Ejem. In my new system with w7.64 ?
I'll have to mount a vm with 7 to make proofs.
For the moment goes well Direct Folders
 :-[