开云体育

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

twsapi: automated login


Carl Erikson
 

A hack is to send keystrokes to the login window.
Pass your username as separate keystrokes. Then send
a tab key. Then send your password as separate
keystrokes. Then send a return. There is a setting
to pre-fill the username in the .ini file (sorry, no
pre-fill for the password):

[Logon]
Username=edemo

.
.
.

If you pre-filled in the username you can just send a
tab and then the password plus a return key. I send
characters to windows with Perl, but you can do it in
almost any language (Visual Basic, C++).

I believe you can detect when the "Accept incoming
connection" window pops up. If that is possible you
might just be able to send the enter key to it to
accept the connection. I haven't tried this yet.

Good luck,
Carl

--- Michel <migurull@...> wrote:
Hi,

Does somebody know some way to run the TWS
application unattended?
What I need is:
1- Avoid the login screen, passing parameters
(UserName and Password) from
my calling application.
2- Respond to the message window asking 'Accept
incoming connection
attempt?' when I connect to the local server.

This is because I'm writting my own program (Visual
Basic using TWS ActiveX)
which allways runs in the background and want it to
automatically launch TWS
few minutes before markets open and perform some
automated tasks when I'm
not at home.

I've tried to launch TWS from my application with a
call to 'ShellExecute',
passing parameters as 'username' or 'user' without
success. I always get the
login screen blank because I ignore if TWS accepts
such parameters and how
they must be coded (I think this must be possible
because in the web demo,
the login screen appears whith such fields
pre-filled with 'edemo' and
'demouser'). Perhaps in some 'ini' file? (I've not
found any section related
to username and password).

Thanks for any help.

Michel.



__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free


Michel
 

开云体育

Thanks Carl.
I've tried it in VB but it does not work.?I've not tried it with the login window but with the 'connection confirmation' window there are various problems.
In my code, first I pass the focus to TWS (AppActivate) and then I try to send it keys (SendKey) (ENTER key in this case).
First problem is when in your code you issue a connection command (ActiveX.connect), TWS seems to catch you in a program loop and dont return to your calling program until you manually click 'Yes' or 'No' in this window so any code after 'connect' (AppActivate and SendKeys), simply dont execute.
To turn around this problem, I made a separate litle?application (IBActivation.exe) which simply makes this:
1- Tempo 1 second.
2- AppActivate "Stock and options..." (this is the title of the TWS window)
3- Tempo 1 second.
4- SendKeys "{ENTER}"
Then in my main code:
ShellExecute "IBActivation.exe"
TWS.connect
... and get a system error when IBActivation.exe tries to activate and/or send keys. (It works if TWS is runing normally, but not when presenting the 'connection confirmation' window)!
So I thought this behaviour was implemented by IB for some security reason to be sure that a connection to the program is really made by the account owner. (There is a security problem if you automate login and connection because everybody having your program or access to your PC can connect to your account).
?
Here I am...
I'll try this for the login window and post results here.
?
Thanks again.
Michel.
?

[Michel]??-----Mensaje original-----
De: Carl Erikson [mailto:carlerikson@...]
Enviado el: martes, 02 de julio de 2002 22:24
Para: twsapi@...
Asunto: Re: twsapi: automated login

A hack is to send keystrokes to the login window.
Pass your username as separate keystrokes.? Then send
a tab key.? Then send your password as separate
keystrokes.? Then send a return.? There is a setting
to pre-fill the username in the .ini file (sorry, no
pre-fill for the password):

[Logon]
Username=edemo

.
.
.

If you pre-filled in the username you can just send a
tab and then the password plus a return key.? I send
characters to windows with Perl, but you can do it in
almost any language (Visual Basic, C++).

I believe you can detect when the "Accept incoming
connection" window pops up.? If that is possible you
might just be able to send the enter key to it to
accept the connection.? I haven't tried this yet.

Good luck,
Carl


David
 

开云体育

Michel,
what bee-jay-61 has done it was using Win Api's not the VB code itself.
I'll post the code after i get around my problems and have more time to do it.
Also, anyone running Proxy succesfully?? (Proxy from AnalogX)
That's why I don't have the time.
David

----- Original Message -----
From: Michel
Sent: Wednesday, July 03, 2002 7:33 PM
Subject: RE: twsapi: automated login

Thanks Carl.
I've tried it in VB but it does not work.?I've not tried it with the login window but with the 'connection confirmation' window there are various problems.
In my code, first I pass the focus to TWS (AppActivate) and then I try to send it keys (SendKey) (ENTER key in this case).
First problem is when in your code you issue a connection command (ActiveX.connect), TWS seems to catch you in a program loop and dont return to your calling program until you manually click 'Yes' or 'No' in this window so any code after 'connect' (AppActivate and SendKeys), simply dont execute.
To turn around this problem, I made a separate litle?application (IBActivation.exe) which simply makes this:
1- Tempo 1 second.
2- AppActivate "Stock and options..." (this is the title of the TWS window)
3- Tempo 1 second.
4- SendKeys "{ENTER}"
Then in my main code:
ShellExecute "IBActivation.exe"
TWS.connect
... and get a system error when IBActivation.exe tries to activate and/or send keys. (It works if TWS is runing normally, but not when presenting the 'connection confirmation' window)!
So I thought this behaviour was implemented by IB for some security reason to be sure that a connection to the program is really made by the account owner. (There is a security problem if you automate login and connection because everybody having your program or access to your PC can connect to your account).
?
Here I am...
I'll try this for the login window and post results here.
?
Thanks again.
Michel.
?

[Michel]??-----Mensaje original-----
De: Carl Erikson [mailto:carlerikson@...]
Enviado el: martes, 02 de julio de 2002 22:24
Para: twsapi@...
Asunto: Re: twsapi: automated login

A hack is to send keystrokes to the login window.
Pass your username as separate keystrokes.? Then send
a tab key.? Then send your password as separate
keystrokes.? Then send a return.? There is a setting
to pre-fill the username in the .ini file (sorry, no
pre-fill for the password):

[Logon]
Username=edemo

.
.
.

If you pre-filled in the username you can just send a
tab and then the password plus a return key.? I send
characters to windows with Perl, but you can do it in
almost any language (Visual Basic, C++).

I believe you can detect when the "Accept incoming
connection" window pops up.? If that is possible you
might just be able to send the enter key to it to
accept the connection.? I haven't tried this yet.

Good luck,
Carl


To unsubscribe from this group, send an email to:
twsapi-unsubscribe@...



Your use of Yahoo! Groups is subject to the .


bee_jay_61
 

That?s why I start a new separate thread in my program to confirm
the "Accept incomming connection attempt" dialog.

First I start the thread that searches the window for about 60
seconds (or more if you need). Than I call TWS.Connect from the main
thread while the child thread has allready began his search.

This call will force the TWS to display the dialog and than the child
thread can find this window. So the main thread (main program) is
never blocked like in your case.

It is not a security feature from IB.

BeeJay




--- In twsapi@y..., "Michel" <migurull@t...> wrote:
Thanks Carl.
I've tried it in VB but it does not work. I've not tried it with
the login
window but with the 'connection confirmation' window there are
various
problems.
In my code, first I pass the focus to TWS (AppActivate) and then I
try to
send it keys (SendKey) (ENTER key in this case).
First problem is when in your code you issue a connection command
(ActiveX.connect), TWS seems to catch you in a program loop and
dont return
to your calling program until you manually click 'Yes' or 'No' in
this
window so any code after 'connect' (AppActivate and SendKeys),
simply dont
execute.
To turn around this problem, I made a separate litle application
(IBActivation.exe) which simply makes this:
1- Tempo 1 second.
2- AppActivate "Stock and options..." (this is the title of the TWS
window)
3- Tempo 1 second.
4- SendKeys "{ENTER}"
Then in my main code:
ShellExecute "IBActivation.exe"
TWS.connect
... and get a system error when IBActivation.exe tries to activate
and/or
send keys. (It works if TWS is runing normally, but not when
presenting the
'connection confirmation' window)!
So I thought this behaviour was implemented by IB for some security
reason
to be sure that a connection to the program is really made by the
account
owner. (There is a security problem if you automate login and
connection
because everybody having your program or access to your PC can
connect to
your account).

Here I am...
I'll try this for the login window and post results here.

Thanks again.
Michel.


[Michel] -----Mensaje original-----
De: Carl Erikson [mailto:carlerikson@y...]
Enviado el: martes, 02 de julio de 2002 22:24
Para: twsapi@y...
Asunto: Re: twsapi: automated login


A hack is to send keystrokes to the login window.
Pass your username as separate keystrokes. Then send
a tab key. Then send your password as separate
keystrokes. Then send a return. There is a setting
to pre-fill the username in the .ini file (sorry, no
pre-fill for the password):

[Logon]
Username=edemo

.
.
.

If you pre-filled in the username you can just send a
tab and then the password plus a return key. I send
characters to windows with Perl, but you can do it in
almost any language (Visual Basic, C++).

I believe you can detect when the "Accept incoming
connection" window pops up. If that is possible you
might just be able to send the enter key to it to
accept the connection. I haven't tried this yet.

Good luck,
Carl


David
 

开云体育

this is the way to do it considering the situation
well done
David

----- Original Message -----
From: bee_jay_61
Sent: Wednesday, July 03, 2002 8:03 PM
Subject: Re: twsapi: automated login

That?s why I start a new separate thread in my program to confirm
the "Accept incomming connection attempt" dialog.

First I start the thread that searches the window for about 60
seconds (or more if you need). Than I call TWS.Connect from the main
thread while the child thread has allready began his search.

This call will force the TWS to display the dialog and than the child
thread can find this window. So the main thread (main program) is
never blocked like in your case.

It is not a security feature from IB.

BeeJay




--- In twsapi@y..., "Michel" wrote:
> Thanks Carl.
> I've tried it in VB but it does not work. I've not tried it with
the login
> window but with the 'connection confirmation' window there are
various
> problems.
> In my code, first I pass the focus to TWS (AppActivate) and then I
try to
> send it keys (SendKey) (ENTER key in this case).
> First problem is when in your code you issue a connection command
> (ActiveX.connect), TWS seems to catch you in a program loop and
dont return
> to your calling program until you manually click 'Yes' or 'No' in
this
> window so any code after 'connect' (AppActivate and SendKeys),
simply dont
> execute.
> To turn around this problem, I made a separate litle application
> (IBActivation.exe) which simply makes this:
> 1- Tempo 1 second.
> 2- AppActivate "Stock and options..." (this is the title of the TWS
window)
> 3- Tempo 1 second.
> 4- SendKeys "{ENTER}"
> Then in my main code:
> ShellExecute "IBActivation.exe"
> TWS.connect
> ... and get a system error when IBActivation.exe tries to activate
and/or
> send keys. (It works if TWS is runing normally, but not when
presenting the
> 'connection confirmation' window)!
> So I thought this behaviour was implemented by IB for some security
reason
> to be sure that a connection to the program is really made by the
account
> owner. (There is a security problem if you automate login and
connection
> because everybody having your program or access to your PC can
connect to
> your account).
>
> Here I am...
> I'll try this for the login window and post results here.
>
> Thanks again.
> Michel.
>
>
> [Michel]? -----Mensaje original-----
> De: Carl Erikson [mailto:carlerikson@y...]
> Enviado el: martes, 02 de julio de 2002 22:24
> Para: twsapi@y...
> Asunto: Re: twsapi: automated login
>
>
>?? A hack is to send keystrokes to the login window.
>?? Pass your username as separate keystrokes.? Then send
>?? a tab key.? Then send your password as separate
>?? keystrokes.? Then send a return.? There is a setting
>?? to pre-fill the username in the .ini file (sorry, no
>?? pre-fill for the password):
>
>?? [Logon]
>?? Username=edemo
>
>?? .
>?? .
>?? .
>
>?? If you pre-filled in the username you can just send a
>?? tab and then the password plus a return key.? I send
>?? characters to windows with Perl, but you can do it in
>?? almost any language (Visual Basic, C++).
>
>?? I believe you can detect when the "Accept incoming
>?? connection" window pops up.? If that is possible you
>?? might just be able to send the enter key to it to
>?? accept the connection.? I haven't tried this yet.
>
>?? Good luck,
>?? Carl



To unsubscribe from this group, send an email to:
twsapi-unsubscribe@...



Your use of Yahoo! Groups is subject to the .


tripack44
 

No, a while back I tried that but it was a no-go with TWS. I gave it
up and finally just bought a router. Life is so much simpler now.

--- In twsapi@y..., "David" <kotomo@p...> wrote:

Also, anyone running Proxy succesfully?? (Proxy from AnalogX)
That's why I don't have the time.
David


David
 

开云体育

Thanks tripack44
this is good info...
?

----- Original Message -----
From: tripack44
Sent: Wednesday, July 03, 2002 11:57 PM
Subject: Re: twsapi: automated login

No, a while back I tried that but it was a no-go with TWS. I gave it
up and finally just bought a router. Life is so much simpler now.

--- In twsapi@y..., "David" <kotomo@p...> wrote:

> Also, anyone running Proxy succesfully?? (Proxy from AnalogX)
> That's why I don't have the time.
> David




To unsubscribe from this group, send an email to:
twsapi-unsubscribe@...



Your use of Yahoo! Groups is subject to the .


marinindextrader
 

This thread has been archived in the Bookmarks Section, within the
Board Threads Folder. From time to time exhaustive discussions that
stay on topic will be archived to this folder.

Scott


--- In twsapi@y..., "David" <kotomo@p...> wrote:
Thanks tripack44
this is good info...

----- Original Message -----
From: tripack44
To: twsapi@y...
Sent: Wednesday, July 03, 2002 11:57 PM
Subject: Re: twsapi: automated login


No, a while back I tried that but it was a no-go with TWS. I gave
it
up and finally just bought a router. Life is so much simpler now.

--- In twsapi@y..., "David" <kotomo@p...> wrote:

> Also, anyone running Proxy succesfully?? (Proxy from AnalogX)
> That's why I don't have the time.
> David



Yahoo! Groups Sponsor
ADVERTISEMENT



To unsubscribe from this group, send an email to:
twsapi-unsubscribe@y...



Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.