One of the best tools for controlling or "automating" a Java GUI application (eg TWS) is Jemmy from http://www.netbeans.org. It is designed for building automated GUI test harnesses and allows access to fields, menus etc by name. All Java so works cross platform.