Reputation: 7284
I've found the following question in Stack-Overflow which is related to mine, but the solution didn't work for me.
I would like to compile an AHK script which opens a file in Notepad++ and inserts a code at a specific line. I've got the AHK script to work with a normal string, but it doesn't work with the code I'm trying to use.
I would like to insert the following code in a file using notepad++
<Macro name="Remove Navis folders" Ctrl="no" Alt="no" Shift="no" Key="0">
<Action type="0" message="2318" wParam="0" lParam="0" sParam="" />
<Action type="3" message="1700" wParam="0" lParam="0" sParam="" /></Macro>"
And here's my script
obj := {"key":
(
<Macro name="Remove Navis folders" Ctrl="no" Alt="no" Shift="no" Key="0">
<Action type="0" message="2318" wParam="0" lParam="0" sParam="" />
<Action type="3" message="1700" wParam="0" lParam="0" sParam="" /></Macro>
)}
Run, notepad++.exe %A_AppData%\Notepad++\shortcuts.xml
Sleep, 200
Send, ^{Home}
Send, ^f
Sleep, 200
Sendraw, <Macros>
Send, {ENTER}{ESC}{Right}
Sleep, 200
Send, {ENTER}{Tab}
Sleep, 200
Send, % obj["key"]
Upvotes: 0
Views: 658
Reputation: 221
You have to put entire text in " and escape " that are part of the code otherwise there is an error.
obj := {"key":
(
"<Macro name=""Remove Navis folders"" Ctrl=""no"" Alt=""no"" Shift=""no"" Key=""0"">
<Action type=""0"" message=""2318"" wParam=""0"" lParam=""0"" sParam="""" />
<Action type=""3"" message=""1700"" wParam=""0"" lParam=""0"" sParam="""" /></Macro>"""
)}
MsgBox % obj["key"]
Upvotes: 1