1

I'm searching for a way to do that.

Using ArsClip's Clipboard Bar, I see that when I select a file o Windows Explorer and copy it, its full path is stored on clipboard.

If I keep selecting Windows Explorer and paste, that file is copied to current foler, ok.

If I go to Notepad2 (or any text editor) and paste, the usual behavior is nothing happen. I'd like the file path to be pasted as text.

I'm trying to implement this feature using AutoHotKey. I'd need to:

1) intercept paste command, not just Ctrl+V keystroke
2) verify if the pasting target is a text editor and not a file manager
3) when that's the case, I'd need to retrieve the file path from clipboard, which ArsClip is able to do
4) then edit clipbard to place that string into it, so that the paste command will write the string to the target.

I don't mind to lose the file reference. It means that I don't mind if, after running this routine, Windows Explorer won't copy the file anymore.

Any idea how to do it?

Based on the answer of user3419297 I made this code:

~F9::                                   ; run when F9 is pressed, ~ makes any other feature still trigger
    if GetKeyState("ScrollLock", "T")   ; only run if ScrollLock is active, easy way to quickly suspend the feature
        && WinActive("ahk_class  CabinetWClass") ; only run when WinExplorer is active window
    {   
        clipboard := ""                ; empty clipboard
        Send, ^c                       ; copy the selected file
        ClipWait, 1                    ; wait for the clipboard to contain data
        if (!ErrorLevel)               ; If NOT ErrorLevel clipwait found data on the clipboard
        clipboard := clipboard         ; convert to text (= copy the path)
    }
return
4
  • 2
    Hi, unfortunately we're not a script writing service. What have you got/tried so far, and where exactly are you getting stuck implementing your AHK script? May 9, 2016 at 15:37
  • If you copy a file in Explorer the paste options via mouse (right-click) and keyboard (menu and/or ctrl+v) aren't even available in Notepad2--as far as I can tell--which me thinks makes item 2 a moot point. I use a different shortcut key to execute shell code that grabs the full path and/or filename of whatever file was selected last in Explorer... not exactly what you reference, but doesn't rely on intercepting paste or messing with the clipboard... if you've clicked on a file and copied it without clicking on another file then you can use Shell.Application windows and paste the path
    – JJohnston2
    May 10, 2016 at 6:29
  • @Techie I don't mean to ask for a script writing service, if I meant for that I'd hire a developer to do so. What I mean with this question is ask of somebody already knows any of those steps, to point me out the direction, so that I can do it. Thanks
    – Hikari
    May 10, 2016 at 13:49
  • @JJohn I also do that, I have Moo RightClick, it cleans context menu and adds neat extra features like copying to clipboard files' names, paths, etc. But I wanna go further than that, instead of 2 or 3 clicks on the mouse, I wanna just copy the file and have its path directly available on clipboard.
    – Hikari
    May 10, 2016 at 13:52

1 Answer 1

1

Try this:

#If WinActive("ahk_class  CabinetWClass") && WinExist("ahk_class Notepad2U")

; select a file in explorer and press F1 to copy the path and paste it in Notepad2.

F1::
ClipSaved := ClipboardAll      ; Save the entire clipboard to the variable ClipSaved
clipboard := ""                ; empty clipboard
Send, ^c                       ; copy the selected file
ClipWait, 1                    ; wait for the clipboard to contain data
if (!ErrorLevel)               ; If NOT ErrorLevel clipwait found data on the clipboard
clipboard := clipboard         ; convert to text (= copy the path)
Sleep, 300 
 ; MsgBox, %clipboard%         ; display the path
WinActivate, ahk_class Notepad2U
WinWaitActive, ahk_class Notepad2U
Send, ^v                       ; paste the path
clipboard := ClipSaved         ; restore original clipboard
return

#If
1
  • Cool! tnx a lot! Since it doesn't work well with Ctrl+C, I had idea for a made a simpler vesion, gonna post it on question.
    – Hikari
    May 10, 2016 at 23:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .