Results 1 to 12 of 12
  1. #1
    lolaika is offline Member
    Join Date
    Jun 2010
    Location
    GDL MEXICO
    Posts
    6
    Rep Power
    0

    Exclamation How to localize the position on screen of a running java application?

    Hi!
    Im trying to create an application to automate a procedure...
    The thing is that I need to localize on screen a running java application, I mean the X and Y values where is positioned that app...
    but I have no idea how can I do that...
    Can someone help me? :confused:

    Thank You
    :)
    Last edited by lolaika; 06-01-2010 at 07:30 PM.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by lolaika View Post
    Hi!
    Im trying to create an application to automate a procedure...
    The thing is that I need to localize on screen a running java application, I mean the X and Y values where is positioned that app...
    but I have no idea hoy can I do that...
    Can someone help me?
    Is your application running in the same JVM? If so you can get all the frames with the Frame.getFrames() method and you're in business. If not, the other application has to cooperate a bit, e.g. it should save its frame position in a file which your application can access. Grabbing the screen image and analyzing it is a last (tedious) resort.

    kind regards,

    Jos

  3. #3
    lolaika is offline Member
    Join Date
    Jun 2010
    Location
    GDL MEXICO
    Posts
    6
    Rep Power
    0

    Default

    The application is not running in the same JVM... And I cant modify the other app ... So I guess I could use the third option, but how do I do that?

    Thanx

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    See the Robot class for how to capture the current screen.
    From that image, create a byte array and scan it.
    Grabbing the screen image and analyzing it is a last (tedious) resort.

  5. #5
    lolaika is offline Member
    Join Date
    Jun 2010
    Location
    GDL MEXICO
    Posts
    6
    Rep Power
    0

    Default

    ok, I create a byte array... But how can I identify where the app begins? Or a textfield begins? :confused:
    Last edited by lolaika; 06-01-2010 at 07:31 PM.

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by lolaika View Post
    ok, I create a byte array... But how can I identify where the app begins? Or a textfield begins? :confused:
    That's the tedious part about it: you have to do some image recognition. Don't go there, forget about it.

    kind regards,

    Jos

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Think at the pixel level. Can you tell when the pixel you are looking at is on the desktop and when it is part of a window? Perhaps in a well defined environment. In general:
    Don't go there, forget about it.

  8. #8
    lolaika is offline Member
    Join Date
    Jun 2010
    Location
    GDL MEXICO
    Posts
    6
    Rep Power
    0

    Default

    ok ok...
    I'll try to do it...
    Buy anyone hot another idea?
    How can I do it?
    :D

  9. #9
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by lolaika View Post
    ok ok...
    I'll try to do it...
    Buy anyone hot another idea?
    How can I do it?
    :D
    There is no free lunch here. Maybe a bit of C or C++ can help you out.

    kind regards,

    Jos

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    An idea on how to get some insights:
    Get a program that will display the value of pixels at the mouse when the mouse scans over an image. What color is a window's title bar. What color is the desktop. You run the cursor up and down and left and right and see where there are different colors/things.

    Better go to Google and see what's been done.

  11. #11
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Norm View Post
    An idea on how to get some insights:
    Get a program that will display the value of pixels at the mouse when the mouse scans over an image. What color is a window's title bar. What color is the desktop. You run the cursor up and down and left and right and see where there are different colors/things.

    Better go to Google and see what's been done.
    This is going to be a lost battle: the OP even wants to recognize 'the start of a text field', so even *shudder* the contents of such a field (eeww, character recognition comes to mind). Font comparisons, anti aliased rendering and all that horror; (partially) hidden characters but still present in that other application; I don't even want to think about it; I'm afraid my first advice still applies: you don't want to go there, forget about it.

    kind regards,

    Jos

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    I agree. I'd thought of doing something like what the OP wants to do but gave up. I was trying to sucker someone to doing the work as I watched. Oh well.
    I did a simple program that filled in a drawn closed shape but it only had the two colors of the shape and the background to consider and so could easily find the boundary.

Similar Threads

  1. Replies: 3
    Last Post: 01-16-2010, 07:14 PM
  2. running a java application on Japanese OS
    By yibingdong in forum Advanced Java
    Replies: 4
    Last Post: 09-09-2009, 10:01 PM
  3. Problem running a java desktop application
    By chris@gaiag.net in forum AWT / Swing
    Replies: 2
    Last Post: 08-24-2008, 04:24 AM
  4. Localize JFileChooser
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-14-2008, 11:54 AM
  5. Running a application in java
    By barney in forum Java Applets
    Replies: 1
    Last Post: 08-07-2007, 07:12 AM

Tags for this Thread

Posting Permissions

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