Columbine
Joined: 10 Nov 2009 Posts: 9 Location: Australia
|
Posted: Thu Nov 12, 2009 3:53 pm Post subject: Lost outside the loop |
|
|
This code almost does what I want, but I'm a little lost with the loop command to make it all happen again,
Specifically
1. Open Excel, (do this once)
2. Open Text file from a folder, Copy three lines respectively into cells A1, B1, C1
3. Close Text file, Open next text file in folder, copy the three lines.
4. continue until there are no text files left in the folder.
Text files named sequentially: 001xxxxxxxxx, 002xxxxxxxx, 003xxxxxxx etc.
| Code: | ; AutoHotkey Version: 1.0.48.05
; Language: English
; Platform: Windows XP Professional 5.1 SP3
; Author: C. Waring
;
; Script Function: To Make one New Excel File and to copy all results (from mulitply .txt) made in program Mark to rows in the Excel sheet.
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
FileSelectFile, Results, 3, C:\Documents and Settings\gseuser\Desktop\Bootstrap\,Name New Results File ,*xls
Run, %Results%
WinActivate, ahk_class XLMAIN
Send, ^{Home} ; Go to Row 1 Col 1
clipboard = ; start off empty
FileSelectFile, File,,,Select first .txt file,*.txt
Loop,%File%, 0, 0
{
File = %A_LoopFileFullPath%
Run, %File%
Loop, Read, %File%,
FileReadLine, Name, %File%, 8
ControlSend, XLDESK1, %Name%, ahk_class XLMAIN
WinActivate, ahk_class XLMAIN
Send {tab}
clipboard = ; start off empty
WinActivate, ahk_class Notepad
WinWait, ahk_class Notepad
Loop, Read, %File%,
If A_LoopReadLine contains Model=
{
StringReplace, var, A_LoopReadLine, {, +[, All ; "Shift + [") = {
StringReplace, var, var, }, +], All
ControlSend, XLDESK1, %var%, ahk_class XLMAIN
}
WinActivate, ahk_class XLMAIN
Send {tab}
WinActivate, ahk_class Notepad
WinWait, ahk_class Notepad
Loop, Read, %File%,
If A_LoopReadLine contains 1 1
ControlSend, XLDESK1, %A_LoopReadLine%, ahk_class XLMAIN
WinActivate, ahk_class XLMAIN
Send {tab}
Sleep, 100
Send {enter}
Sleep, 100
WinClose, ahk_class Notepad
} |
_________________ Learning on the fly |
|