Jump to content

Cope text from a program and paste into a line in the text file


Recommended Posts

Hi guys,

I was introduced to Autoit a month ago and found that software quite interesting even though I have very little experience in programming.

I currently work on a small project which involve testing a product. The testing process is enter a list of commands one after another in sequence into customer's consigned program. After each command enter, the program will then generate a result and I need to store the result into an open office log file.

The way I was done before is using Winactive, Mouseclick, Send command to copy and paste back and forth between two windows as below.

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <FileConstants.au3>

AutoItSetOption ('MouseCoordMode', 0)

WinActivate ('DMFC Terminal')           ;customer program
MouseClick ('primary', 46, 105, 1, 0)
Send ('gasidentifier(1)=H2O')           ;1st command
MouseClick ('primary', 86, 215, 1, 0)
Sleep (200)
MouseClick ('primary', 52, 179, 2, 0)   ;highlight the result
Send ("^c")                             ;copy it
WinActivate ('201-000715-001_A03 BI 097X624 TEST LOG MASTER.ods - OpenOffice Calc')
MouseClick ('primary', 850, 383, 1, 0)  
Send ("^v")                             ;paste the result

  Now, I want to store my result in a text file so that it can be opened on any computers and converted into csv format as needed. Below is what I have been working on.

#include <StringConstants.au3>
#include <MsgBoxConstants.au3>
#include <FileConstants.au3>

Global $customer = InputBox ('Customer','Please enter customer name ?')
Global $assy = InputBox ('Assembly','Please enter assembly number ?')
Global $wo = InputBox ('Work order','Please enter work order number ?')
Global $serial = InputBox ('Serial number', 'Please scan serial number ?')
Global $qty = InputBox ('Kit Quantity','Please enter kit quantity ?')
Global $id = InputBox ('Operator ID','Please enter your ID ?')
Global $shift = InputBox ('Shift','Please enter your shift ?')

$file = FileOpen("C:\Users\HuynhTran\Desktop\Bi Project\testing.txt", 1)

; Check if file opened for writing OK
If $file = -1 Then

FileWriteLine ($file, "Date, " & @MON & "/" & @MDAY  & "/" & @YEAR & "," & "Time: " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
FileWriteLine ($file, "Customer, " & $customer & @CRLF)
FileWriteLine ($file, "Assembly, " & $assy & @CRLF)
FileWriteLine ($file, "W/O, " & $wo & @CRLF)
FileWriteLine ($file, "Serial, " & $serial & @CRLF)
FileWriteLine ($file, "Quantity, " & $qty & @CRLF)
FileWriteLine ($file, "Operator ID, " & $id & @CRLF)
FileWriteLine ($file, "Shift, " & $shift & @CRLF)
FileWriteLine ($file, "Command, " &  "Expected result," & "Result," & "Pass/Fail," & @CRLF)

FileWriteLine ($file, "gasidentifier(1)=H2O," & "H2O," &        ;I want to paste result here right after H2O

I would like to paste the result right after H2O in a text file but I don't know how to do it. It will be much helpful if you guys can help me by point me the right directions or suggestions that I should research more. Thank you very much.


Edited by Mr_Tran
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...