花费大量时间,并找到不起作用的旧语法示例,使我很难使其变得简单。
将目录拼接成字符串数组的简单快速的解决方案:
Loop, % folder_path_array.MaxIndex() ; concat string array
{
folder_path .= folder_path_array[A_Index]"\"
}
更高级的版本,如果您在路径字段中有结束反斜杠:
Loop, % folder_path_array.MaxIndex() ; concat array
{ if folder_path_array[A_Index] ; if [last] element of array is empty, skip it
folder_path .= folder_path_array[A_Index]"\"
}
更深入的细节。
我需要从输入字段复制目录路径,更改根目录,将其粘贴回输入字段并保存。
所以我最终得到了这个脚本:
SendInput, ^a ; select all input field text
SendInput, ^c ; copy current selection to clipboard
ClipWait, 30
folder_path_array := StrSplit(Clipboard, "\") ; split folder path into strings of array
folder_path_array[2] .= "_backup" ; prepend string to root folder, first element is "C:"
Loop, % folder_path_array.MaxIndex() ; concat string array
{ if folder_path_array[A_Index] ; if [last] element of array is empty, skip it
folder_path .= folder_path_array[A_Index]"\"
}
Clipboard := folder_path ; load the new string to clipboard
SendInput, ^v ; paste the new string into input field
希望它也能帮助别人。