Sign in to follow this  
Followers 0
packrat

How to work with Java SunAwtDialog class windows?

7 posts in this topic

In automating some commercial software written in Java, I've run into an interesting problem that I can't seem to solve, so I'm asking for collective advice:

The Java software occasionally pops up windows that I want to use WinWaitActive with, rather than using a "blind" timer (via the Sleep command) that waits for a given amount of time before proceeding. The AU3Info tool indicates the title of the window and also the fact that its class is "SunAwtDialog", but does not indicate any of the text that appears in the window (so I've had to do a little pixel OCR to figure out critical textual info).

I may be mistaken (and here's where the collective mind comes in), but I was under the impression that, if AU3Info could read the title of a window, so could AutoIt. However, AutoIt seems NOT to be able to read the titles of SunAwtDialog windows, because, when I use WinWaitActive (or WinWaitNotActive) with SunAwtDialog window titles, my AutoIt scripts hang at that point. If I substitute a Sleep command for the WinWait... commands, the scripts work fine. Since WinWait... commands would make my scripts more reliable and stable (rather than being affected by system response time vagaries that could make timers unreliable), I really want to use that approach. The WinWait... commands work with other windows automated by the script, just not with SunAwtDialog windows.

Does anyone have any explanations or solutions or workarounds? Thanks!

Harvey

Share this post


Link to post
Share on other sites



kind of a dumb workaround but you could use "PixelChecksum ( left, top, right, bottom [, step] )" in a loop in order to determine when the window is opened, I have had to do this before for apps that have fake windows in fake windows. This is a N00B workaround though, just saw nobody posting :rolleyes:

Share this post


Link to post
Share on other sites

@packrat -- I've ran into similar trouble trying to control java applets with autoit and have become frustrated with AutoIt Info being able to see controls but ControlCommand and ControlClick having no effect on those controls. Trying to find an answer to my problems I found this thread and thought I'd share the code I use to wait for my java applet to load before clicking the next step. Maybe you'll find some value in this.

Also if any of the Autoit gurus can help us noobs find a better way controling our java classes/controls that would be greatly appreciated. And if there's a better/cleaner way of coding the following that feedback would be appreciated too!

Summary:

after java applet has been launced

loop until Title meets condition set

close any extra IE windows that may popup due to clicking the java logo as the applet loads

While 1
    If WinExists("WINDOW TITLE", "WINDOW TEXT") Then
        ExitLoop
    Else
        WinActivate("WINDOW TITLE", "WINDOW TEXT")
        Sleep(9000)
        MouseClick("left", 120, 300, 1)  ;~ Select Menu Item from java applet menu
        Sleep(1000)
        ContinueLoop
    EndIf
WEnd
If WinExists("java.com", "") Then
    WinClose("java.com", "")
EndIf

@danwilli -- can you share an example of the pixchecksum you talked about?

Thanks!

...

Share this post


Link to post
Share on other sites

@danwilli -- thanks for suggesting the PixelCheckSum command. After reading the help and playing around with the example command I was able to use this nifty feature. Not only did it cut down on the number of lines I was using, but its way more reliable than what I had been using before.

My code went from this:

While 1
    If WinExists("WINDOW TITLE", "WINDOW TEXT") Then
        ExitLoop
    Else
        WinActivate("WINDOW TITLE", "WINDOW TEXT")
        Sleep(9000)
        MouseClick("left", 120, 300, 1)  ;~ Select Menu Item from java applet menu
        Sleep(1000)
        ContinueLoop
    EndIf
WEnd
If WinExists("java.com", "") Then
    WinClose("java.com", "")
EndIfoÝ÷ ÚÚ-+ºÚ"µÍÜ
    ][ÝÔ^[ÛÛÜ[ÙI][ÝËBÌÍØÚXÚÜÝ[HH^[ÚXÚÜÝ[JLLMÌLÌ
BÚ[H   ÌÍØÚXÚÜÝ[HH^[ÚXÚÜÝ[JLLMÌLÌ
BÛY
L
BÑ[ÛY
L
B[ÝÙPÛXÚÊ  ][ÝÛY ][ÝËLÌJHßÙ[XÝY[H][HÛH]H]Y[BÛY

...

Share this post


Link to post
Share on other sites

@danwilli -- thanks for suggesting the PixelCheckSum command. After reading the help and playing around with the example command I was able to use this nifty feature. Not only did it cut down on the number of lines I was using, but its way more reliable than what I had been using before.

My code went from this:

While 1
    If WinExists("WINDOW TITLE", "WINDOW TEXT") Then
        ExitLoop
    Else
        WinActivate("WINDOW TITLE", "WINDOW TEXT")
        Sleep(9000)
        MouseClick("left", 120, 300, 1)  ;~ Select Menu Item from java applet menu
        Sleep(1000)
        ContinueLoop
    EndIf
WEnd
If WinExists("java.com", "") Then
    WinClose("java.com", "")
EndIfoÝ÷ ÚÚ-+ºÚ"µÍÜ
    ][ÝÔ^[ÛÛÜ[ÙI][ÝË BÌ ÍØÚXÚÜÝ[HH^[ÚXÚÜÝ[J  LL MÌ LÌ
BÚ[H    Ì ÍØÚXÚÜÝ[HH^[ÚXÚÜÝ[J  LL MÌ LÌ
BÛY
L 
BÑ[ÛY
L 
B[ÝÙPÛXÚÊ    ][ÝÛY    ][ÝË L  Ì  JHßÙ[XÝY[H][HÛH]H]Y[BÛY

...

Hi All,

The above solution doesn't work in my case since the pop up size is getting varied and i need to perform some action on the "SunAWTdialog" class pop up. is there any other solution available?

Thanks and Regards,

Ilaya.M

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0