在 Windows 命令行参数中使用空格

Use whitespace in Windows command line parameters

我的 AutoIt 脚本:

WinWaitActive("Open")
Send($CmdLine[1])
Send("{ENTER}")

我从 Java 执行它(将文件路径传递给它):

String autoITExecutable = "C:\filechooser.exe " + fileSource;

文件名包含 spaces,因此它读取文件名直到第一个 space 并忽略其余部分。如何正确传递包含 spaces 的文件路径作为命令行参数?

Name of files contains spaces, but it reads filename only for the first space and cuts filename.

根据Documentation - Intro - Running Scripts

If you're passing strings with spaces, then you will need to escape these using "double quotes" in your commandline string.

如果没有,space 之后的文本将包含在下一个数组元素中(在本例中为 $CmdLine[2])。 Java 示例:

String autoITExecutable = "C:\filechooser.exe \"" + fileSource + "\"";

未处理的命令行(单个字符串)根据 $CmdLineRaw 从接收 AutoIt 脚本中获得。