I want to Copy some Specific (mp3) and (jpg) files to clipboard one by one to add them to another program
without a need to open File Explorer
but I can't find a function to do that
for Exampe:
Code: Select all
FileCopy, D:\0.jpg, Clipboard
This Topic Say the Same thing, but solution won't work for me
I wonder if some command been changed since 2007
https://autohotkey.com/board/topic/2316 ... clipboard/
Code: Select all
FileToClipboard(PathToCopy)
{
; Expand to full path:
Loop, %PathToCopy%, 1
PathToCopy := A_LoopFileLongPath
; Allocate some movable memory to put on the clipboard.
; This will hold a DROPFILES struct, the string, and an (extra) null terminator
; 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
; Copy the string into moveable memory.
DllCall("lstrcpy","uint",pPath+20,"str",PathToCopy)
; 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")
}