一个脚本中的一系列动作,依次

Series of actions in one script, successively

AutoHotKey。 学习如何使用字符串、文件、变量等进行一系列操作。从 1 到 101 个。一个文件夹中的文件或一个文件夹中的文件夹,来自高位的字符串,一个脚本中的变量。通过更简单和经典的方法。

如果您想执行多个类似的操作,使用某种形式的循环几乎总是一个好主意。
数组也可以提供很多帮助。

这是一个 file/folder 循环:

Loop Files, C:\*.exe, R  ; get all .exe files that are on C:\ and subfolders of it
{
    MsgBox, Full path of the current file: %A_LoopFileFullPath%
    If (A_LoopFileName = "virus.exe") {
        MsgBox, A file called virus.exe was found.
    }
}

这是一个正常的循环:

Loop, 101 ;run the following code 101 times
{
    MsgBox, This is iteration number %A_Index%
    If (A_Index = 10)
        MsgBox, Nice! You made it through 10 iterations!
}

...

Loop, 101 ;run the following code 101 times
{
    If (A_Index >= 10 && A_Index < 20)
        MsgBox, This is iteration number %A_Index%. (10-20)
    If (A_Index >= 37 && A_Index < 71)
    {
        MsgBox, This is iteration number %A_Index%. (37-71)
    }
}