Welcome Guest.   Make a donation to an author on the site November 26, 2014, 05:22:58 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Your Support Funds this Site: View the Supporter Yearbook.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: IDEA: Insta-switch file dialog to any Explorer window's path (code included)  (Read 5324 times)
koomi
Participant
*
Posts: 4


Hello there

View Profile Give some DonationCredits to this forum member
« on: April 01, 2010, 08:25:50 PM »

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

Formatted for AutoIt with the GeSHI Syntax Highlighter [copy or print]
  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
Logged
MilesAhead
Member
**
Posts: 5,053



View Profile WWW Give some DonationCredits to this forum member
« Reply #1 on: April 02, 2010, 01:06:24 PM »

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.
Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
AndyM
Charter Member
***
Posts: 616


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #2 on: April 02, 2010, 03:19:50 PM »

Doesn't Skrommel have something that watch's windows and places/sizes them accordingly?
Logged
MilesAhead
Member
**
Posts: 5,053



View Profile WWW Give some DonationCredits to this forum member
« Reply #3 on: April 02, 2010, 03:36:36 PM »

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?

Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
koomi
Participant
*
Posts: 4


Hello there

View Profile Give some DonationCredits to this forum member
« Reply #4 on: April 02, 2010, 07:32:48 PM »

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.
Logged
lanux128
Global Moderator
*****
Posts: 6,133



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #5 on: April 02, 2010, 11:08:31 PM »

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.
Logged

Winkie
Supporting Member
**
Posts: 82


View Profile Give some DonationCredits to this forum member
« Reply #6 on: April 09, 2010, 05:54:06 PM »

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.)

Quote from: koomi
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

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.

Quote from: koomi
Work with folder tree dialogs as well (like Direct Folders)

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.

Quote from: koomi
Allow modification of the filename after the dialog first opens

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:
Formatted for AutoIt with the GeSHI Syntax Highlighter [copy or print]
  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. ControlSetText,, %ExplorerTitle%\, ahk_id %ControlHwnd%
  74. }
  75. ; Back to where we started...
  76. WinActivate, ahk_class %DialogClass%
  77. ControlHwnd =
  78. DialogClass =
  79. }
  80. }
  81. }
  82. }
  83.  
  84. ; See http://www.autohotkey.com/forum/topic35659.html
  85. HookProc( hWinEventHook, Event, hWnd, idObject, idChild, dwEventThread, dwmsEventTime )
  86. {
  87. global ControlHwnd
  88. global DialogClass
  89.  
  90. If Event ; EVENT_SYSTEM_FOREGROUND = 0x3
  91. {
  92. ; Windows and dialog boxes need time to "settle". See AHK manual
  93. Sleep, 120
  94. WinGetClass, DialogClass, ahk_id %hWnd%
  95. ; Is this a typical Open/Save dialog box?
  96. If DialogClass Contains bosa_sdm ; Might need adjustment for Office 2007 or 2010
  97. OfficeDialog := True
  98. If ( DialogClass = "#32770" || OfficeDialog )
  99. {
  100. ; Get control handle of edit for use in ShellMessage()
  101. EditClass = Edit1 ; Default
  102. If OfficeDialog
  103. EditClass = RichEdit20W2 ; Might need adjustment for Office 2007 or 2010
  104. ControlGet, ControlHwnd, Hwnd,, %EditClass%, ahk_id %hWnd%
  105. }
  106. }
  107. }
  108.  
  109. SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags)
  110. {
  111. DllCall("CoInitialize", Uint, 0)
  112. return DllCall("SetWinEventHook"
  113. , Uint,eventMin
  114. , Uint,eventMax
  115. , Uint,hmodWinEventProc
  116. , Uint,lpfnWinEventProc
  117. , Uint,idProcess
  118. , Uint,idThread
  119. , Uint,dwFlags)
  120. }
  121.  
  122. UnhookWinEvent()
  123. {
  124. DllCall( "UnhookWinEvent", Uint,hWinEventHook )
  125. DllCall( "GlobalFree", UInt,&HookProcAdr ) ; free up allocated memory for RegisterCallback
  126. }
  127.  
  128. HandleExit:
  129. UnhookWinEvent()
  130. ExitApp

Greetz Winkie
Logged
Contro
Participant
*
Posts: 2,179

View Profile Give some DonationCredits to this forum member
« Reply #7 on: October 17, 2012, 06:40:45 PM »

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.)

Quote from: koomi
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

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.

Quote from: koomi
Work with folder tree dialogs as well (like Direct Folders)

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.

Quote from: koomi
Allow modification of the filename after the dialog first opens

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:
Formatted for AutoIt with the GeSHI Syntax Highlighter [copy or print]
  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. ControlSetText,, %ExplorerTitle%\, ahk_id %ControlHwnd%
  74. }
  75. ; Back to where we started...
  76. WinActivate, ahk_class %DialogClass%
  77. ControlHwnd =
  78. DialogClass =
  79. }
  80. }
  81. }
  82. }
  83.  
  84. ; See http://www.autohotkey.com/forum/topic35659.html
  85. HookProc( hWinEventHook, Event, hWnd, idObject, idChild, dwEventThread, dwmsEventTime )
  86. {
  87. global ControlHwnd
  88. global DialogClass
  89.  
  90. If Event ; EVENT_SYSTEM_FOREGROUND = 0x3
  91. {
  92. ; Windows and dialog boxes need time to "settle". See AHK manual
  93. Sleep, 120
  94. WinGetClass, DialogClass, ahk_id %hWnd%
  95. ; Is this a typical Open/Save dialog box?
  96. If DialogClass Contains bosa_sdm ; Might need adjustment for Office 2007 or 2010
  97. OfficeDialog := True
  98. If ( DialogClass = "#32770" || OfficeDialog )
  99. {
  100. ; Get control handle of edit for use in ShellMessage()
  101. EditClass = Edit1 ; Default
  102. If OfficeDialog
  103. EditClass = RichEdit20W2 ; Might need adjustment for Office 2007 or 2010
  104. ControlGet, ControlHwnd, Hwnd,, %EditClass%, ahk_id %hWnd%
  105. }
  106. }
  107. }
  108.  
  109. SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags)
  110. {
  111. DllCall("CoInitialize", Uint, 0)
  112. return DllCall("SetWinEventHook"
  113. , Uint,eventMin
  114. , Uint,eventMax
  115. , Uint,hmodWinEventProc
  116. , Uint,lpfnWinEventProc
  117. , Uint,idProcess
  118. , Uint,idThread
  119. , Uint,dwFlags)
  120. }
  121.  
  122. UnhookWinEvent()
  123. {
  124. DllCall( "UnhookWinEvent", Uint,hWinEventHook )
  125. DllCall( "GlobalFree", UInt,&HookProcAdr ) ; free up allocated memory for RegisterCallback
  126. }
  127.  
  128. HandleExit:
  129. UnhookWinEvent()
  130. ExitApp

Greetz Winkie

Winkie I received this error in the script



Best Regards
Logged
Contro
Participant
*
Posts: 2,179

View Profile Give some DonationCredits to this forum member
« Reply #8 on: October 17, 2012, 06:51:56 PM »

oohhh my god
At final I got close the script.
Always getting the message of the window above.
Uuffff
 Kiss
Logged
MilesAhead
Member
**
Posts: 5,053



View Profile WWW Give some DonationCredits to this forum member
« Reply #9 on: October 17, 2012, 07:45:51 PM »

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.

[copy or print]
; 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
}
Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
MilesAhead
Member
**
Posts: 5,053



View Profile WWW Give some DonationCredits to this forum member
« Reply #10 on: October 17, 2012, 07:49:41 PM »

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.
Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
Contro
Participant
*
Posts: 2,179

View Profile Give some DonationCredits to this forum member
« Reply #11 on: October 17, 2012, 07:52:03 PM »

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 ?

 Kiss
Logged
MilesAhead
Member
**
Posts: 5,053



View Profile WWW Give some DonationCredits to this forum member
« Reply #12 on: October 17, 2012, 07:57:44 PM »

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 ?

 Kiss

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.

Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
Contro
Participant
*
Posts: 2,179

View Profile Give some DonationCredits to this forum member
« Reply #13 on: October 18, 2012, 05:26:46 AM »

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
 embarassed
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.346s | Server load: 0.15 ]