Results 1 to 4 of 4
  1. #1
    joratorio is offline Member
    Join Date
    Aug 2010
    Posts
    2
    Rep Power
    0

    Default A bot selecting windows based on their title

    Hi, I've made a bot that performs some things for me in various programs on my computer. I've made it switch between windows by using java.robot to move the cursor down to the Windows taskbar and clicking the desired window. It's not very elegant though, as I have to make sure every program is started in the right order before I run my bot. So...

    Is there a way to make my Java application switch between windows based for example on their title? The two windows I need to switch between are titled "Example.com - Mozilla Firefox" and "Administrator: cmd". I'm using Windows 7.

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

    Default

    Quote Originally Posted by joratorio View Post
    Hi, I've made a bot that performs some things for me in various programs on my computer. I've made it switch between windows by using java.robot to move the cursor down to the Windows taskbar and clicking the desired window. It's not very elegant though, as I have to make sure every program is started in the right order before I run my bot. So...

    Is there a way to make my Java application switch between windows based for example on their title? The two windows I need to switch between are titled "Example.com - Mozilla Firefox" and "Administrator: cmd". I'm using Windows 7.
    With the Java Robot class you have to go much lower level than window titles and such. The Robot class can take a snapshot of (part of) the screen which is basically a matrix (two dimensional) of ARGB values; you have to compare those values to known values to figure out what you took a snapshot of; it's callled digital image recognition.

    kind regards,

    Jos

  3. #3
    joratorio is offline Member
    Join Date
    Aug 2010
    Posts
    2
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    With the Java Robot class you have to go much lower level than window titles and such. The Robot class can take a snapshot of (part of) the screen which is basically a matrix (two dimensional) of ARGB values; you have to compare those values to known values to figure out what you took a snapshot of; it's callled digital image recognition.

    kind regards,

    Jos
    Thanks for your reply. My bot already uses a lot of image recognition for other things, but I was hoping to avoid it for this purpose. It would stop working if I change the color of the taskbar or change the fonts etc... Isn't there another class that could solve this in another way?

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,018
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by joratorio View Post
    Thanks for your reply. My bot already uses a lot of image recognition for other things, but I was hoping to avoid it for this purpose. It would stop working if I change the color of the taskbar or change the fonts etc... Isn't there another class that could solve this in another way?
    Not pre-built in Java, no; maybe you can apply some native code that call some MS Windows mysterious system calls that can supply you the information you need/want but otherwise you'd have to take the digital image processing route but it won't be easy.

    kind regarrds,

    Jos

Similar Threads

  1. i need an example of JSR179 ((Location based Ser)implementation for CDC based device
    By talk_to_vivekmishra in forum CDC and Personal Profile
    Replies: 3
    Last Post: 12-30-2010, 10:07 AM
  2. Selecting Files in a folder
    By ravjot28 in forum New To Java
    Replies: 1
    Last Post: 02-26-2010, 04:25 PM
  3. JFileChooser example (selecting a directory)
    By Java Tip in forum Java Tip
    Replies: 1
    Last Post: 02-03-2009, 01:25 PM
  4. Selecting parts of an image
    By shaungoater in forum Java 2D
    Replies: 1
    Last Post: 12-15-2007, 10:06 PM
  5. selecting a record in database
    By ramachandran in forum New To Java
    Replies: 0
    Last Post: 10-25-2007, 07:06 AM

Posting Permissions

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