Hello,
I'd appreciate your help.
I have some template files stored in specific paths, for instance:
C:\TEMPLATES\File.pdf
C:\TEMPLATES\File.docx
C:\TEMPLATES\File.png
Does anyone know a script to copy the FULL file (e.g. "File.docx") from the path (C:\TEMPLATES\File.docx) to the clipboard?
By FULL file I mean the file itself, and not the path, or the internal content.
So if I run this script, and then paste (ctrl+v) in file explorer, "File.docx" should be pasted.
The intention of the script is to create shortcuts to my main template files, for easy access and usage.
Thank you very much!
How to copy the FULL file to clipboard from specific path?
Re: How to copy the FULL file to clipboard from specific path?
Lexikos has written some wonderful posts related to your issue.
https://autohotkey.com/board/topic/23162-how-to-copy-a-file-to-the-clipboard/page-1
I think this is what you're looking for sir.
https://autohotkey.com/board/topic/23162-how-to-copy-a-file-to-the-clipboard/page-1
I think this is what you're looking for sir.
I like to think extroverts have attention dependency disorder.
my projects: D2 Reconsidered - Diablo 2 Resurrected script | HideMyIcon, customizable desktop icon hider for Windows 10
my projects: D2 Reconsidered - Diablo 2 Resurrected script | HideMyIcon, customizable desktop icon hider for Windows 10
Re: How to copy the FULL file to clipboard from specific path?
Topic moved to 'Ask for Help'.
Re: How to copy the FULL file to clipboard from specific path?
Many thanks for the topic direction.aeiklmr wrote: ↑26 Apr 2019, 10:26Lexikos has written some wonderful posts related to your issue.
https://autohotkey.com/board/topic/23162-how-to-copy-a-file-to-the-clipboard/page-1
I think this is what you're looking for sir.
I'm trying to use the syntaxes available at the end of the topic without success:
https://autohotkey.com/board/topic/23162-how-to-copy-a-file-to-the-clipboard/page-4
Also, I'm wondering if I so complex syntax is needed to just copy a file from a specified path.
Does anyone have further information on how to copy a file from a specified path?
Re: How to copy the FULL file to clipboard from specific path?
Lexikos' FileToClipboard function at the link that aeiklmr gave works for me. I ran it in a folder with a 1GB movie file, right-clicked on my desktop, clicked Paste and the movie file was copied to my desktop. Is that not what you're after?
Code: Select all
FileToClipboard("test.mkv")
FileToClipboard(PathToCopy)
{
; Expand to full paths:
Loop, Parse, PathToCopy, `n, `r
Loop, %A_LoopField%, 1
temp_list .= A_LoopFileLongPath "`n"
PathToCopy := SubStr(temp_list, 1, -1)
; Allocate some movable memory to put on the clipboard.
; This will hold a DROPFILES struct and a null-terminated list of
; null-terminated strings.
; 0x42 = GMEM_MOVEABLE(0x2) | GMEM_ZEROINIT(0x40)
hPath := DllCall("GlobalAlloc","uint",0x42,"uint",StrLen(PathToCopy)+22)
; Lock the moveable memory, retrieving a pointer to it.
pPath := DllCall("GlobalLock","uint",hPath)
NumPut(20, pPath+0) ; DROPFILES.pFiles = offset of file list
pPath += 20
; Copy the list of files into moveable memory.
Loop, Parse, PathToCopy, `n, `r
{
DllCall("lstrcpy","uint",pPath+0,"str",A_LoopField)
pPath += StrLen(A_LoopField)+1
}
; Unlock the moveable memory.
DllCall("GlobalUnlock","uint",hPath)
DllCall("OpenClipboard","uint",0)
; Empty the clipboard, otherwise SetClipboardData may fail.
DllCall("EmptyClipboard")
; Place the data on the clipboard. CF_HDROP=0xF
DllCall("SetClipboardData","uint",0xF,"uint",hPath)
DllCall("CloseClipboard")
}
Re: How to copy the FULL file to clipboard from specific path?
Hello,
sorry for the "grave shoveling", but I tried it and it did not work.
Apparantly there is something inside of the Clipboard (after I run the script), but when I want to paste it, there is just this Windows error sound when you press keys but nothing happens...
My file is for example this:
C:\song.mp3
When I'm on any folder (e.g. on D:\Music\) I would like to paste it.
Maybe Lexikos' FileToClipboard function has to be written different for Windows 10?
The scriptDir and the files are not in the same location (in my case)
Thanks for any help and best regards
sorry for the "grave shoveling", but I tried it and it did not work.
Apparantly there is something inside of the Clipboard (after I run the script), but when I want to paste it, there is just this Windows error sound when you press keys but nothing happens...
My file is for example this:
C:\song.mp3
When I'm on any folder (e.g. on D:\Music\) I would like to paste it.
Maybe Lexikos' FileToClipboard function has to be written different for Windows 10?
The scriptDir and the files are not in the same location (in my case)
Thanks for any help and best regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Re: How to copy the FULL file to clipboard from specific path?
I've had good success with just me's ClipboardSetFiles() viewtopic.php?p=63914#p63914
Re: How to copy the FULL file to clipboard from specific path?
Thank you - this works!
I made it a little bit smaller, because I don't need the part with the sorting.
So it's just:
F1::
ClipBoardSetFiles("C:\Song.mp3")
return
The function is the same, but at the end I added a ClipWait, 0.3 and Send ^v
I did several tests and everything was fine.
Cheers!
I made it a little bit smaller, because I don't need the part with the sorting.
So it's just:
F1::
ClipBoardSetFiles("C:\Song.mp3")
return
The function is the same, but at the end I added a ClipWait, 0.3 and Send ^v
I did several tests and everything was fine.
Cheers!
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Re: How to copy the FULL file to clipboard from specific path?
Hi Scr1pter, could you post your code please?
I'm really struggling with various copy-paste codes and wouldn't even know where to start amending someone else's script. Thank you!
I'm really struggling with various copy-paste codes and wouldn't even know where to start amending someone else's script. Thank you!