首页 > 解决方案 > 如何将大量数据复制到剪贴板

问题描述

我有一个数组 [1, 2, 56, 32, 54] 或其他东西。

我如何将其发送到剪贴板

1 2 56 32 54

我试过这个。

Loop % table.MaxIndex() {
    meow := table[A_Index]
    Clipboard := meow"`r"
}

标签: autohotkeyclipboardmassive

解决方案


table := [1,2,3,4,5,6,7,8,9]

vClipboard := ClipboardAll
Clipboard := ""

Loop, % table.Count()
    string := string ? string . ", " . table[A_Index] : table[A_Index]

Clipboard := string

;Do some stuff.

Clipboard := vClipboard ;Restore the Clipboard.

您的问题是尝试使用 table.MaxIndex() 进行循环,这可能会给您带来意想不到的数量,因为您可以拥有一个包含 2 个值但在索引方面相距甚远的数组,即

table := [1]
table[93] := "String"

而且每个循环都在覆盖你的喵值。您要使用的方法是连接,即

meow := "Hello"
meow := meow . "World" or meow .= "World"

推荐阅读