Can I copy an image file into clipboard
-
- Posts: 10
- Joined: Jul 21st, ’19, 11:22
i like copy file and paste with ctrl v its possible?
Is this what you want?
viewtopic.php?f=4&t=882
viewtopic.php?f=4&t=882
-
- Posts: 10
- Joined: Jul 21st, ’19, 11:22
FileToClipboard("E:\Lexus888\test.jpg")
sleep 1000
send, ^v
return
FileToClipboard(PathToCopy,Method="copy")
{
FileCount:=0
PathLength:=0
; Count files and total string length
Loop,Parse,PathToCopy,`n,`r
{
FileCount++
PathLength+=StrLen(A_LoopField)
}
pid:=DllCall("GetCurrentProcessId","uint")
hwnd:=WinExist("ahk_pid " . pid)
; 0x42 = GMEM_MOVEABLE(0x2) | GMEM_ZEROINIT(0x40)
hPath := DllCall("GlobalAlloc","uint",0x42,"uint",20 + (PathLength + FileCount + 1) * 2,"UPtr")
pPath := DllCall("GlobalLock","UPtr",hPath)
NumPut(20,pPath+0),pPath += 16 ; DROPFILES.pFiles = offset of file list
NumPut(1,pPath+0),pPath += 4 ; fWide = 0 -->ANSI,fWide = 1 -->Unicode
Offset:=0
Loop,Parse,PathToCopy,`n,`r ; Rows are delimited by linefeeds (`r`n).
offset += StrPut(A_LoopField,pPath+offset,StrLen(A_LoopField)+1,"UTF-16") * 2
DllCall("GlobalUnlock","UPtr",hPath)
DllCall("OpenClipboard","UPtr",hwnd)
DllCall("EmptyClipboard")
DllCall("SetClipboardData","uint",0xF,"UPtr",hPath) ; 0xF = CF_HDROP
; Write Preferred DropEffect structure to clipboard to switch between copy/cut operations
; 0x42 = GMEM_MOVEABLE(0x2) | GMEM_ZEROINIT(0x40)
mem := DllCall("GlobalAlloc","uint",0x42,"uint",4,"UPtr")
str := DllCall("GlobalLock","UPtr",mem)
if (Method="copy")
DllCall("RtlFillMemory","UPtr",str,"uint",1,"UChar",0x05)
else if (Method="cut")
DllCall("RtlFillMemory","UPtr",str,"uint",1,"UChar",0x02)
else
{
DllCall("CloseClipboard")
return
}
DllCall("GlobalUnlock","UPtr",mem)
cfFormat := DllCall("RegisterClipboardFormat","Str","Preferred DropEffect")
DllCall("SetClipboardData","uint",cfFormat,"UPtr",mem)
DllCall("CloseClipboard")
return
}
im using this script and work well, but how about if i like send 2 picture or 3 picture for 1 time
sleep 1000
send, ^v
return
FileToClipboard(PathToCopy,Method="copy")
{
FileCount:=0
PathLength:=0
; Count files and total string length
Loop,Parse,PathToCopy,`n,`r
{
FileCount++
PathLength+=StrLen(A_LoopField)
}
pid:=DllCall("GetCurrentProcessId","uint")
hwnd:=WinExist("ahk_pid " . pid)
; 0x42 = GMEM_MOVEABLE(0x2) | GMEM_ZEROINIT(0x40)
hPath := DllCall("GlobalAlloc","uint",0x42,"uint",20 + (PathLength + FileCount + 1) * 2,"UPtr")
pPath := DllCall("GlobalLock","UPtr",hPath)
NumPut(20,pPath+0),pPath += 16 ; DROPFILES.pFiles = offset of file list
NumPut(1,pPath+0),pPath += 4 ; fWide = 0 -->ANSI,fWide = 1 -->Unicode
Offset:=0
Loop,Parse,PathToCopy,`n,`r ; Rows are delimited by linefeeds (`r`n).
offset += StrPut(A_LoopField,pPath+offset,StrLen(A_LoopField)+1,"UTF-16") * 2
DllCall("GlobalUnlock","UPtr",hPath)
DllCall("OpenClipboard","UPtr",hwnd)
DllCall("EmptyClipboard")
DllCall("SetClipboardData","uint",0xF,"UPtr",hPath) ; 0xF = CF_HDROP
; Write Preferred DropEffect structure to clipboard to switch between copy/cut operations
; 0x42 = GMEM_MOVEABLE(0x2) | GMEM_ZEROINIT(0x40)
mem := DllCall("GlobalAlloc","uint",0x42,"uint",4,"UPtr")
str := DllCall("GlobalLock","UPtr",mem)
if (Method="copy")
DllCall("RtlFillMemory","UPtr",str,"uint",1,"UChar",0x05)
else if (Method="cut")
DllCall("RtlFillMemory","UPtr",str,"uint",1,"UChar",0x02)
else
{
DllCall("CloseClipboard")
return
}
DllCall("GlobalUnlock","UPtr",mem)
cfFormat := DllCall("RegisterClipboardFormat","Str","Preferred DropEffect")
DllCall("SetClipboardData","uint",cfFormat,"UPtr",mem)
DllCall("CloseClipboard")
return
}
im using this script and work well, but how about if i like send 2 picture or 3 picture for 1 time