AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Java Windows / Applications

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
sl_alagappan



Joined: 03 Mar 2004
Posts: 17

PostPosted: Thu Apr 08, 2004 10:56 am    Post subject: Java Windows / Applications Reply with quote

Hi,

Will there by any chance or method to trace the controls in a java window ( i mean, java application )?
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10465

PostPosted: Thu Apr 08, 2004 1:02 pm    Post subject: Reply with quote

It seems doubtful since I think those controls aren't really controls, but rather just mouse hotspots and graphics drawn by Java. If so, there might be no way to interact with them except by using PixelGetColor and such.

On the other hand, it might be possible to do this using PostMessage, which is a command Rajat suggested. I think there are some tools out there, one of which is MS's Spy++, which allow you to watch what messages are being sent and received by various windows. Once you figure out the message, you might be able to use PostMessage to mimic it and thus avoid having to have the window active to interact with it.

Maybe Rajat can tell us what message spying software he uses (preferably a free one if there's one out there -- maybe Spy++ is free), and whether he thinks it might work with Java apps.
Back to top
View user's profile Send private message Send e-mail
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Thu Apr 08, 2004 3:00 pm    Post subject: Reply with quote

this is the best of the lot i've got:

Spy & Capture
http://come.to/kobik

free and very useful, allows posting all sorts of messages too...

and finding out messages & params is best done with girder (www.girder.nl) it has a 'Capture' feature. herein one turns it on and does normal action like pressing play button on mp3 players (like WMP). the command log of that program captures the messages posted and allows them to be reposted to mimic the action.

note: i've not tried them with java apps, so u check.
_________________
Back to top
View user's profile Send private message
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Thu Apr 08, 2004 5:00 pm    Post subject: Reply with quote

and if u want something like Spy++ then check out Winspector! much better!!

http://www.gipsysoft.com/winspector/
_________________
Back to top
View user's profile Send private message
Beastmaster
Guest





PostPosted: Fri Apr 09, 2004 12:34 pm    Post subject: Reply with quote

That damn old story Sad (to be honest that seems the same prob for all scripting tools). Therefore it would be very usefull to improve AHKs Pixel command(s) !

With another Macro Tool - I've managed to detect such "invisible" windows (if there's no info detectable with a window spy tool) by its change of a specific/unique pixel(color). Afterwards a MouseClick ...

That tool provides a command which is a mixture of AHK's PixelGetColor and PixelSearch command. It delivers an ERRORLEVEL if the specified timeout has passed. With AHK it would look similar to this:

PixelWaitColor, ColorID, X, Y, Timeout [0 to wait indefinitely]

eg. wait for a pixel on the OK-Button of a Java app
Code:
PixelColorWait, 16777215, 300, 200, 0 (to wait indefinitely)
MouseClick, Left, 300, 200


This would propably cover only a part of the isuue, but could have been accomplished with AHK's functionality.

Exclamation PixelWaitColor isn't yet implemeted within AHK Exclamation If you (also) think it would be usefull --> WishList Very Happy
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10465

PostPosted: Fri Apr 09, 2004 12:52 pm    Post subject: Reply with quote

The reason I assign low priority to request like PixelWaitColor is that it's easy to script it yourself. In this case, you could do it this way:
Code:
Loop
{
     PixelGetColor, color, 15, 20
     if color = 12345
     {
          MsgBox, The pixel is now the right color.
          break
     }
     Sleep, 100  ; Rest the CPU between cycles.
}

Adding a new command means making the help file seem more complicated and cluttered, which is another disadvantage. I do like your suggestion, I'm just trying to explain why it's a low priority in my estimation.
Back to top
View user's profile Send private message Send e-mail
Beastmaster
Guest





PostPosted: Fri Apr 09, 2004 1:25 pm    Post subject: Reply with quote

Me, myself and I confirmed. Very Happy
Cause that makes sense. Exclamation
Back to top
sl_alagappan



Joined: 03 Mar 2004
Posts: 17

PostPosted: Sat Apr 10, 2004 6:12 am    Post subject: Reply with quote

Thanks for the info given.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10465

PostPosted: Sat Apr 10, 2004 1:39 pm    Post subject: Reply with quote

The next release of AHK may have a PostMessage command (thanks to Rajat). So if you can discover what messages are received by the Java applications to trigger certain actions, you might be able to use PostMessage to automate/interact with them.
Back to top
View user's profile Send private message Send e-mail
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Sun Apr 11, 2004 12:56 pm    Post subject: Reply with quote

I've checked it out and noticed a li'l peculiarity. See if that happens with others too.
(Chris can u plz suggest the reason)

i've my desktop BG set to black. and no wallpaper. (for testing only! i'm not a freak!!)

i run the script given below.

i've run the script from a folder and its window is activated at the moment, but isn't maximised & doesn't cover the specific part of the desktop.

the particular pixel is showing and has the correct color but the msgbox doesn't come.

now when i click anywhere on desktop and activate it then the msgbox comes.

Code:
Loop
{
     PixelGetColor, color, 15, 20
     if color = 0
     {
          MsgBox, The pixel is now the right color.
          break
     }
     Sleep, 100  ; Rest the CPU between cycles.
}


the help file says "Retrieves the color of the pixel at the specified x,y screen coordinates." as it nowhere says that the co-ordinates are relative to active window, so i assume its not.
_________________
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10465

PostPosted: Sun Apr 11, 2004 1:14 pm    Post subject: Reply with quote

Yes, they're relative (I've fixed the docs to reflect this). It was done that way because everything else in AHK is relative and I didn't want to break the precedent. In hindsight, this was probably not the best decision, especially for users with high resolution screens. For example, if you have two windows displayed next to each other, PixelGetColor will fail to work if the target window is deactivated in favor of the other window. This essentially makes it necessary to keep the target window always active while waiting for a pixel (or else have to adjust the coordinates dynamically whenever another window becomes active). I hope to provide some kind of workaround fairly soon.
Back to top
View user's profile Send private message Send e-mail
Baestmaster
Guest





PostPosted: Sun Apr 11, 2004 1:19 pm    Post subject: Reply with quote

I've something similar.

An app has been minimized to the taskbar. WinActivate, WinRestore, WinMaximize seems to work fine but after the window has been maximized it still hasn't the focus (the titlebars color scheme is still grey instead of the expected blue).

Cause that script should be part of a 24/7 process - that hurts Crying or Very sad
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10465

PostPosted: Sun Apr 11, 2004 1:37 pm    Post subject: Reply with quote

Are you saying that WinActivate fails to activate that particular window? Maybe put in a WinWaitActive to be sure it's active prior to checking for a pixel color.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group