我怎样才能让这个脚本从列表中选择一个随机单词并输出它而不重复 autohotkey 中的先前输出?
How can I have this script choose a random word from a list and output it without repeating the previous output in autohotkey?
我正在尝试制作一个脚本,输出一个词并进入聊天而不重复前一个词。我正在使用 autohotkey 来这样做。这是我的代码。
Word1 = This
Word2 = Is
Word3 = A
Word4 = Test
Word5 = Script
Word6 = And
Word7 = I
Word8 = Like
Word9 = Apple
Word10 = Pie
Min := 1
Max := 10
MButton::
RandWords := ""
Loop 1
{
Random N, %Min%, %Max%
RandWords .= Word%N%
}
Send %RandWords% {enter}
Return
所以基本上,每次我按下鼠标中键,它都会从上面列出的单词中随机输出一个单词。但我尽量避免这样做,
Script
Script
Script
我不介意程序输出,
Like
Apple
Like
Apple
只要每次输出与上一次不同即可。
如果您不想重复之前的单词索引,只需声明另一个变量来记住上次使用的单词索引:
Last := 0
然后循环直到你得到一个在使用它之前不同的随机索引:
loop,
{
Random N, %Min%, %Max%
if( Last != N )
{
Last := N
break
}
}
RandWords .= Word%N%
我正在尝试制作一个脚本,输出一个词并进入聊天而不重复前一个词。我正在使用 autohotkey 来这样做。这是我的代码。
Word1 = This
Word2 = Is
Word3 = A
Word4 = Test
Word5 = Script
Word6 = And
Word7 = I
Word8 = Like
Word9 = Apple
Word10 = Pie
Min := 1
Max := 10
MButton::
RandWords := ""
Loop 1
{
Random N, %Min%, %Max%
RandWords .= Word%N%
}
Send %RandWords% {enter}
Return
所以基本上,每次我按下鼠标中键,它都会从上面列出的单词中随机输出一个单词。但我尽量避免这样做,
Script
Script
Script
我不介意程序输出,
Like
Apple
Like
Apple
只要每次输出与上一次不同即可。
如果您不想重复之前的单词索引,只需声明另一个变量来记住上次使用的单词索引:
Last := 0
然后循环直到你得到一个在使用它之前不同的随机索引:
loop,
{
Random N, %Min%, %Max%
if( Last != N )
{
Last := N
break
}
}
RandWords .= Word%N%