Welcome Guest.   Make a donation to an author on the site September 01, 2014, 06:22:30 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.
 
Read the full one-year retrospective report on DonationCoder.com.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Capture the address window or file path to the clipboard with hotkey  (Read 4139 times)
Contro
Participant
*
Posts: 2,105

View Profile Give some DonationCredits to this forum member
« on: June 26, 2012, 04:40:16 PM »

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

I would like a software for

1. Capture the address of the selected active window to the clipboard with a definable hotkey
2. capture the file path selected to the clipboard with a definable hotkey




Best Regards
Logged
skwire
Charter Member
***
Posts: 4,036



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #1 on: June 26, 2012, 05:39:14 PM »

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]
  1. #q:: ; Win+Q, change to your liking.
  2. {
  3. }

2. capture the file path selected to the clipboard with a definable hotkey

The easiest way is probably:

Formatted for Autohotkey with the GeSHI Syntax Highlighter [copy or print]
  1. #c:: ; Win+C, change to your liking.
  2. {
  3.    Clipboard = %Clipboard%
  4. }

Logged

Contro
Participant
*
Posts: 2,105

View Profile Give some DonationCredits to this forum member
« Reply #2 on: June 26, 2012, 08:25:53 PM »

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]
  1. #q:: ; Win+Q, change to your liking.
  2. {
  3. }

2. capture the file path selected to the clipboard with a definable hotkey

The easiest way is probably:

Formatted for Autohotkey with the GeSHI Syntax Highlighter [copy or print]
  1. #c:: ; Win+C, change to your liking.
  2. {
  3.    Clipboard = %Clipboard%
  4. }



Running
I can't believe would be so simpleeeeeeeeeeeeeee

 Kiss
Logged
Contro
Participant
*
Posts: 2,105

View Profile Give some DonationCredits to this forum member
« Reply #3 on: June 26, 2012, 08:44:30 PM »

i am trying this first. But no results

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

In the screenshots I selected the folder path, but the target is copy to the clipboard without it.
Only needed to select the windows folder.

I am doing something bad. Don't copy
I tried also win+1
but the clipboard have wrong.
It seems don't act the command
« Last Edit: June 26, 2012, 08:52:21 PM by Contro » Logged
Contro
Participant
*
Posts: 2,105

View Profile Give some DonationCredits to this forum member
« Reply #4 on: June 27, 2012, 09:21:35 PM »

Repeating

[copy or print]
#q:: ; Win+Q, change to your liking.
    {
       WinGetTitle, Clipboard, A
    }
    Return

Go perfect
Logged
Contro
Participant
*
Posts: 2,105

View Profile Give some DonationCredits to this forum member
« Reply #5 on: June 27, 2012, 09:33:44 PM »

Repeating

[copy or print]
#c:: ; Win+C, change to your liking.
    {
       Clipboard = %Clipboard%
    }
    Return

don't go

I don't understand

clipboard = %clipboard%   ; Convert any copied files, HTML, or other formatted text to plain text.

I position the cursor over one file.

By example :



After applying the script don't appear the clip in my Ditto Clipboard.
Logged
skwire
Charter Member
***
Posts: 4,036



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #6 on: June 27, 2012, 09:54:02 PM »

Try this:

Formatted for Autohotkey with the GeSHI Syntax Highlighter [copy or print]
  1. #c:: ; Win+C, change to your liking.
  2. {
  3.    SendInput, ^c
  4.    ClipWait, 2
  5.    Clipboard = %Clipboard%
  6. }
Logged

4wd
Supporting Member
**
Posts: 3,293



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #7 on: June 27, 2012, 10:39:09 PM »

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 smiley

Of course, with my non-knowledge of AutoHK you might have already answered the question, in which case feel free to  trout
Logged

Four wheel drive: Helping you get stuck faster, harder, further from help...........and it's no different on this forum Evil
Contro
Participant
*
Posts: 2,105

View Profile Give some DonationCredits to this forum member
« Reply #8 on: June 28, 2012, 06:14:15 AM »

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 smiley

Of course, with my non-knowledge of AutoHK you might have already answered the question, in which case feel free to  trout

May be that what you are telling is what I must say.

 Grin

It's a good solution, because with one hotkey we can do all the tasks

Logged
Contro
Participant
*
Posts: 2,105

View Profile Give some DonationCredits to this forum member
« Reply #9 on: June 28, 2012, 06:14:43 AM »

Try this:

Formatted for Autohotkey with the GeSHI Syntax Highlighter [copy or print]
  1. #c:: ; Win+C, change to your liking.
  2. {
  3.    SendInput, ^c
  4.    ClipWait, 2
  5.    Clipboard = %Clipboard%
  6. }

Running to try
Best Regards
 Kiss
Logged
Contro
Participant
*
Posts: 2,105

View Profile Give some DonationCredits to this forum member
« Reply #10 on: June 28, 2012, 06:21:10 AM »

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.

 tongue
Logged
4wd
Supporting Member
**
Posts: 3,293



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #11 on: July 03, 2012, 09:21:28 AM »

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.

Formatted for AutoIt with the GeSHI Syntax Highlighter [copy or print]
  1. ; http://www.autoitscript.com/forum/topic/89833-windows-explorer-current-folder/page__st__40#entry973904
  2. #include <Array.au3>
  3.  
  4. HotKeySet('+!c', '_ExClip') ; Shift+Alt+C
  5.  
  6. Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ComErrFunc")
  7.  
  8. Sleep(100)
  9.  
  10.  
  11. Func _ExClip()
  12. $hExplr = WinActive("[REGEXPCLASS:(Explore|Cabinet)WClass]")
  13. If $hExplr <> '' Then
  14. $aSelection = _ExplorerWinGetSelectedItems($hExplr)
  15. If $aSelection[0] = 0 Then
  16. If StringLeft($aSelection[1], 2) <> '::' Then ClipPut($aSelection[1])
  17. ClipPut($aSelection[2])
  18.  
  19.  
  20.  
  21. ; ==========================================================================================================================
  22.  
  23. ; Func _ObjectSHFolderViewFromWin($hWnd)
  24. ;
  25. ; Returns an 'ShellFolderView' Object for the given Window handle
  26. ;
  27. ; Author: Ascend4nt, based on code by KaFu, klaus.s
  28. ; ==========================================================================================================================
  29.  
  30. Func _ObjectSHFolderViewFromWin($hWnd)
  31.    If Not IsHWnd($hWnd) Then Return SetError(1,0,0)
  32.    Local $oShell,$oShellWindows,$oIEObject,$oSHFolderView
  33.  
  34.    ; Shell Object
  35.    $oShell=ObjCreate("Shell.Application")
  36.    If Not IsObj($oShell) Then Return SetError(2,0,0)
  37.  
  38. ;   Get a 'ShellWindows Collection' object
  39.    $oShellWindows = $oShell.Windows()
  40.    If Not IsObj($oShellWindows) Then Return SetError(3,0,0)
  41.  
  42. ;   Iterate through the collection - each of type 'InternetExplorer' Object
  43.  
  44.    For $oIEObject In $oShellWindows
  45.        If $oIEObject.HWND = $hWnd Then
  46.            ; InternetExplorer->Document = ShellFolderView object
  47.            $oSHFolderView=$oIEObject.Document
  48.            If IsObj($oSHFolderView) Then Return $oSHFolderView
  49.            Return SetError(4,0,0)
  50.        EndIf
  51.    Next
  52.  
  53.    Return SetError(-1,0,0)
  54.  
  55. ; ==========================================================================================================================
  56. ; Func _ExplorerWinGetSelectedItems($hWnd)
  57. ;
  58. ;
  59. ; Author: klaus.s, KaFu, Ascend4nt (consolidation & cleanup, Path name simplification)
  60. ; ==========================================================================================================================
  61.  
  62. Func _ExplorerWinGetSelectedItems($hWnd)
  63.    If Not IsHWnd($hWnd) Then Return SetError(1,0,'')
  64.    Local $oSHFolderView
  65.    Local $iSelectedItems,$iCounter=2,$aSelectedItems[2] = [0, ""]
  66.  
  67.    $oSHFolderView=_ObjectSHFolderViewFromWin($hWnd)
  68.  
  69. ;   SelectedItems = FolderItems Collection object->Count
  70.    $iSelectedItems = $oSHFolderView.SelectedItems.Count
  71.  
  72.    Dim $aSelectedItems[$iSelectedItems+2]  ; 2 extra -> 1 for count [0], 1 for Folder Path [1]
  73.  
  74.    $aSelectedItems[0]=$iSelectedItems
  75. ;   ShellFolderView->Folder->Self as 'FolderItem'->Path
  76.    $aSelectedItems[1]=$oSHFolderView.Folder.Self.Path
  77.  
  78. ;   ShellFolderView->SelectedItems = FolderItems Collection object
  79.    $oSelectedFolderItems = $oSHFolderView.SelectedItems
  80.  
  81. #cs
  82.     ; For ALL items in an Explorer Window (not just the selected ones):
  83.     $oSelectedFolderItems = $oSHFolderView.Folder.Items
  84.     ReDim $aSelectedItems[$oSelectedFolderItems.Count+2]
  85. #ce
  86.  
  87.    For $oFolderItem In $oSelectedFolderItems
  88.        $aSelectedItems[$iCounter] = $oFolderItem.Path
  89.        $iCounter += 1
  90.    Next
  91.  
  92.    Return SetExtended($iCounter-2,$aSelectedItems)
  93. EndFunc   ;==>_ExplorerWinGetSelectedItems
  94.  
  95. Func _ComErrFunc($oError)
  96.    ConsoleWrite("COM Error occurred:"  & @CRLF & _
  97.        "Number: " & @TAB & $oError.number & @CRLF & _
  98.        "Windescription:" & @TAB & $oError.windescription & @CRLF & _
  99.        "Description is: " & @TAB & $oError.description & @CRLF & _
  100.        "Source is: " & @TAB & $oError.source & @CRLF & _
  101.        "Helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
  102.        "Helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
  103.        "Lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
  104.        "Scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
  105.        "Retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
  106. EndFunc   ;==>_ComErrFunc
« Last Edit: July 03, 2012, 09:30:53 AM by 4wd; Reason: For some reason I appear to be getting grumpier...it\'s not true...honest...maybe it\'s just the way I phrase things...or maybe I haven\'t had enough coffee... » Logged

Four wheel drive: Helping you get stuck faster, harder, further from help...........and it's no different on this forum Evil
Contro
Participant
*
Posts: 2,105

View Profile Give some DonationCredits to this forum member
« Reply #12 on: July 03, 2012, 11:01:44 AM »

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.

Formatted for AutoIt with the GeSHI Syntax Highlighter [copy or print]
  1. ; http://www.autoitscript.com/forum/topic/89833-windows-explorer-current-folder/page__st__40#entry973904
  2. #include <Array.au3>
  3.  
  4. HotKeySet('+!c', '_ExClip') ; Shift+Alt+C
  5.  
  6. Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ComErrFunc")
  7.  
  8. Sleep(100)
  9.  
  10.  
  11. Func _ExClip()
  12. $hExplr = WinActive("[REGEXPCLASS:(Explore|Cabinet)WClass]")
  13. If $hExplr <> '' Then
  14. $aSelection = _ExplorerWinGetSelectedItems($hExplr)
  15. If $aSelection[0] = 0 Then
  16. If StringLeft($aSelection[1], 2) <> '::' Then ClipPut($aSelection[1])
  17. ClipPut($aSelection[2])
  18.  
  19.  
  20.  
  21. ; ==========================================================================================================================
  22.  
  23. ; Func _ObjectSHFolderViewFromWin($hWnd)
  24. ;
  25. ; Returns an 'ShellFolderView' Object for the given Window handle
  26. ;
  27. ; Author: Ascend4nt, based on code by KaFu, klaus.s
  28. ; ==========================================================================================================================
  29.  
  30. Func _ObjectSHFolderViewFromWin($hWnd)
  31.    If Not IsHWnd($hWnd) Then Return SetError(1,0,0)
  32.    Local $oShell,$oShellWindows,$oIEObject,$oSHFolderView
  33.  
  34.    ; Shell Object
  35.    $oShell=ObjCreate("Shell.Application")
  36.    If Not IsObj($oShell) Then Return SetError(2,0,0)
  37.  
  38. ;   Get a 'ShellWindows Collection' object
  39.    $oShellWindows = $oShell.Windows()
  40.    If Not IsObj($oShellWindows) Then Return SetError(3,0,0)
  41.  
  42. ;   Iterate through the collection - each of type 'InternetExplorer' Object
  43.  
  44.    For $oIEObject In $oShellWindows
  45.        If $oIEObject.HWND = $hWnd Then
  46.            ; InternetExplorer->Document = ShellFolderView object
  47.            $oSHFolderView=$oIEObject.Document
  48.            If IsObj($oSHFolderView) Then Return $oSHFolderView
  49.            Return SetError(4,0,0)
  50.        EndIf
  51.    Next
  52.  
  53.    Return SetError(-1,0,0)
  54.  
  55. ; ==========================================================================================================================
  56. ; Func _ExplorerWinGetSelectedItems($hWnd)
  57. ;
  58. ;
  59. ; Author: klaus.s, KaFu, Ascend4nt (consolidation & cleanup, Path name simplification)
  60. ; ==========================================================================================================================
  61.  
  62. Func _ExplorerWinGetSelectedItems($hWnd)
  63.    If Not IsHWnd($hWnd) Then Return SetError(1,0,'')
  64.    Local $oSHFolderView
  65.    Local $iSelectedItems,$iCounter=2,$aSelectedItems[2] = [0, ""]
  66.  
  67.    $oSHFolderView=_ObjectSHFolderViewFromWin($hWnd)
  68.  
  69. ;   SelectedItems = FolderItems Collection object->Count
  70.    $iSelectedItems = $oSHFolderView.SelectedItems.Count
  71.  
  72.    Dim $aSelectedItems[$iSelectedItems+2]  ; 2 extra -> 1 for count [0], 1 for Folder Path [1]
  73.  
  74.    $aSelectedItems[0]=$iSelectedItems
  75. ;   ShellFolderView->Folder->Self as 'FolderItem'->Path
  76.    $aSelectedItems[1]=$oSHFolderView.Folder.Self.Path
  77.  
  78. ;   ShellFolderView->SelectedItems = FolderItems Collection object
  79.    $oSelectedFolderItems = $oSHFolderView.SelectedItems
  80.  
  81. #cs
  82.     ; For ALL items in an Explorer Window (not just the selected ones):
  83.     $oSelectedFolderItems = $oSHFolderView.Folder.Items
  84.     ReDim $aSelectedItems[$oSelectedFolderItems.Count+2]
  85. #ce
  86.  
  87.    For $oFolderItem In $oSelectedFolderItems
  88.        $aSelectedItems[$iCounter] = $oFolderItem.Path
  89.        $iCounter += 1
  90.    Next
  91.  
  92.    Return SetExtended($iCounter-2,$aSelectedItems)
  93. EndFunc   ;==>_ExplorerWinGetSelectedItems
  94.  
  95. Func _ComErrFunc($oError)
  96.    ConsoleWrite("COM Error occurred:"  & @CRLF & _
  97.        "Number: " & @TAB & $oError.number & @CRLF & _
  98.        "Windescription:" & @TAB & $oError.windescription & @CRLF & _
  99.        "Description is: " & @TAB & $oError.description & @CRLF & _
  100.        "Source is: " & @TAB & $oError.source & @CRLF & _
  101.        "Helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
  102.        "Helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
  103.        "Lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
  104.        "Scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
  105.        "Retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
  106. EndFunc   ;==>_ComErrFunc

I'll try and comment.
 Kiss
Logged
Contro
Participant
*
Posts: 2,105

View Profile Give some DonationCredits to this forum member
« Reply #13 on: July 03, 2012, 12:09:29 PM »

 tongue

Wonderful.
Wonderfullllllllllllllllllllllllllllllllllll

Logged
gabrielko
Participant
*
Posts: 1

View Profile Give some DonationCredits to this forum member
« Reply #14 on: October 02, 2012, 11:41:06 AM »

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  cheesy
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.329s | Server load: 0.08 ]