Hi
@just me, thanks for the reply.
For the error checking, would that be
Code: Select all
+q::
If !ClipBoardSetFiles("J:\Documents\Ableton\User Library\AutoHotKey presets\Pro-Q 3.vstpreset", "Copy")
MsgBox, 16, Error!, A_LastError: %A_LastError%
ClipBoardSetFiles("J:\Documents\Ableton\User Library\AutoHotKey presets\Pro-Q 3.vstpreset", "Copy")
Send, ^v
Return
If so, no message box came up. In the console, it looks like this.
Code: Select all
Script lines most recently executed (oldest first). Press [F5] to refresh. The seconds elapsed between a line and the one after it is in parentheses to the right (if not 0). The bottommost line's elapsed time is the number of seconds since it executed.
---- C:\Users\Joe\Desktop\Autohotkey scripts\Copy paste 4 27.01.23.ahk
009: TCS := A_IsUnicode ? 2 : 1
010: PreferredDropEffect := DllCall("RegisterClipboardFormat", "Str", "Preferred DropEffect")
011: DropEffects := {1: 1, 2: 2, Copy: 1, Move: 2}
003: SendMode,Input
006: {
055: Return (10.45)
056: if !ClipBoardSetFiles("J:\Documents\Ableton\User Library\AutoHotKey presets\Pro-Q 3.vstpreset", "Copy")
014: TotalLength := 0
015: FileArray := []
016: Loop,Parse,FilesToSet,
,
018: if (Length := StrLen(A_LoopField))
019: FileArray.Push({Path: A_LoopField, Len: Length + 1})
020: TotalLength += Length
021: }
022: FileCount := FileArray.Length()
023: if !(FileCount && TotalLength)
027: if DllCall("OpenClipboard", "Ptr", 0) && DllCall("EmptyClipboard")
030: hDrop := DllCall("GlobalAlloc", "UInt", 0x42, "UInt", 20 + (TotalLength + FileCount + 1) * TCS, "UPtr")
031: pDrop := DllCall("GlobalLock", "Ptr" , hDrop)
032: Offset := 20
033: NumPut(Offset, pDrop + 0, "UInt")
034: NumPut(!!A_IsUnicode, pDrop + 16, "UInt")
035: For Each,File in FileArray
036: Offset += StrPut(File.Path, pDrop + Offset, File.Len) * TCS
037: DllCall("GlobalUnlock", "Ptr", hDrop)
038: DllCall("SetClipboardData","UInt", 0x0F, "UPtr", hDrop)
040: if (DropEffect := DropEffects[DropEffect])
043: hMem := DllCall("GlobalAlloc", "UInt", 0x42, "UInt", 4, "UPtr")
044: pMem := DllCall("GlobalLock", "Ptr", hMem)
045: NumPut(DropEffect, pMem + 0, "UChar")
046: DllCall("GlobalUnlock", "Ptr", hMem)
047: DllCall("SetClipboardData", "UInt", PreferredDropEffect, "Ptr", hMem)
048: }
049: DllCall("CloseClipboard")
050: Return,True
058: ClipBoardSetFiles("J:\Documents\Ableton\User Library\AutoHotKey presets\Pro-Q 3.vstpreset", "Copy")
014: TotalLength := 0
015: FileArray := []
016: Loop,Parse,FilesToSet,
,
018: if (Length := StrLen(A_LoopField))
019: FileArray.Push({Path: A_LoopField, Len: Length + 1})
020: TotalLength += Length
021: }
022: FileCount := FileArray.Length()
023: if !(FileCount && TotalLength)
027: if DllCall("OpenClipboard", "Ptr", 0) && DllCall("EmptyClipboard")
030: hDrop := DllCall("GlobalAlloc", "UInt", 0x42, "UInt", 20 + (TotalLength + FileCount + 1) * TCS, "UPtr")
031: pDrop := DllCall("GlobalLock", "Ptr" , hDrop)
032: Offset := 20
033: NumPut(Offset, pDrop + 0, "UInt")
034: NumPut(!!A_IsUnicode, pDrop + 16, "UInt")
035: For Each,File in FileArray
036: Offset += StrPut(File.Path, pDrop + Offset, File.Len) * TCS
037: DllCall("GlobalUnlock", "Ptr", hDrop)
038: DllCall("SetClipboardData","UInt", 0x0F, "UPtr", hDrop)
040: if (DropEffect := DropEffects[DropEffect])
043: hMem := DllCall("GlobalAlloc", "UInt", 0x42, "UInt", 4, "UPtr")
044: pMem := DllCall("GlobalLock", "Ptr", hMem)
045: NumPut(DropEffect, pMem + 0, "UChar")
046: DllCall("GlobalUnlock", "Ptr", hMem)
047: DllCall("SetClipboardData", "UInt", PreferredDropEffect, "Ptr", hMem)
048: }
049: DllCall("CloseClipboard")
050: Return,True
059: Send,^v
060: Return (3.16)
Press [F5] to refresh.
The line change didn't have an effect either. I've spent some more time troubleshooting and the script works perfectly in Explorer, so I think Ableton must be handling the clipboard in an unusual way.
When using the script, I can see in Free Clipboard Viewer that the correct plugin has being copied, but nothing happens in Ableton unless I ctrl-C a plugin within the program. If that's happened then the script just pastes that same plugin (i.e. the Send ^v part is all that's registering), ignoring the new files that the script should be replacing them with.
Thanks again, really appreciate it. I'd love this to work!