AutoHotKey: copy file from Windows Explorer, paste path to Notepad2
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
windows-explorer autohotkey copy-paste clipboard notepad2
add a comment |
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
windows-explorer autohotkey copy-paste clipboard notepad2
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?
– Ƭᴇcʜιᴇ007
May 9 '16 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 '16 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 '16 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 '16 at 13:52
add a comment |
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
windows-explorer autohotkey copy-paste clipboard notepad2
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
windows-explorer autohotkey copy-paste clipboard notepad2
windows-explorer autohotkey copy-paste clipboard notepad2
edited Dec 23 '18 at 22:26
Josem
159110
159110
asked May 9 '16 at 15:33
HikariHikari
106419
106419
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?
– Ƭᴇcʜιᴇ007
May 9 '16 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 '16 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 '16 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 '16 at 13:52
add a comment |
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?
– Ƭᴇcʜιᴇ007
May 9 '16 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 '16 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 '16 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 '16 at 13:52
2
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?
– Ƭᴇcʜιᴇ007
May 9 '16 at 15:37
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?
– Ƭᴇcʜιᴇ007
May 9 '16 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 '16 at 6:29
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 '16 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 '16 at 13:49
@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 '16 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 '16 at 13:52
@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 '16 at 13:52
add a comment |
1 Answer
1
active
oldest
votes
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
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 '16 at 23:41
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1074846%2fautohotkey-copy-file-from-windows-explorer-paste-path-to-notepad2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
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 '16 at 23:41
add a comment |
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
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 '16 at 23:41
add a comment |
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
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
answered May 10 '16 at 7:06
user3419297user3419297
1,846267
1,846267
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 '16 at 23:41
add a comment |
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 '16 at 23:41
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 '16 at 23:41
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 '16 at 23:41
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1074846%2fautohotkey-copy-file-from-windows-explorer-paste-path-to-notepad2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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?
– Ƭᴇcʜιᴇ007
May 9 '16 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 '16 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 '16 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 '16 at 13:52