| View previous topic :: View next topic |
| Author |
Message |
sl_alagappan
Joined: 03 Mar 2004 Posts: 17
|
Posted: Thu Apr 08, 2004 10:56 am Post subject: Java Windows / Applications |
|
|
Hi,
Will there by any chance or method to trace the controls in a java window ( i mean, java application )? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10465
|
Posted: Thu Apr 08, 2004 1:02 pm Post subject: |
|
|
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 |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1717
|
Posted: Thu Apr 08, 2004 3:00 pm Post subject: |
|
|
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 |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1717
|
|
| Back to top |
|
 |
Beastmaster Guest
|
Posted: Fri Apr 09, 2004 12:34 pm Post subject: |
|
|
That damn old story (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.
PixelWaitColor isn't yet implemeted within AHK If you (also) think it would be usefull --> WishList  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10465
|
Posted: Fri Apr 09, 2004 12:52 pm Post subject: |
|
|
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 |
|
 |
Beastmaster Guest
|
Posted: Fri Apr 09, 2004 1:25 pm Post subject: |
|
|
Me, myself and I confirmed.
Cause that makes sense.  |
|
| Back to top |
|
 |
sl_alagappan
Joined: 03 Mar 2004 Posts: 17
|
Posted: Sat Apr 10, 2004 6:12 am Post subject: |
|
|
| Thanks for the info given. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10465
|
Posted: Sat Apr 10, 2004 1:39 pm Post subject: |
|
|
| 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 |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1717
|
Posted: Sun Apr 11, 2004 12:56 pm Post subject: |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10465
|
Posted: Sun Apr 11, 2004 1:14 pm Post subject: |
|
|
| 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 |
|
 |
Baestmaster Guest
|
Posted: Sun Apr 11, 2004 1:19 pm Post subject: |
|
|
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  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10465
|
Posted: Sun Apr 11, 2004 1:37 pm Post subject: |
|
|
| 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 |
|
 |
|