Send Command

AutoIt

 

Q #1: How do I output spaces that are at the beginning of a line?

      ---------------------------------------------------------------------

A #1: The SEND command gobbles whitespace at the beginning and end of lines.

      For example:

      sample file sample.txt:

      -----this is line one
            -----this is line two
                 -----this is line three

      ********************************

      ;--sample.aut file
      FileReadLine,line1,C:\\sample.txt,1
      FileReadLine,line2,C:\\sample.txt,2
      FileReadLine,line3,C:\\sample.txt,3
      run,notepad.exe
      winwaitactive,Untitled

      Send,%line1%{ENTER}
      Send,%line2%{ENTER}
      Send,%line3%{ENTER}

      msgbox,0,test,%line1%\n%line2%\n%line3%

      ********************************

      output in msgbox is fine
      output to notepad is:
     
      -----this is line one
      -----this is line two
      -----this is line three

      I fixed by doing the following:

      Send,#%line1%{ENTER}
      Send,#%line2%{ENTER}
      Send,#%line3%{ENTER}

      The pound sign does not get sent, but it does allow you to delineate the
      start of the string.

-----------------------------------------------------------------------------

Q #2: With AutoIT can I work with excel cells,
      i.e.: can I put values inside cells

      ---------------------------------------------------------------------

A #1: Yes.  The same way you would normally do
      keystrokes and mouse clicks.  An example
      might be the following scriptlet.

      ; ======= Scriptlet Starts Here =======
      ; Put EXCEL's PATH into the EXCEL variable.
      SetEnv, EXCEL, F:\\Apps\\Office97\\Office\\excel.exe
      ; Run the Excel program.
      Run, %EXCEL%

      ; Wait for Excel to be ready for input.
      WinWaitActive, Microsoft Excel

      ; Goto cells C1-C5 and enter #'s & a formula
      ; that finds 10% of the 4 cells above C5.
      Send, ^Gc1{ENTER}22.5{ENTER}
      Send, ^Gc2{ENTER}55.625{ENTER}
      Send, ^Gc3{ENTER}12.75{ENTER}
      Send, ^Gc4{ENTER}103.31{ENTER}.
      Send, ^Gc5{ENTER}=sum(C1-C4)/100*10
      ; ======= Scriptlet Ends Here =======