尝试制作一个脚本,从 txt 文件中获取第一个单词,写入它,重复直到所有单词都写完

Trying to make a script that takes first word from a txt file, writes it, repeat till all words written

我有一个文本文件,它有几行。 1 行 = 1 个字

现在我想要一个脚本,如果我按下一个特定的按钮,它会写下第一个单词(第一行)。如果我再按一下按钮,就会写下一个字,就这样一直写到所有字都写完。我试着编写它,但它只会写第一个字,然后会继续写。它不会写下一个字,我不知道为什么,因为实际上我做了一个增加的变量...

这是我的代码:

F11::

Index = 1
Array := Object()
Loop, Read, C:\Users\Emilia\Desktop\list.txt
{
    Array.Push(A_LoopReadLine)
}
Send % Array[Index]
Index++
  1. 使用带有行号参数的FileReadLine
  2. 将索引变量保存在全局上下文中,这样它就不会每次都重置为 1
  3. 使用SendPlay一次发送单词,而不是character-by-character。
    您可以使用 SendMode play 命令切换默认发送模式。
  4. 发送Enter键,在发送命令中添加{Enter}

index = 1
F11::
    FileReadLine line, C:\Users\Emilia\Desktop\list.txt, index
    SendPlay %line%{Enter}
    index++
    Return