AutoHotkey - 遍历列表并在每次迭代之间发送命令以进行数据输入
AutoHotkey - Iterate through list and send commands between each iteration for data entry
我正在尝试在 AHK 中使用 arrays/lists 进行一些数据输入,但无法弄清楚如何正确迭代。我从一个我一直在尝试的类似问题中得到这段代码:
^!G::
VarX=
(
48306237
48306642
48303423
48303612
48303797
)
loop, parse, VarX, \`n,`r
{
Send, %VarX%
Send, The next item in the list is
return
}
return
这确实遍历了列表,但我无法在两者之间发送命令。
目前,这是我得到的输出:
48306237
48306642
48303423
48303612
48303797the next item in the list is
怎样才能使输出结果如下?
48306237
the next item in the list is
48306642
the next item in the list is
48303423
the next item in the list is
48303612
the next item in the list is
48303797
the next item in the list is
感谢阅读
没有添加功能的解决方案:
VarX=
(
48306237
48306642
48303423
48303612
48303797
)
loop, parse, VarX, `n,`r
{
SendInput, %A_LoopField%{Enter}
Send, wait {Enter}
Sleep, 2000
Send, OK {Enter}
}
return
当您使用 Loop, parse
时,您要查找的循环内的值是 A_Loopfield
。如果代码变得过于复杂,创建一个单独的函数来清理代码也很有用。这是正确的示例用法:
VarX=
(
48306237
48306642
48303423
48303612
48303797
)
loop, parse, VarX, \`n,`r
HandleItem(A_Loopfield)
HandleItem(value)
{
SendInput % "Item Content: " . value . "`n"
}
我正在尝试在 AHK 中使用 arrays/lists 进行一些数据输入,但无法弄清楚如何正确迭代。我从一个我一直在尝试的类似问题中得到这段代码:
^!G::
VarX=
(
48306237
48306642
48303423
48303612
48303797
)
loop, parse, VarX, \`n,`r
{
Send, %VarX%
Send, The next item in the list is
return
}
return
这确实遍历了列表,但我无法在两者之间发送命令。
目前,这是我得到的输出:
48306237
48306642
48303423
48303612
48303797the next item in the list is
怎样才能使输出结果如下?
48306237
the next item in the list is
48306642
the next item in the list is
48303423
the next item in the list is
48303612
the next item in the list is
48303797
the next item in the list is
感谢阅读
没有添加功能的解决方案:
VarX=
(
48306237
48306642
48303423
48303612
48303797
)
loop, parse, VarX, `n,`r
{
SendInput, %A_LoopField%{Enter}
Send, wait {Enter}
Sleep, 2000
Send, OK {Enter}
}
return
当您使用 Loop, parse
时,您要查找的循环内的值是 A_Loopfield
。如果代码变得过于复杂,创建一个单独的函数来清理代码也很有用。这是正确的示例用法:
VarX=
(
48306237
48306642
48303423
48303612
48303797
)
loop, parse, VarX, \`n,`r
HandleItem(A_Loopfield)
HandleItem(value)
{
SendInput % "Item Content: " . value . "`n"
}