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

    Getting information of another window in java...

    I was wondering if Java has the ability to get information from another window. I was using a program called AutoIt v3 Active Window Info, and it gets different information from a window such as the buttons and text fields in the window. I've included a couple of pictures to demonstrate it doing this.




    Anyone have any ideas on how to do this in Java? Thanks

  2. #2
    Join Date
    Sep 2004
    Posts
    247

    Re: Getting information of another window in java...

    I don't believe its possible to do this unless you use JNI.

  3. #3
    Join Date
    Sep 2004
    Posts
    57

    Re: Getting information of another window in java...

    So I would have to use JNI and c++ or something?

  4. #4
    Join Date
    Sep 2004
    Posts
    247

    Re: Getting information of another window in java...

    You could certainly do it using JNI and C++ to the Windows SDK.

  5. #5
    Join Date
    Apr 2003
    Location
    Los Angeles area
    Posts
    776

    Re: Getting information of another window in java...

    Isn't creating bots for the purpose of online gambling illegal?
    "The Chicken and Rice MRE is not a personal lubricant."

  6. #6
    Join Date
    Sep 2004
    Posts
    57

    Re: Getting information of another window in java...

    This is the first time I've tried messing with JNI, so from what I read I tried through together some code. I first tested out the Hello world idea and that worked fine for me. Then II took my code that worked in C++ and tried to use it with JNI, and got some errors. Here's my code, followed by the errors...

    Code:
    POINT pt;
    pt.x=200;
    pt.y=570;
    int nMaxCount = 10;
    char buff[20];
    
    HWND hWndParent;
    hWndParent = WindowFromPoint(pt);
    
    if(GetWindowText(hWndParent, buff, nMaxCount))
    	printf("%s",buff);
    else
    	printf("null");
    Code:
    HelloWorld.obj : error LNK2001: unresolved external symbol __imp__GetWindowTextA
    @12
    HelloWorld.obj : error LNK2001: unresolved external symbol __imp__WindowFromPoin
    t@8
    HelloWorldImp.dll : fatal error LNK1120: 2 unresolved externals
    Is this just not supported in JNI or what? I'm totally lost here, so any help would be greatly appreciated. Thanks!

  7. #7
    Join Date
    Sep 2004
    Posts
    57

    Re: Getting information of another window in java...

    Does anyone have any experience with GetWindowText() and other functions of that sort with JNI?

  8. #8
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Getting information of another window in java...

    Have you built a JNI DLL exporting the API functions you want to use?

    Doing more things faster is no substitute for doing the right things...
    S. R. Covey
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  9. #9
    Join Date
    Sep 2004
    Posts
    57

    Re: Getting information of another window in java...

    That's when the compiler starts to whine at me...What's weird is when I try to compile the .cpp in Visual C++ it compiles fine, but when I try to compile in the command prompt using cl, it gives me those link errors

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