是否有可能在自己的脚本中写入运行?

时间:2016-03-15 17:52:35

标签: autohotkey

我的脚本里面有一个单词列表。我想创建一个打开的gui,允许用户在列表中输入单词并删除它们。脚本可以在运行时编辑自己吗?如果是这样,我将如何做到这一点。这是我目前的剧本。

Word1 = This
Word2 = Is
Word3 = A
Word4 = Test
Word5 = Script
Word6 = And
Word7 = I
Word8 = Like
Word9 = Apple
Word10 = Pie

Min := 1
Max := 10

Gui, New
Gui, Add, Text,, Please enter a word you wish to add:
Gui, Add, Edit, Word
Gui, Show

MButton:: 
   RandWords := "" 
loop,
{
    Random N, %Min%, %Max%  
    if( Last != N )
    { 
         Last := N
         break
    }
}
RandWords .= Word%N%
   Send %RandWords%{!} {enter} 
Return

1 个答案:

答案 0 :(得分:1)

以下是如何使用数组存储用户输入的示例:

store :=
counter := 0
loop, 3
{
    InputBox , here , User input , Please enter some text!
    store%counter% := here
    counter++
}

store1 = This element was deleted!

counter := 0
loop, 3
{
    str := store%counter%
    MsgBox, %str%
    counter++
}

如您所见,store用作伪数组,并使用counter或整数值进行索引。

有一行删除(实际上只是更改,但你明白了)第二个元素。它可以这样写:

counter := 1
store%counter% = This element was deleted!