Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBS script reading data from text file 1

Status
Not open for further replies.

DutchDude

Technical User
Jul 15, 2005
11
NL
I' m trying to convert a piece of code I have for automating a simple task. i have a file called ABC.TXT filled with lines of text, I would like to insert this text into application TEST.EXE with a TAB in front...
it starts running fine, but it inserts the text a1 into the EXE, instead of the data from ABC.TXT.
does someone know what is wrong with the following script?


Code:
filespec="C:\ABC.txt"    'my data file
 
dim a,s
s=createobject("scripting.filesystemobject").opentextfile(filespec,1,true).readall
a=split(s,vbcrlf)
 
set WshShell = CreateObject("WScript.Shell")
 
for i=0 to ubound(a)
    if trim(a(i))<>"" then
         'Bring the application to the foreground
  WshShell.AppActivate "TEST.EXE"
  wscript.sleep 500
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "a(1)"
WshShell.SendKeys "{ENTER}"
    end if
next

thanks in advance for your time & afford
 
>[tt]WshShell.SendKeys "a(1)"[/tt]
[tt]WshShell.SendKeys [highlight]a[/highlight](1[highlight])[/highlight][/tt]


 
excellent

I thought I already tried that one to be sure, but I guess not
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top