Code:
^1::
Clip_1 := Clip_Catch()
tooltip, % "Clip1: " Strlen(Clip_1),50,50, 2
Return
!1::
Clip_Send(Clip_1)
Return
Clip_Catch() {
cliphold = %clipboardall%
Clipboard =
SendInput, ^c
ClipWait, 10, 1
if errorlevel
{
MsgBox clip error
}
MsgBox %clipboard%
/* This is the line that is causing the failure
Temphold = %clipboardall%
you can use either
Temphold = %clipboard% ; <- this may alter the contents due to auto-trim
or preferably
Temphold := clipboard ; <- this avoids any auto-trim action
*/
Temphold := clipboard ; <- tested and it works
tooltip, % "Temphold: " Strlen(Temphold),20,20, 1
Clipboard = %Cliphold%
cliphold =
Return Temphold
}
Clip_Send(var) {
if var
{
cliphold = %clipboardall%
Clipboard = %var%
ClipWait, 10, 1
if errorlevel
{
MsgBox clip error
}
SendInput, ^v
sleep, 200
Clipboard = %Cliphold%
cliphold =
}
Else
{
MsgBox no value
}
}
The problem (as colored in the above code) is that when you assign clipboardall to a variable, it in essence becomes a "special" binary variable containing all the clipboard inforamtion (including markers for the type of data) which cannot be passed in the return statement.
Quote:
Variables to which ClipboardAll has been assigned are in binary format and thus will appear as gibberish when displayed with MsgBox or similar. Also, altering a binary-clipboard variable (by means such as StringReplace) will revert it to a normal variable, resulting in the loss of its clipboard data.
This is what is happening when you Return Temphold. If you really need true clipboardall contents (but I see no reason, as you are then using SendInput...), you could declare Temphold as global variable that you could then access outside the function.
I placed a couple of tooltips in the above to see the size of the vars.
Quote:
StringLen may be used to discover the total size of a variable to which ClipboardAll has been assigned.