Here is the script. It will launch TWS (had to use a batch file do to the long command line required to launch Java. The batch file is listed below). Then it will wait 4 seconds for TWS to load. If the script does not see the Logon screen, it will try again after waiting for another second (maximum tries is set to 10).
You should replace the USERID and PASSWORD, in the Send() command with your real userid and password.
AUTOIT SCRIPT
-------------------
Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
If Not WinExists("Universal Account") Then
Run(@ComSpec & " /c " & "c:\jts\run.bat", "c:\jts" ,@SW_HIDE )
Sleep(4000)
for $__n1_ = 1 to 10
WinWait("New Login","")
If Not WinActive("New Login","") Then WinActivate("New Login","")
WinWaitActive("New Login","")
Sleep ( 1000 )
next
Send("USERID{TAB}PASSWORD{ENTER}")
EndIf
Sleep(5000)
for $__n1_ = 1 to 20
Sleep(1000)
If WinExists("Universal Account") Then
WinMinimizeAll()
Exit
EndIf
Sleep ( 1000 )
next
Exit
RUN.BAT
----------
c:
cd \jts
javaw.exe -cp jts.jar;jcommon-0.9.0.jar;jfreechart-0.9.15.jar -Dsun.java2d.noddraw=true jclient/LoginFrame C:\Jts