1. Capture the address of the selected active window to the clipboard with a definable hotkey
#q:: ; Win+Q, change to your liking.
{
WinGetTitle, Clipboard, A
}
Return2. capture the file path selected to the clipboard with a definable hotkey
#c:: ; Win+C, change to your liking.
{
Clipboard = %Clipboard%
}
Return1. Capture the address of the selected active window to the clipboard with a definable hotkey
Since you have the active path displayed in the window's titlebar, you can do your first request like this:Code: (autohotkey)#q:: ; Win+Q, change to your liking. { WinGetTitle, Clipboard, A } Return2. capture the file path selected to the clipboard with a definable hotkey
The easiest way is probably:Code: (autohotkey)#c:: ; Win+C, change to your liking. { Clipboard = %Clipboard% } Return

; 1. Capture the address of the selected active window to the clipboard with a definable hotkey
; Since you have the active path displayed in the window's titlebar, you can do your first request like this:
; Formatted for Autohotkey with the GeSHI Syntax Highlighter [copy or print]
; Skwire
; !#y:: ; no parece elegible ^#y en ctrl+Win+y, change to your liking. Pruebo con alt
^!u:: ;
{
WinGetTitle, Clipboard, A
}
Return#q:: ; Win+Q, change to your liking.
{
WinGetTitle, Clipboard, A
}
Return#c:: ; Win+C, change to your liking.
{
Clipboard = %Clipboard%
}
Return
#c:: ; Win+C, change to your liking.
{
SendInput, ^c
ClipWait, 2
Clipboard = %Clipboard%
}
Return

I'm not sure but I think what Contro is saying is:
a) If no file is selected, return the Window address field to the clipboard.
b) If a file is selected, return the full path of the file.
Feel free to ignore me if I'm wrong
Of course, with my non-knowledge of AutoHK you might have already answered the question, in which case feel free to

Try this:Code: (autohotkey)#c:: ; Win+C, change to your liking. { SendInput, ^c ClipWait, 2 Clipboard = %Clipboard% } Return


; 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
EndIf
EndFunc
; ==========================================================================================================================
; 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 ;==>_ComErrFuncI 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 EndIf EndFunc ; ========================================================================================================================== ; 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



Original address: https://www.donationcoder.com/forum/index.php?topic=31443.0