I need help with multiple line variables (specifically the clipboard)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
JoshMoore13579

I need help with multiple line variables (specifically the clipboard)

12 May 2016, 19:58

Can you help me with this? I am trying to paste multiple lines of code into a program, and it is not working. Right now I am using the (parentheses) method to store the info in the clipboard variable. It doesn't store multiple lines however, not even when I put `n at the end. (Which I would rather not use as there is a lot of lines that would need `n s on them. This is how I do it now:

clipboard =
(
Insert
multi
line
text
here
)
Send ^v

Here's my whole code in case I missed something. (The clipboard variables are at the end.) (Sorry that its long af. :P)

Code: Select all

#singleinstance force
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
^+x::
Keywait, LButton, D
MouseGetPos, mousex, mousey
Sleep, 100
KeyWait, LButton, D
MouseGetPos, mousex2, mousey2
origin := mousex
loops := (mousex2 - mousex) * (mousey2 - mousey)
loopsforx := (mousex2 - mousex)
;loops := loopsfo
MsgBox, %loops%`n%mousex%`n%mousey%`n%mousex2%`n%mousey2%

loop, % loops {
PixelGetColor, color%A_Index%, %mousex%, %mousey%
;MsgBox % color%A_Index%
mousex++
;Tooltip % color%A_Index% 
;Send %mousex% %mousey%

If mousex = %mousex2%
{
	mousey++
	mousex := origin
}
Tooltip %mousey%`n%mousey2%
}
msgbox, "Done!"
return
P::
clipboard = 
(
<MergeScript xmlns="http://www.ni.com/DiagramSdk.xsd">`n
    <MergeData Key="SerializationReason" Value="Copy" />`n
    <MergeGroup Path=".">`n
)
Send ^v
loop % loops {
If %loopsforx% = %A_Index% {
clipboard = 
(
        <MergeItem Path="." IsPrimary="True"><ConfigurableMethodCall Id="%ConfigurableMethodCallandSequenceOut%" Bounds="-34 152 163 91" Target="MotorDistance\.vix" xmlns="http://www.ni.com/VirtualInstrument.xsd"><ConfigurableMethodTerminal ConfiguredValue="1.B"><Terminal Id="MotorPort" Direction="Input" DataType="Single" Hotspot="0.5 1" Bounds="0 0 0 0" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="50"><Terminal Id="Speed" Direction="Input" DataType="Single" Hotspot="0.5 1" Bounds="54 56 30 27" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="-2"><Terminal Id="Degrees" Direction="Input" DataType="Single" Hotspot="0.5 1" Bounds="85 56 30 27" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="True"><Terminal Id="Brake\ At\ End" Direction="Input" DataType="Boolean" Hotspot="0.5 1" Bounds="116 56 30 27" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="0"><Terminal Id="InterruptsToListenFor_16B03592_CD76_4D58_8DC3_E3C3091E327A" Direction="Input" DataType="Int32" Hotspot="0.5 1" Bounds="0 0 0 0" /></ConfigurableMethodTerminal><Terminal Id="SequenceIn" Direction="Input" Wire="w6" DataType="NationalInstruments:SourceModel:DataTypes:X3SequenceWireDataType" Hotspot="0 0.5" Bounds="0 33 18 18" /><Terminal Id="SequenceOut" Direction="Output" Wire="w5" DataType="NationalInstruments:SourceModel:DataTypes:X3SequenceWireDataType" Hotspot="1 0.5" Bounds="145 33 18 18" /></ConfigurableMethodCall></MergeItem>`n
        <MergeItem Path="." IsPrimary="True"><Wire Id="w1" Joints="N(n%ConfigurableMethodCallandSequenceOut%:SequenceOut) N(n%SequenceIn%:SequenceIn)" xmlns="http://www.ni.com/VirtualInstrument.xsd" /></MergeItem>`n
)
Send, ^v
clipboard = 
(
        <MergeItem Path="." IsPrimary="True"><ConfigurableMethodCall Id="n%ConfigurableMethodCallandSequenceOut%" Bounds="1719 100 163 91" Target="MotorDistance\.vix" xmlns="http://www.ni.com/VirtualInstrument.xsd"><ConfigurableMethodTerminal ConfiguredValue="1.A"><Terminal Id="MotorPort" Direction="Input" DataType="Single" Hotspot="0.5 1" Bounds="0 0 0 0" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="50"><Terminal Id="Speed" Direction="Input" DataType="Single" Hotspot="0.5 1" Bounds="54 56 30 27" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="-2"><Terminal Id="Degrees" Direction="Input" DataType="Single" Hotspot="0.5 1" Bounds="85 56 30 27" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="True"><Terminal Id="Brake\ At\ End" Direction="Input" DataType="Boolean" Hotspot="0.5 1" Bounds="116 56 30 27" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="0"><Terminal Id="InterruptsToListenFor_16B03592_CD76_4D58_8DC3_E3C3091E327A" Direction="Input" DataType="Int32" Hotspot="0.5 1" Bounds="0 0 0 0" /></ConfigurableMethodTerminal><Terminal Id="SequenceIn" Direction="Input" Wire="w13" DataType="NationalInstruments:SourceModel:DataTypes:X3SequenceWireDataType" Hotspot="0 0.5" Bounds="0 33 18 18" /><Terminal Id="SequenceOut" Direction="Output" Wire="w14" DataType="NationalInstruments:SourceModel:DataTypes:X3SequenceWireDataType" Hotspot="1 0.5" Bounds="145 33 18 18" /></ConfigurableMethodCall></MergeItem>`n
        <MergeItem Path="." IsPrimary="True"><Wire Id="w13" Joints="N(n%ConfigurableMethodCallandSequenceOut%:SequenceOut) N(n%SequenceIn%:SequenceIn)" xmlns="http://www.ni.com/VirtualInstrument.xsd" /></MergeItem>`n
)
loop, %loopsforx% {
Send, ^v
}
}
;Tooltip, % color%A_Index%
;MsgBox % color%A_Index%
;If % color%A_Index% = 0xFFFFFF {
;MsgBox It is white
;}
If % color%A_Index% = 0x000000 {
;MsgBox It is black
clipboard =
(
        <MergeItem Path="." IsPrimary="True"><ConfigurableMethodCall Id="n3" Bounds="499 48 163 91" Target="MotorDistance\.vix" xmlns="http://www.ni.com/VirtualInstrument.xsd"><ConfigurableMethodTerminal ConfiguredValue="1.D"><Terminal Id="MotorPort" Direction="Input" DataType="Single" Hotspot="0.5 1" Bounds="0 0 0 0" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="50"><Terminal Id="Speed" Direction="Input" DataType="Single" Hotspot="0.5 1" Bounds="54 56 30 27" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="-180"><Terminal Id="Degrees" Direction="Input" DataType="Single" Hotspot="0.5 1" Bounds="85 56 30 27" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="True"><Terminal Id="Brake\ At\ End" Direction="Input" DataType="Boolean" Hotspot="0.5 1" Bounds="116 56 30 27" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="0"><Terminal Id="InterruptsToListenFor_16B03592_CD76_4D58_8DC3_E3C3091E327A" Direction="Input" DataType="Int32" Hotspot="0.5 1" Bounds="0 0 0 0" /></ConfigurableMethodTerminal><Terminal Id="SequenceIn" Direction="Input" Wire="w3" DataType="NationalInstruments:SourceModel:DataTypes:X3SequenceWireDataType" Hotspot="0 0.5" Bounds="0 33 18 18" /><Terminal Id="SequenceOut" Direction="Output" DataType="NationalInstruments:SourceModel:DataTypes:X3SequenceWireDataType" Hotspot="1 0.5" Bounds="145 33 18 18" /></ConfigurableMethodCall></MergeItem>`n
        <MergeItem Path="." IsPrimary="True"><Wire Id="w3" Joints="N(n3:SequenceIn) N(n2:SequenceOut)" xmlns="http://www.ni.com/VirtualInstrument.xsd" /></MergeItem>`n
        <MergeItem Path="." IsPrimary="True"><ConfigurableMethodCall Id="n4" Bounds="499 48 163 91" Target="MotorDistance\.vix" xmlns="http://www.ni.com/VirtualInstrument.xsd"><ConfigurableMethodTerminal ConfiguredValue="1.D"><Terminal Id="MotorPort" Direction="Input" DataType="Single" Hotspot="0.5 1" Bounds="0 0 0 0" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="50"><Terminal Id="Speed" Direction="Input" DataType="Single" Hotspot="0.5 1" Bounds="54 56 30 27" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="180"><Terminal Id="Degrees" Direction="Input" DataType="Single" Hotspot="0.5 1" Bounds="85 56 30 27" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="True"><Terminal Id="Brake\ At\ End" Direction="Input" DataType="Boolean" Hotspot="0.5 1" Bounds="116 56 30 27" /></ConfigurableMethodTerminal><ConfigurableMethodTerminal ConfiguredValue="0"><Terminal Id="InterruptsToListenFor_16B03592_CD76_4D58_8DC3_E3C3091E327A" Direction="Input" DataType="Int32" Hotspot="0.5 1" Bounds="0 0 0 0" /></ConfigurableMethodTerminal><Terminal Id="SequenceIn" Direction="Input" Wire="w3" DataType="NationalInstruments:SourceModel:DataTypes:X3SequenceWireDataType" Hotspot="0 0.5" Bounds="0 33 18 18" /><Terminal Id="SequenceOut" Direction="Output" DataType="NationalInstruments:SourceModel:DataTypes:X3SequenceWireDataType" Hotspot="1 0.5" Bounds="145 33 18 18" /></ConfigurableMethodCall></MergeItem>`n
        <MergeItem Path="." IsPrimary="True"><Wire Id="w3" Joints="N(n4:SequenceIn) N(n3:SequenceOut)" xmlns="http://www.ni.com/VirtualInstrument.xsd" /></MergeItem>`n
)
Send ^v
}
clipboard = 
(

)
}
clipboard = 
(
    </MergeGroup>`n
</MergeScript>
)
Send ^v
User avatar
Flarebrass
Posts: 104
Joined: 20 Nov 2015, 13:13
Location: USA
Contact:

Re: I need help with multiple line variables (specifically the clipboard)

13 May 2016, 06:26

Does the paste fail, or is it simply skipping the newlines? 'r'n is the newline method that the documentation says to use. Also, make sure you're using clipboard := because it will find the continuation section on the next line; a regular equals sign will trick it into thinking that you want a blank variable and it won't read the next line's parenthesis.
(Note that I can't test my code before posting, so beware of bugs! -Flarebrass Amatzikahni)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333 and 363 guests