Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops 在循环中从文件返回两次_Loops_Autohotkey - Fatal编程技术网

Loops 在循环中从文件返回两次

Loops 在循环中从文件返回两次,loops,autohotkey,Loops,Autohotkey,在完成循环之前,我尝试从文件返回两次值(第一个值,然后是第二个值)。在重复循环之前,它当前会两次返回文件中的第一个值 我可以将信息保存在单独的文件中,但在重复循环之前,我不知道如何从每个文件中提取第一个值。想法 这是我的剧本: Loop, read, C:\Users\Michael\Google Drive\AutoHotKey\Reference Files\item.txt { Loop, parse, A_LoopReadLine, %A_Tab% { sleep 150

在完成循环之前,我尝试从文件返回两次值(第一个值,然后是第二个值)。在重复循环之前,它当前会两次返回文件中的第一个值

我可以将信息保存在单独的文件中,但在重复循环之前,我不知道如何从每个文件中提取第一个值。想法

这是我的剧本:

Loop, read, C:\Users\Michael\Google Drive\AutoHotKey\Reference Files\item.txt
{
Loop, parse, A_LoopReadLine, %A_Tab%
    {
    sleep 1500
    send 1
    sleep 1500
    send {enter}
    send 52
    sleep 1500
    send {enter}
    send 4
    sleep 1500
    send {enter}
    sleep 1500
    Send %A_LoopField%
    sleep 1500
    send {enter}
    sleep 1500
    Send %A_LoopField%
}

}

您已经得到了第一个值-当循环读取该行时,您得到了一个\u loopfield-这是每个文件中第一行的值

但您只在一个文件中查找!这就是为什么你只能得到一个值。如果要循环浏览该目录中的所有
.txt
文件,必须使用通配符

这是给你的示意图(一个想法;你必须调整它):


请详细说明你的问题。提供有关输入和输出的详细信息。您要读取的文件的结构是什么?你想提取什么?发布具有代表性的输入->输出示例!
Loop, read, C:\Users\Michael\Google Drive\AutoHotKey\Reference Files\*.txt  ;loop through all .txt files in this directory
{
    thisfile = %a_loopfield%
    Loop, parse, A_LoopReadLine, %A_Tab%  ;now parse the file that is being looped
        {
            msgbox The file is: %thisfile%`r and the first line is %a_loopfield%
            break  ;since we only want the *first* line, then don't read any more of this file
    }
}