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

Main Area and Open Discussion > General Software Discussion

Capture the address window or file path to the clipboard with hotkey

<< < (3/3)

Contro:
A Strange thing. One time goes well. next time fails.

4wd is the best initial idea :

Possibilities with the assigned hotkey .
1. In the active window assigned hotkey copy the active window path to the clipboard
2. In the active window and one subfolder select copy the the subfolder path to the clipboard
3. In the active window and file select inside that folder or explorer window copy the file path to the clipboard.

 :P

4wd:
I did not write any of this, (except _ExClip function and set a hotkey), it was written by Ascend4ant and Melba23 over on the AutoIt forum.

Thank them if you want to thank someone.

The hotkey is set for Shift+Alt+C, edit the code to change it to what you like.


* If nothing is selected, the Explorer path is clipped.
* If something is selected, its full path is clipped.
* If multiple somethings are selected, only the first one is returned.

--- Code: AutoIt ---; http://www.autoitscript.com/forum/topic/89833-windows-explorer-current-folder/page__st__40#entry973904#include <Array.au3> HotKeySet('+!c', '_ExClip') ; Shift+Alt+C Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ComErrFunc") While 1        Sleep(100)WEnd  Func _ExClip()        $hExplr = WinActive("[REGEXPCLASS:(Explore|Cabinet)WClass]")        If $hExplr <> '' Then                $aSelection = _ExplorerWinGetSelectedItems($hExplr)                If $aSelection[0] = 0 Then                        If StringLeft($aSelection[1], 2) <> '::' Then ClipPut($aSelection[1])                Else                        ClipPut($aSelection[2])                EndIf        EndIfEndFunc   ; ========================================================================================================================== ; Func _ObjectSHFolderViewFromWin($hWnd);; Returns an 'ShellFolderView' Object for the given Window handle;; Author: Ascend4nt, based on code by KaFu, klaus.s; ========================================================================================================================== Func _ObjectSHFolderViewFromWin($hWnd)    If Not IsHWnd($hWnd) Then Return SetError(1,0,0)    Local $oShell,$oShellWindows,$oIEObject,$oSHFolderView     ; Shell Object    $oShell=ObjCreate("Shell.Application")    If Not IsObj($oShell) Then Return SetError(2,0,0) ;   Get a 'ShellWindows Collection' object    $oShellWindows = $oShell.Windows()    If Not IsObj($oShellWindows) Then Return SetError(3,0,0) ;   Iterate through the collection - each of type 'InternetExplorer' Object     For $oIEObject In $oShellWindows        If $oIEObject.HWND = $hWnd Then            ; InternetExplorer->Document = ShellFolderView object            $oSHFolderView=$oIEObject.Document            If IsObj($oSHFolderView) Then Return $oSHFolderView            Return SetError(4,0,0)        EndIf    Next     Return SetError(-1,0,0)EndFunc ; ==========================================================================================================================; Func _ExplorerWinGetSelectedItems($hWnd);;; Author: klaus.s, KaFu, Ascend4nt (consolidation & cleanup, Path name simplification); ========================================================================================================================== Func _ExplorerWinGetSelectedItems($hWnd)    If Not IsHWnd($hWnd) Then Return SetError(1,0,'')    Local $oSHFolderView    Local $iSelectedItems,$iCounter=2,$aSelectedItems[2] = [0, ""]     $oSHFolderView=_ObjectSHFolderViewFromWin($hWnd)    If @error Then Return SetError(@error,0,'') ;   SelectedItems = FolderItems Collection object->Count    $iSelectedItems = $oSHFolderView.SelectedItems.Count     Dim $aSelectedItems[$iSelectedItems+2]  ; 2 extra -> 1 for count [0], 1 for Folder Path [1]     $aSelectedItems[0]=$iSelectedItems;   ShellFolderView->Folder->Self as 'FolderItem'->Path    $aSelectedItems[1]=$oSHFolderView.Folder.Self.Path ;   ShellFolderView->SelectedItems = FolderItems Collection object    $oSelectedFolderItems = $oSHFolderView.SelectedItems #cs    ; For ALL items in an Explorer Window (not just the selected ones):    $oSelectedFolderItems = $oSHFolderView.Folder.Items    ReDim $aSelectedItems[$oSelectedFolderItems.Count+2]#ce     For $oFolderItem In $oSelectedFolderItems        $aSelectedItems[$iCounter] = $oFolderItem.Path        $iCounter += 1    Next     Return SetExtended($iCounter-2,$aSelectedItems)EndFunc   ;==>_ExplorerWinGetSelectedItems Func _ComErrFunc($oError)    ConsoleWrite("COM Error occurred:"  & @CRLF & _        "Number: " & @TAB & $oError.number & @CRLF & _        "Windescription:" & @TAB & $oError.windescription & @CRLF & _        "Description is: " & @TAB & $oError.description & @CRLF & _        "Source is: " & @TAB & $oError.source & @CRLF & _        "Helpfile is: " & @TAB & $oError.helpfile & @CRLF & _        "Helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _        "Lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _        "Scriptline is: " & @TAB & $oError.scriptline & @CRLF & _        "Retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)EndFunc   ;==>_ComErrFunc

Contro:
I did not write any of this, (except _ExClip function and set a hotkey), it was written by Ascend4ant and Melba23 over on the AutoIt forum.

Thank them if you want to thank someone.

The hotkey is set for Shift+Alt+C, edit the code to change it to what you like.


* If nothing is selected, the Explorer path is clipped.
* If something is selected, its full path is clipped.
* If multiple somethings are selected, only the first one is returned.

--- Code: AutoIt ---; http://www.autoitscript.com/forum/topic/89833-windows-explorer-current-folder/page__st__40#entry973904#include <Array.au3> HotKeySet('+!c', '_ExClip') ; Shift+Alt+C Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ComErrFunc") While 1        Sleep(100)WEnd  Func _ExClip()        $hExplr = WinActive("[REGEXPCLASS:(Explore|Cabinet)WClass]")        If $hExplr <> '' Then                $aSelection = _ExplorerWinGetSelectedItems($hExplr)                If $aSelection[0] = 0 Then                        If StringLeft($aSelection[1], 2) <> '::' Then ClipPut($aSelection[1])                Else                        ClipPut($aSelection[2])                EndIf        EndIfEndFunc   ; ========================================================================================================================== ; Func _ObjectSHFolderViewFromWin($hWnd);; Returns an 'ShellFolderView' Object for the given Window handle;; Author: Ascend4nt, based on code by KaFu, klaus.s; ========================================================================================================================== Func _ObjectSHFolderViewFromWin($hWnd)    If Not IsHWnd($hWnd) Then Return SetError(1,0,0)    Local $oShell,$oShellWindows,$oIEObject,$oSHFolderView     ; Shell Object    $oShell=ObjCreate("Shell.Application")    If Not IsObj($oShell) Then Return SetError(2,0,0) ;   Get a 'ShellWindows Collection' object    $oShellWindows = $oShell.Windows()    If Not IsObj($oShellWindows) Then Return SetError(3,0,0) ;   Iterate through the collection - each of type 'InternetExplorer' Object     For $oIEObject In $oShellWindows        If $oIEObject.HWND = $hWnd Then            ; InternetExplorer->Document = ShellFolderView object            $oSHFolderView=$oIEObject.Document            If IsObj($oSHFolderView) Then Return $oSHFolderView            Return SetError(4,0,0)        EndIf    Next     Return SetError(-1,0,0)EndFunc ; ==========================================================================================================================; Func _ExplorerWinGetSelectedItems($hWnd);;; Author: klaus.s, KaFu, Ascend4nt (consolidation & cleanup, Path name simplification); ========================================================================================================================== Func _ExplorerWinGetSelectedItems($hWnd)    If Not IsHWnd($hWnd) Then Return SetError(1,0,'')    Local $oSHFolderView    Local $iSelectedItems,$iCounter=2,$aSelectedItems[2] = [0, ""]     $oSHFolderView=_ObjectSHFolderViewFromWin($hWnd)    If @error Then Return SetError(@error,0,'') ;   SelectedItems = FolderItems Collection object->Count    $iSelectedItems = $oSHFolderView.SelectedItems.Count     Dim $aSelectedItems[$iSelectedItems+2]  ; 2 extra -> 1 for count [0], 1 for Folder Path [1]     $aSelectedItems[0]=$iSelectedItems;   ShellFolderView->Folder->Self as 'FolderItem'->Path    $aSelectedItems[1]=$oSHFolderView.Folder.Self.Path ;   ShellFolderView->SelectedItems = FolderItems Collection object    $oSelectedFolderItems = $oSHFolderView.SelectedItems #cs    ; For ALL items in an Explorer Window (not just the selected ones):    $oSelectedFolderItems = $oSHFolderView.Folder.Items    ReDim $aSelectedItems[$oSelectedFolderItems.Count+2]#ce     For $oFolderItem In $oSelectedFolderItems        $aSelectedItems[$iCounter] = $oFolderItem.Path        $iCounter += 1    Next     Return SetExtended($iCounter-2,$aSelectedItems)EndFunc   ;==>_ExplorerWinGetSelectedItems Func _ComErrFunc($oError)    ConsoleWrite("COM Error occurred:"  & @CRLF & _        "Number: " & @TAB & $oError.number & @CRLF & _        "Windescription:" & @TAB & $oError.windescription & @CRLF & _        "Description is: " & @TAB & $oError.description & @CRLF & _        "Source is: " & @TAB & $oError.source & @CRLF & _        "Helpfile is: " & @TAB & $oError.helpfile & @CRLF & _        "Helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _        "Lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _        "Scriptline is: " & @TAB & $oError.scriptline & @CRLF & _        "Retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)EndFunc   ;==>_ComErrFunc-4wd (July 03, 2012, 09:21 AM)
--- End quote ---

I'll try and comment.
 :-*

Contro:
 :P

Wonderful.
Wonderfullllllllllllllllllllllllllllllllllll

Capture the address window or file path to the clipboard with hotkey Capture the address window or file path to the clipboard with hotkey Capture the address window or file path to the clipboard with hotkey Capture the address window or file path to the clipboard with hotkey

gabrielko:
This may or may not be significant, it's totally up to you to decide I really did get a quick fix with Long Path Tool. http://PathTooDeep.com  :D

Navigation

[0] Message Index

[*] Previous page

Go to full version