#!/usr/bin/perl # # from TWS Yahoo mailing list # From: Ed Peschko esp5 at pge dot com # Date: Mon, 26 Jun 2006 11:57:47 -0700 # # License: Artistic License # # This version from: http://www.trading-shim.org/faq/?autologin # Versioning added by trading-shim.org staff; comments to: # herrold@trading-shim.org please my $version = "20060707"; # # # The author (Ed Peschko) requests that if a user 'changes it in # any way, they'd let me know' at the cited address # # Needs: perl-X11-GUITest from CPAN # of which Owl River packages a SRPM at: # ftp://ftp.owlriver.com/pub/mirror/ORC/perl-X11-GUITest/ # # The author also notes: # Of course, you might have to change the offsets based on your # display because it simulates the click of a mouse to get through # dialog boxes. And of course, use at your own risk. # # TBD Query: Is it possible to inspect the content under the position # of the cursor, to determine when it is sitting on a given Login # button, and then to 'tab around' to the userid and password fields, # to remove the need for X-Y positioning? # # TBD FIXME: issue: upstream perl module has an insecure environmental, # preventing running perl with -Tw # # Insecure $ENV{PATH} while running with -T switch at # /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/X11/GUITest.pm line 545. # use strict; # use warnings; use X11::GUITest qw/ StartApp WaitWindowClose WaitWindowViewable SendKeys ClickWindow GetWindowName /; start_and_stop_tws(); sub start_and_stop_tws { my ($login_window, $welcome_window, $future_window, $content_window); # # We call the local script which starts the TWS-API 'run-tws'; # alter to local practice if needed StartApp('run-tws'); # # Wait for it to appear within 120 seconds. RegEx: .* = zero or more of # any character. (($login_window) = WaitWindowViewable('Login', undef, 120)) || die('Unable to find Login screen!'); ClickWindow($login_window); print STDERR "HERE :LOGIN:\n"; # Send some text to the editor (TEXT x NUM TIMES) # # Note that the userid, and the password are present at clear text # in this script -- be sure the script is not readible by anyone # not permitted access to your account credentials # SendKeys("edemo{TAB}demouser{TAB 3}{SPC}") || die('Unable to send text to Login screen!'); if (($welcome_window) = WaitWindowViewable('Welcome', undef, 20)) { print STDERR "HERE :WELCOME:\n"; ClickWindow($welcome_window, 328, 311); } print STDERR "HERE :FUTURE:\n"; if (($future_window) = WaitWindowViewable('Future.*', undef, 120)) { ClickWindow($future_window,200,280); } WaitWindowClose($content_window); die "Success!\n"; } # ########################################################################### #