Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • September 01, 2015, 07:12:59 AM
  • Proudly celebrating 10 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: Capture the address window or file path to the clipboard with hotkey  (Read 4979 times)

Contro

  • Participant
  • Joined in 2007
  • *
  • gravatar avatar
  • Posts: 2,453
    • View Profile
    • Donate to Member
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

http://img577.imageshack.us/img577/6646/mozart26062012223822.png
Capture the address window or file path to the clipboard with hotkey

http://img27.imageshack.us/img27/4067/mozart26062012223835.png
Capture the address window or file path to the clipboard with hotkey


Best Regards

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,391
    • View Profile
    • Donate to Member
Re: Capture the address window or file path to the clipboard with hotkey
« 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:

Code: Autohotkey
  1. #q:: ; Win+Q, change to your liking.
  2. {
  3. }
  4. Return
  5.  

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

The easiest way is probably:

Code: Autohotkey
  1. #c:: ; Win+C, change to your liking.
  2. {
  3.     Clipboard = %Clipboard%
  4. }
  5. Return
  6.  


Contro

  • Participant
  • Joined in 2007
  • *
  • gravatar avatar
  • Posts: 2,453
    • View Profile
    • Donate to Member
Re: Capture the address window or file path to the clipboard with hotkey
« 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:

Code: Autohotkey
  1. #q:: ; Win+Q, change to your liking.
  2. {
  3. }
  4. Return
  5.  

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

The easiest way is probably:

Code: Autohotkey
  1. #c:: ; Win+C, change to your liking.
  2. {
  3.     Clipboard = %Clipboard%
  4. }
  5. Return
  6.  



Running
I can't believe would be so simpleeeeeeeeeeeeeee

 :-*

Contro

  • Participant
  • Joined in 2007
  • *
  • gravatar avatar
  • Posts: 2,453
    • View Profile
    • Donate to Member
Re: Capture the address window or file path to the clipboard with hotkey
« Reply #3 on: June 26, 2012, 08:44:30 PM »
i am trying this first. But no results

Code: [Select]
; 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 »

Contro

  • Participant
  • Joined in 2007
  • *
  • gravatar avatar
  • Posts: 2,453
    • View Profile
    • Donate to Member
Re: Capture the address window or file path to the clipboard with hotkey
« Reply #4 on: June 27, 2012, 09:21:35 PM »
Repeating

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

Go perfect

Contro

  • Participant
  • Joined in 2007
  • *
  • gravatar avatar
  • Posts: 2,453
    • View Profile
    • Donate to Member
Re: Capture the address window or file path to the clipboard with hotkey
« Reply #5 on: June 27, 2012, 09:33:44 PM »
Repeating

Code: [Select]
#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 :

http://img40.imageshack.us/img40/572/mozart2806201233147.png
Capture the address window or file path to the clipboard with hotkey


After applying the script don't appear the clip in my Ditto Clipboard.

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,391
    • View Profile
    • Donate to Member
Re: Capture the address window or file path to the clipboard with hotkey
« Reply #6 on: June 27, 2012, 09:54:02 PM »
Try this:

Code: Autohotkey
  1. #c:: ; Win+C, change to your liking.
  2. {
  3.     SendInput, ^c
  4.     ClipWait, 2
  5.     Clipboard = %Clipboard%
  6. }
  7. Return
  8.  

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,970
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Capture the address window or file path to the clipboard with hotkey
« 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 :)

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

Contro

  • Participant
  • Joined in 2007
  • *
  • gravatar avatar
  • Posts: 2,453
    • View Profile
    • Donate to Member
Re: Capture the address window or file path to the clipboard with hotkey
« 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 :)

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.

 ;D

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


Contro

  • Participant
  • Joined in 2007
  • *
  • gravatar avatar
  • Posts: 2,453
    • View Profile
    • Donate to Member
Re: Capture the address window or file path to the clipboard with hotkey
« Reply #9 on: June 28, 2012, 06:14:43 AM »
Try this:

Code: Autohotkey
  1. #c:: ; Win+C, change to your liking.
  2. {
  3.     SendInput, ^c
  4.     ClipWait, 2
  5.     Clipboard = %Clipboard%
  6. }
  7. Return
  8.  

Running to try
Best Regards
 :-*

Contro

  • Participant
  • Joined in 2007
  • *
  • gravatar avatar
  • Posts: 2,453
    • View Profile
    • Donate to Member
Re: Capture the address window or file path to the clipboard with hotkey
« 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.

 :P

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,970
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Capture the address window or file path to the clipboard with hotkey
« 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.

Code: AutoIt
  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.                 Else
  18.                         ClipPut($aSelection[2])
  19.                 EndIf
  20.         EndIf
  21.  
  22.  
  23.  
  24. ; ==========================================================================================================================
  25.  
  26. ; Func _ObjectSHFolderViewFromWin($hWnd)
  27. ;
  28. ; Returns an 'ShellFolderView' Object for the given Window handle
  29. ;
  30. ; Author: Ascend4nt, based on code by KaFu, klaus.s
  31. ; ==========================================================================================================================
  32.  
  33. Func _ObjectSHFolderViewFromWin($hWnd)
  34.     If Not IsHWnd($hWnd) Then Return SetError(1,0,0)
  35.     Local $oShell,$oShellWindows,$oIEObject,$oSHFolderView
  36.  
  37.     ; Shell Object
  38.     $oShell=ObjCreate("Shell.Application")
  39.     If Not IsObj($oShell) Then Return SetError(2,0,0)
  40.  
  41. ;   Get a 'ShellWindows Collection' object
  42.     $oShellWindows = $oShell.Windows()
  43.     If Not IsObj($oShellWindows) Then Return SetError(3,0,0)
  44.  
  45. ;   Iterate through the collection - each of type 'InternetExplorer' Object
  46.  
  47.     For $oIEObject In $oShellWindows
  48.         If $oIEObject.HWND = $hWnd Then
  49.             ; InternetExplorer->Document = ShellFolderView object
  50.             $oSHFolderView=$oIEObject.Document
  51.             If IsObj($oSHFolderView) Then Return $oSHFolderView
  52.             Return SetError(4,0,0)
  53.         EndIf
  54.     Next
  55.  
  56.     Return SetError(-1,0,0)
  57.  
  58. ; ==========================================================================================================================
  59. ; Func _ExplorerWinGetSelectedItems($hWnd)
  60. ;
  61. ;
  62. ; Author: klaus.s, KaFu, Ascend4nt (consolidation & cleanup, Path name simplification)
  63. ; ==========================================================================================================================
  64.  
  65. Func _ExplorerWinGetSelectedItems($hWnd)
  66.     If Not IsHWnd($hWnd) Then Return SetError(1,0,'')
  67.     Local $oSHFolderView
  68.     Local $iSelectedItems,$iCounter=2,$aSelectedItems[2] = [0, ""]
  69.  
  70.     $oSHFolderView=_ObjectSHFolderViewFromWin($hWnd)
  71.  
  72. ;   SelectedItems = FolderItems Collection object->Count
  73.     $iSelectedItems = $oSHFolderView.SelectedItems.Count
  74.  
  75.     Dim $aSelectedItems[$iSelectedItems+2]  ; 2 extra -> 1 for count [0], 1 for Folder Path [1]
  76.  
  77.     $aSelectedItems[0]=$iSelectedItems
  78. ;   ShellFolderView->Folder->Self as 'FolderItem'->Path
  79.     $aSelectedItems[1]=$oSHFolderView.Folder.Self.Path
  80.  
  81. ;   ShellFolderView->SelectedItems = FolderItems Collection object
  82.     $oSelectedFolderItems = $oSHFolderView.SelectedItems
  83.  
  84. #cs
  85.     ; For ALL items in an Explorer Window (not just the selected ones):
  86.     $oSelectedFolderItems = $oSHFolderView.Folder.Items
  87.     ReDim $aSelectedItems[$oSelectedFolderItems.Count+2]
  88. #ce
  89.  
  90.     For $oFolderItem In $oSelectedFolderItems
  91.         $aSelectedItems[$iCounter] = $oFolderItem.Path
  92.         $iCounter += 1
  93.     Next
  94.  
  95.     Return SetExtended($iCounter-2,$aSelectedItems)
  96. EndFunc   ;==>_ExplorerWinGetSelectedItems
  97.  
  98. Func _ComErrFunc($oError)
  99.     ConsoleWrite("COM Error occurred:"  & @CRLF & _
  100.         "Number: " & @TAB & $oError.number & @CRLF & _
  101.         "Windescription:" & @TAB & $oError.windescription & @CRLF & _
  102.         "Description is: " & @TAB & $oError.description & @CRLF & _
  103.         "Source is: " & @TAB & $oError.source & @CRLF & _
  104.         "Helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
  105.         "Helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
  106.         "Lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
  107.         "Scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
  108.         "Retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
  109. EndFunc   ;==>_ComErrFunc
  110.  
« 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... »

Contro

  • Participant
  • Joined in 2007
  • *
  • gravatar avatar
  • Posts: 2,453
    • View Profile
    • Donate to Member
Re: Capture the address window or file path to the clipboard with hotkey
« 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.

Code: AutoIt
  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.                 Else
  18.                         ClipPut($aSelection[2])
  19.                 EndIf
  20.         EndIf
  21.  
  22.  
  23.  
  24. ; ==========================================================================================================================
  25.  
  26. ; Func _ObjectSHFolderViewFromWin($hWnd)
  27. ;
  28. ; Returns an 'ShellFolderView' Object for the given Window handle
  29. ;
  30. ; Author: Ascend4nt, based on code by KaFu, klaus.s
  31. ; ==========================================================================================================================
  32.  
  33. Func _ObjectSHFolderViewFromWin($hWnd)
  34.     If Not IsHWnd($hWnd) Then Return SetError(1,0,0)
  35.     Local $oShell,$oShellWindows,$oIEObject,$oSHFolderView
  36.  
  37.     ; Shell Object
  38.     $oShell=ObjCreate("Shell.Application")
  39.     If Not IsObj($oShell) Then Return SetError(2,0,0)
  40.  
  41. ;   Get a 'ShellWindows Collection' object
  42.     $oShellWindows = $oShell.Windows()
  43.     If Not IsObj($oShellWindows) Then Return SetError(3,0,0)
  44.  
  45. ;   Iterate through the collection - each of type 'InternetExplorer' Object
  46.  
  47.     For $oIEObject In $oShellWindows
  48.         If $oIEObject.HWND = $hWnd Then
  49.             ; InternetExplorer->Document = ShellFolderView object
  50.             $oSHFolderView=$oIEObject.Document
  51.             If IsObj($oSHFolderView) Then Return $oSHFolderView
  52.             Return SetError(4,0,0)
  53.         EndIf
  54.     Next
  55.  
  56.     Return SetError(-1,0,0)
  57.  
  58. ; ==========================================================================================================================
  59. ; Func _ExplorerWinGetSelectedItems($hWnd)
  60. ;
  61. ;
  62. ; Author: klaus.s, KaFu, Ascend4nt (consolidation & cleanup, Path name simplification)
  63. ; ==========================================================================================================================
  64.  
  65. Func _ExplorerWinGetSelectedItems($hWnd)
  66.     If Not IsHWnd($hWnd) Then Return SetError(1,0,'')
  67.     Local $oSHFolderView
  68.     Local $iSelectedItems,$iCounter=2,$aSelectedItems[2] = [0, ""]
  69.  
  70.     $oSHFolderView=_ObjectSHFolderViewFromWin($hWnd)
  71.  
  72. ;   SelectedItems = FolderItems Collection object->Count
  73.     $iSelectedItems = $oSHFolderView.SelectedItems.Count
  74.  
  75.     Dim $aSelectedItems[$iSelectedItems+2]  ; 2 extra -> 1 for count [0], 1 for Folder Path [1]
  76.  
  77.     $aSelectedItems[0]=$iSelectedItems
  78. ;   ShellFolderView->Folder->Self as 'FolderItem'->Path
  79.     $aSelectedItems[1]=$oSHFolderView.Folder.Self.Path
  80.  
  81. ;   ShellFolderView->SelectedItems = FolderItems Collection object
  82.     $oSelectedFolderItems = $oSHFolderView.SelectedItems
  83.  
  84. #cs
  85.     ; For ALL items in an Explorer Window (not just the selected ones):
  86.     $oSelectedFolderItems = $oSHFolderView.Folder.Items
  87.     ReDim $aSelectedItems[$oSelectedFolderItems.Count+2]
  88. #ce
  89.  
  90.     For $oFolderItem In $oSelectedFolderItems
  91.         $aSelectedItems[$iCounter] = $oFolderItem.Path
  92.         $iCounter += 1
  93.     Next
  94.  
  95.     Return SetExtended($iCounter-2,$aSelectedItems)
  96. EndFunc   ;==>_ExplorerWinGetSelectedItems
  97.  
  98. Func _ComErrFunc($oError)
  99.     ConsoleWrite("COM Error occurred:"  & @CRLF & _
  100.         "Number: " & @TAB & $oError.number & @CRLF & _
  101.         "Windescription:" & @TAB & $oError.windescription & @CRLF & _
  102.         "Description is: " & @TAB & $oError.description & @CRLF & _
  103.         "Source is: " & @TAB & $oError.source & @CRLF & _
  104.         "Helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
  105.         "Helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
  106.         "Lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
  107.         "Scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
  108.         "Retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
  109. EndFunc   ;==>_ComErrFunc
  110.  

I'll try and comment.
 :-*

Contro

  • Participant
  • Joined in 2007
  • *
  • gravatar avatar
  • Posts: 2,453
    • View Profile
    • Donate to Member
Re: Capture the address window or file path to the clipboard with hotkey
« Reply #13 on: July 03, 2012, 12:09:29 PM »
 :P

Wonderful.
Wonderfullllllllllllllllllllllllllllllllllll

http://img101.imageshack.us/img101/7251/besotene2.gif
Capture the address window or file path to the clipboard with hotkey
http://img101.imageshack.us/img101/7251/besotene2.gif
Capture the address window or file path to the clipboard with hotkey
http://img101.imageshack.us/img101/7251/besotene2.gif
Capture the address window or file path to the clipboard with hotkey
http://img101.imageshack.us/img101/7251/besotene2.gif
Capture the address window or file path to the clipboard with hotkey

gabrielko

  • Participant
  • Joined in 2012
  • *
  • gravatar avatar
  • Posts: 1
    • View Profile
    • Donate to Member
Re: Capture the address window or file path to the clipboard with hotkey
« 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  :D