When you use `n in a batch file, that is 2 characters: ` n
When you use `n in an AHK script, that is 1 character: (line feed)
When you use `` in an AHK script, that is 1 character: `
When you use ``n in an AHK script, that is 2 characters: ` n
See this link:
#EscapeChar - Syntax & Usage | AutoHotkey
https://www.autohotkey.com/docs/commands/_EscapeChar.htm
I would write the code like this:
Code: Select all
;MyScript.ahk
;==================================================
count = %0%
Loop %0%
{
if (A_Index = 1)
all := %A_Index%
else
all .= " " %A_Index%
}
all := StrReplace(all, "``n", "`n")
MsgBox, % count "`n" all
;==================================================
count := A_Args.Length()
Loop % A_Args.Length()
{
if (A_Index = 1)
all := A_Args[1]
else
all .= " " A_Args[A_Index]
}
all := StrReplace(all, "``n", "`n")
MsgBox, % count "`n" all
;==================================================
Code: Select all
::MyBat.bat
@"C:\Users\me\Desktop\MyScript.ahk" xx `nyy`nzz
@"C:\Users\me\Desktop\MyScript.ahk" "xx `nyy`nzz"
@pause
exit