To use this code, just run it. Select some simple text, even just a word from this source code. Then press Win-C. It will create three files, two of which should contain the saved clipboard. All three files at this point have the correct contents. Now press Win-G. The newly created fourth file will also be correct. Now press Win-B to update one of the original files. This is where referencing a nested variable that points to a ClipboardAll object fails. Here is the code:
UPDATE: I added using an Array too, which has the same issue.
Code: Select all
#SingleInstance force
global globalCopy
global hack := {}
hack.vars := {}
hack.vars.blah := "This is not my final value...`r`n"
global clips := []
#c::
Send, ^c
ClipWait
copied := ClipboardAll
localCopy := copied
globalCopy := localCopy
FileDelete, % A_Temp . "\clip_*.txt"
FileAppend, % copied, % A_Temp . "\clip_copied.txt" ; this works
FileAppend, % localCopy, % A_Temp . "\clip_localCopy.txt" ; this works
FileAppend, % hack.vars.blah, % A_Temp . "\clip_blah.txt" ; this works
hack.vars.blah := copied ; copy the value to an Object for use later
clips.Push(copied) ; copy the value to an Array for use later
return
#g::
FileAppend, % globalCopy, % A_Temp . "\clip_globalCopy.txt" ; this works
return
#b::
FileAppend, % hack.vars.blah, % A_Temp . "\clip_blah.txt" ; this fails... it only writes one byte (0x3F)
return
#s::
tmpClip := clips.pop()
FileAppend, % tmpClip, % A_Temp . "\clip_stack.txt" ; this fails... it only writes one byte (0x3F)
return