AutoIT 脚本无法处理“+”号
AutoIT script is unable to handle "+" sign
我在 Java
中有一个变量 (fileSource
),其中包含 +
符号。我尝试使用以下代码将其粘贴到文件选择器对话框 window 中。
String autoITExecutable = "C:\_privat\filechooser.exe \"" + fileSource + "\"";
AutoIT 脚本,filechooser.exe
:
WinWaitActive("Open")
Send($CmdLine[1])
Send("{ENTER}")
变量值粘贴到对话框 window 时没有 +
符号。
fileSource
的示例值:C:\_private\input\Files\my_upload1+1+2(original).pdf
AutoIT 像这样使用它:C:\_private\input\Files\my_upload112(original).pdf
WinWaitActive("Open")
Send($CmdLine[1], 1)
Send("{ENTER}")
Send
会将 +
解释为 shift 键。使用 Send
标志 1 的第二个参数发送原始文本。
'+' This tells AutoIt to send a SHIFT keystroke; therefore,
Send("Hell+o") would send the text "HellO". Send("!+a") would send
"ALT+SHIFT+a".
要克服这个问题,你需要
flag [optional] Changes how "keys" is processed:
$SEND_DEFAULT (0) = Text contains special characters like + and ! to indicate SHIFT and ALT key-presses (default).
$SEND_RAW (1) = keys are sent raw.
导致:
$var = "..... + .... +" // string containing special characters - "+"
Send($var, 1) // do not interpret, use raw
我在 Java
中有一个变量 (fileSource
),其中包含 +
符号。我尝试使用以下代码将其粘贴到文件选择器对话框 window 中。
String autoITExecutable = "C:\_privat\filechooser.exe \"" + fileSource + "\"";
AutoIT 脚本,filechooser.exe
:
WinWaitActive("Open")
Send($CmdLine[1])
Send("{ENTER}")
变量值粘贴到对话框 window 时没有 +
符号。
fileSource
的示例值:C:\_private\input\Files\my_upload1+1+2(original).pdf
AutoIT 像这样使用它:C:\_private\input\Files\my_upload112(original).pdf
WinWaitActive("Open")
Send($CmdLine[1], 1)
Send("{ENTER}")
Send
会将 +
解释为 shift 键。使用 Send
标志 1 的第二个参数发送原始文本。
'+' This tells AutoIt to send a SHIFT keystroke; therefore, Send("Hell+o") would send the text "HellO". Send("!+a") would send "ALT+SHIFT+a".
要克服这个问题,你需要
flag [optional] Changes how "keys" is processed:
$SEND_DEFAULT (0) = Text contains special characters like + and ! to indicate SHIFT and ALT key-presses (default).
$SEND_RAW (1) = keys are sent raw.
导致:
$var = "..... + .... +" // string containing special characters - "+"
Send($var, 1) // do not interpret, use raw