Reputation: 642
I have this script in Autohotkey and for some reason it does not work just for ClipboardAll in function:
global clips := Object()
copy(index){
Send ^c
clips[0] := ClipboardAll
}
paste(index){
Clipboard := clips[0]
Send ^v
}
^q:: copy(0)
!q:: paste(0)
but if I try the function copy with "Clipboard" then it does work.
Upvotes: 1
Views: 316
Reputation: 10852
Seems that AutoHotkey's arrays cannot store the contents of clipboardAll
. Someone should report this...
Instead, if you use pseudo arrays, it'll work. So you can either go for this
global clips0,clips1,clips2,clips3,clips4 ; ...
copy(index){
Send ^c
clips%index% := ClipboardAll
}
paste(index){
Clipboard := clips%index%
Send ^v
}
^q:: copy(0)
!q:: paste(0)
which is close to your solution but limited to the size of the array since you'll have to state every variable as global.
Other than that, the best way I can see would be handling everything in subroutines, not in functions. This way, all variables will be global:
copy:
Send ^c
clips%index% := ClipboardAll
return
paste:
Clipboard := clips%index%
Send ^v
return
^q::
index := 0
goSub, copy
return
!q::
index := 0
goSub, paste
return
Upvotes: 1