alpap пишет:вставляется только один последний объект
Так не должно быть, у меня вставляется всё выделенное.
alpap пишет:теперь не работает с текстом
Чтобы работало и с файлами, и с текстом, можно так:
XButton2::
if fileList := Explorer_GetSelection()
PutFilesIntoClipboard(fileList)
else
Send ^c
Return
XButton1:: Send ^v
Explorer_GetSelection() {
WinGetClass, winClass, % "ahk_id" . hWnd := WinExist("A")
if !(winClass ~= "^(Progman|WorkerW|(Cabinet|Explore)WClass)$")
Return
shellWindows := ComObjCreate("Shell.Application").Windows
if (winClass ~= "Progman|WorkerW") ; IShellWindows::Item: https://goo.gl/ihW9Gm
; IShellFolderViewDual: https://goo.gl/gnntq3
shellFolderView := shellWindows.Item( ComObject(VT_UI4 := 0x13, SWC_DESKTOP := 0x8) ).Document
else {
for window in shellWindows ; ShellFolderView object: https://is.gd/eyZ4zG
if (hWnd = window.HWND) && (shellFolderView := window.Document)
break
}
for item in shellFolderView.SelectedItems
result .= (result = "" ? "" : "`n") . item.Path
Return result
}
PutFilesIntoClipboard(fileList) {
static GHND := 0x42, CF_HDROP := 0xF
fileList := Trim( RegExReplace(fileList, "\R", "`n"), " `t`r`n" ), RegExReplace(fileList, "\R", "", count)
VarSetCapacity(DROPFILES, size := 20 + StrLen(fileList) + count + 2, 0)
NumPut(20, DROPFILES)
prevLen := 0
Loop, parse, fileList, `n
prevLen += StrPut(A_LoopField, &DROPFILES + 20 + prevLen + A_Index - 1, StrLen(A_LoopField), "CP0")
hMem := DllCall("GlobalAlloc", "UInt", GHND, "Ptr", size, "Ptr")
pData := DllCall("GlobalLock", "Ptr", hMem, "Ptr")
DllCall("RtlMoveMemory", "Ptr", pData, "Ptr", &DROPFILES, "Ptr", size)
DllCall("GlobalUnlock", "Ptr", hMem)
DllCall("OpenClipboard", "Ptr", 0)
DllCall("SetClipboardData", "UInt", CF_HDROP, "Ptr", hMem)
DllCall("CloseClipboard")
}
Разработка AHK-скриптов:
e-mail
dfiveg@mail.ruTelegram
jollycoder