开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: automated login


bee_jay_61
 

In my program I have automated the "Logon"- and "Accept incomming.."-
Dialog.

For both dialogs I search the desired window. If the window isn?t
found within 60 seconds the function stops. So my program will never
hang if the TWS window doesn?t appear for any reason.

I use the following Delphi Code to find the "Accept incomming.."
Dialog:

function EnumWinProc(WinHandle: HWND; lParam: LPARAM): boolean;
StdCall;
var
szName: array[0..512] of char;
begin
Result := True;
GetClassName(WinHandle, szName, 255);
if UpperCase(szName) = 'SUNAWTDIALOG' then begin
GetWindowText(WinHandle, szName, 255);
if UpperCase(szName) = 'TRADER WORKSTATION' then begin
if IsWindowVisible(WinHandle) then begin
TwsWindow := WinHandle;
Result := False;
end;
end;
end;
end;

For the "Logon"_Dialog you have to search for classname "SUNAWTFRAME"
and windowtext "NEW LOGIN".

When the window is found then I sent a "Carriage Return" to
the "Accept incomming connection attempt"-Dialog or twice a "Tab" and
a "Carriage Return" to the "Logon"-Dialog.

To find out if there is any easy way (of corse you can pre-fill the
fields by sending the values for Username and Password in the same
way like "Carriage Return" and "Tab") to pre-fill the Username and
Password fields I decompiled the "Trader Workstation" (this is
possible because the TWS is written in JAVA).

I found the following code:


public static void main(String args[])
{
if(args.length < 1)
{
System.out.println("USAGE: java jclient.LoginFrame
srcDir");
System.out.println(" --- or ---");
System.out.println(" java -jar jts.jar srcDir");
System.exit(0);
}
Thread.currentThread().setName("JTS-Main");
String s = args[0] + System.getProperty("file.separator");
System.setProperty("srcDir", s);
String s1 = System.getProperty("srcDir") + "jts.ini";
a(s);
String s2 = new String();
fl fl1 = new fl();
er er1 = new er(fl1, "Communication", "Peer", null);
er er2 = new er(fl1, "Communication", "LocalPort", 0);
er er3 = new er(fl1, "Communication", "ShouldClose", true);
er er4 = new er(fl1, "Logon", "Username", "");
er er5 = new er(fl1, "Logon", "Password", "");
er er6 = new er(fl1, "Communication", "Debug", false);
er er7 = new er(fl1, "GUI", "LookAndFeel", "Metal");
er er8 = new er(fl1, "Communication", "Compression", true);
er er9 = new er(fl1, "Logon", "UseAnotherEncryption", false);
if(!fl1.a(s1))
{
ek.b(null, "jts.ini file could not be read");
return;
}
String s4 = er1.a();
if(s4 == null)
{
ek.b(null, "No peer entry in jts.ini file");
return;
}
int i = s4.indexOf(':');
if(i == -1)
{
ek.b(null, "Invalid peer entry in jts.ini file");
return;
} else
{
String s3 = s4.substring(0, i);
int j = Integer.parseInt(s4.substring(i + 1));
int k = er2.b();
boolean flag = er3.c();
go go1 = new go(s3, j, k, er4.a(), er5.a(), false, flag,
null, er6.c(), er7.a(), er8.c(), er9.c());
go1.setLocation(400, 200);
go1.setTitle("New Login");
go1.setSize(250, 174);
go1.setDefaultCloseOperation(2);
go1.show();
return;
}


So I add the following to the JTS.INI file to pre-fill UserName and
Password:

[Logon]
Username=edemo
Password=demouser


I do add these lines from my program every time before I start the
TWS with "ShellExecute" because I have more than one user.


All this works fine for me.

BeeJay


--- In twsapi@y..., "kevin6502" <kevin6502@y...> wrote:
There is an entry in the IB board that addresses this. The solution
is to send a carriage return event to the dialog box when it pops
up.
The trick is knowing which window(dialog box) to send it to. His
solution was to find a window with a certain name (TWS_whatever),
meaning he would search for 60 seconds, then send a CR to that
window. Check out the IB board about a week or two back.

Kevin


--- In twsapi@y..., "kgeis" <kgeis@y...> wrote:
If you could keep TWS running 24/7 and login automatically, then
IB
wouldn't be able to differentiate its professional service (which
requires $2400 minimum commission per month.) An unfortunate
situation for us TWS users who want to do a little bit more.

--- In twsapi@y..., "marinindextrader" <marinindextrader@y...>
wrote:
You are among a large group of users who would like to be able
to
do
this, me being one of them...

I don't know how...

It really is anoying they don't give us a security server to
pass
through. Seems so archaic to have to have a TWS open for each
account
we log on to...

Join [email protected] to automatically receive all group messages.