CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Posts
    1

    Hooking into Java Application

    Hello,

    under Visual C++ there are numerous examples of hooking into
    another application, i.e. adding one's own menus to Notepad etc.

    Is there a similar thing available for Java?
    A net search has not resulted in anything useful.

    What I would like to do:
    1) Programmatically access the menu functions of a swing GUI in another 3rd party Java App for which I just have compiled classes, no source.
    I know that awt.robot can do a bit, but I am looking for more:

    2) Automatically extracting text from a Java Text Field of the 3rd party app (to repeat: I have no source code for this, therefore have to "hook" into the app from outside).
    I have seen examples for C++ on codeguru, but nothing for Java.

    3) A final challenge: adding my own menus to this 3rd party swing app. Again, possible in C++. I think impossible in Java.

    Thanks so much for your help!

    You are my last hope, literally.

    Kind regards,
    Tony

  2. #2
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104
    anything you do will be platform specific - hooking into another app in windows basically involves supplementing how windows treats the other application.. in effect, you are not hooking into the application itself, but into the windows control of it.. ordering windows to process mouseclicks on the application via some other means, for example.
    and, at the end of the day, the only way the java application can get itself drawn on the screen, is to ask windows to do it. I fired up a simple java app and succeeded in finding the main window in the windowspace (spy++) but it didnt have any child windows, so you may struggle to programmatically interact with it.

    had you had the source for the java program youre attemping to run, hooking would have been a lot easier by creating a JNI link (JNI can go both ways.. calling java from a C++ program as well as the usual vice versa)

    I would begin by using a tool such as spy++ to get a handle on the window, then watch the messages transmitted to and from it, and see if they are the regular windows messages; java may not listen to all messages, but it will need to listen to some, just to provide interaction..

    i dont think this will allow you much ability to extend the menus, but you may be able to retrieve the text from a textarea
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured