Code:
<cmds><keys_block>
<#>
<#> Sample: Start Notepad and type text in it - safe way
<#> local variables
<varset>("vbTemp_Output=_vStrEmpty","")
<varset>("vCounter1=0","")
<varset>("vCounter2=0","")
<varset>("vLength=_vStrEmpty","")
<varset>("vFirstLineFlag=0","")
<#> copy the selected text
<clp_copyselected>(0,6)
<#> exit macro if clipboard is empty
<if_clp>("EMPTY","")
<msg>(-100,-100,"Empty clipboad","Meldung",1,0,0,1)
<exitmacro>
<endif>
<#> start notepad and activate
<execappex>("notepad.exe","","",0,0)
<#> Wait until Notepad is loaded
<waitfor>("WIN","OPEN","mw[[ ]] mc[[ Notepad ]] cw[[ ]] cc[[ ]] ",5,0)
<#> Make Notepad window active
<actwin>("mw[[ ]] mc[[ Notepad ]] cw[[ ]] cc[[ ]] ",0,0,"no")
<#> Make sure the Notepad window is active
<if_win>("mw[[ ]] mc[[ Notepad ]] cw[[ ]] cc[[ ]] ","ACT",0)
<wx>(350,1)
<#> paste, select all and crop
<keys><ctrl>v<ctrl><wx>(150,1)<ctrl>a<ctrl><wx>(150,1)<ctrl>x<ctrl><wx>(250,1)<alt><F4><alt><cmds>
<#> set text align left for text out of clipboard
<var_oper>(vResultText,"%_vClpText%",TEXT_ALIGN_LEFT,"","","")
<#> count number of lines and loop over all lines
<var_oper>(vbTemp_NumOfLines,"vResultText",TEXT_GET_NUMOFLINES,"","", "0")
<#><msg>(-100,-100,"%vbTemp_NumOfLines%","Meldung",1,0,0,1)
<if_str>("vbTemp_NumOfLines<=1")
<exitmacro>
<endif>
<#> beginn of lopp over all lines from clipboard text
<begloop>(vbTemp_NumOfLines)
<#> get current line (from loop number)
<var_oper>(vbTemp_LineText,"vResultText",TEXT_GET_LINE,"_vLoopCounter","", "0")
<#> delete all apostrophs
<#><var_oper>(vbTemp_LineText,"%vbTemp_LineText%",STR_REPLACE,"'","", "0")
<#> remove the character TAB from beginning
<#><var_oper>(vbTemp_LineText,"%vbTemp_LineText%",STR_TRIMLEFT," ","", "0")
<#><var_oper>(vbTemp_LineText,"%vbTemp_LineText%",STR_TRIMRIGHT," ","", "0")
<var_oper>(vbTemp_LineText,"%vbTemp_LineText%",STR_REPLACE," ","", "0")
<#> get the length of the line
<var_oper>(vLength,"%vbTemp_LineText%",STR_LENGTH,"","", "0")
<#> if length is smaller that 1 and counter 2 is 1 then skip loop (removes empty lines from text)
<if_str>("(vLength<=1)_AND_(vCounter2==1)")
<goto>("SkipLoop")
<else> <#> if not then reset counter 2
<varset>("vCounter2=0","")
<endif>
<#> if line length is smaller than 1 add 1 to counter1
<if_str>("vLength<1")
<var_oper>(vCounter1,"%vCounter1%+1",CALC_EXPRESSION,"0","", "0")
<endif>
<#> if there are more then 2 empty lines after another then skip loop and set flag counter2 ==1
<if_str>("vCounter1==3")
<var_oper>(vCounter2,"%vCounter2%+1",CALC_EXPRESSION,"0","", "0")
<varset>("vCounter1=0","")
<goto>("SkipLoop")
<endif>
<#><msg>(-100,-100,"%vbTemp_Output%","Meldung",1,0,0,1)
<#> check the output string / append all lines
<#> IMPORTANT! if both is false than this expression ist true!
<if_str>("vbTemp_Output==_vStrEmpty")
<if_str>("vFirstLineFlag==0")
<varset>("vFirstLineFlag=1","")
<varset>("vbTemp_Output=vbTemp_LineText","")
<else>
<goto>("ElseWay")
<endif>
<else>
<label>("ElseWay")
<#><msg>(-100,-100,"Input wäre: %vbTemp_Output%","Meldung",1,0,0,1)
<var_oper>(vbTemp_Output,"%vbTemp_Output%",STR_APPEND,"%_vKeyReturn%%vbTemp_LineText%","", "0")
<endif>
<label>("SkipLoop")
<#><msg>(-100,-100,"%vCounter1%","Meldung",1,0,0,1)
<endloop>
<#> put output text to clipboard
<clpput>("%vbTemp_Output%")
<endif><keys_unblock>