Java app

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Java app

Post by pgriffin » Mon Jan 09, 2006 9:54 pm

I need to write testing scripts for a Java based app. I cannot use Webrecorder to 'see' the window names/objects OR Veiw System Windows.

I am no java expert. How do I best navigate these screens, edit fields, combo boxes, etc...?

User avatar
Captive
Macro Veteran
Posts: 213
Joined: Sun Oct 20, 2002 8:37 pm
Location: Colorado, USA

Post by Captive » Mon Jan 09, 2006 10:05 pm

Depending on the applets that you will be working with, you may be able to use something as simple as MouseMoveRel to click on the same part of the window at each stage.

You can use GetRectCheckSum (GetPixelColor if it's reaaaaaly simple) to figure out what's being shown at a certain part.

Or, there's that fancy new "Image Recognition Library" you can investigate.
( http://www.mjtnet.com/imagerecognition.htm ).

It all depends on what exactly you need to do, and what the situation is.

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Mon Jan 09, 2006 10:10 pm

I am familiar with GetRectChecksum (way too slow). I can use GetPixelcolor (just chain a few of them to together) to do what I call "fingerprinting". The objects are generally going to be located in the same locations, I was just wondering if there is a tool I can use to actually use functions like (but not identical to) GetControlText, SetControlText, Pushbutton, etc....

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Mon Jan 16, 2006 2:01 pm



//Depending on system speed this script adds 10000 pixels in 6 seconds
//Desired_Color returns the value of all 10000 pixels combined from a 100 by 100 pixel area
//Adjust the X and Y positions to your needs
//let>X_Position= and let>Y_Position= are the starting positions of the search
//if>X_Position= and if>Y_Position= are the ending positions of the search

Label>Pre_Get_Color_Loop
let>X_Position=0
let>Y_Position=0
let>Desired_Color=0
GetTime>Start_Time1
Label>Get_Color_Loop
GetPixelColor>X_Position,Y_Position,Pixel_Color
add>Desired_Color,%Pixel_Color%
add>X_Position,1
if>X_Position=100
let>X_Position=0
add>Y_Position,1
if>Y_Position=100,What_Is_The_Color
endif
GoTo>Get_Color_Loop
Label>What_Is_The_Color
MessageModal>Desired_Color
if>Desired_Color=1111111,Color_Correct_Do_Something,Color_Incorrect_Do_Something_Else
Label>Color_Incorrect_Do_Something_Else
Label>Color_Correct_Do_Something


.

I agree with SkunkWorks GetRectCheckSum> is way too slow.
It takes GetRectCheckSum>0,0,100,100,Pixel_Color 20 seconds to return the value of the same area :roll:

See for your self by running the script below


Label>Pre_Get_Color_Loop
let>X_Position=0
let>Y_Position=0
let>Desired_Color=0
GetTime>Start_Time1
Label>Get_Color_Loop
GetPixelColor>X_Position,Y_Position,Pixel_Color
add>Desired_Color,%Pixel_Color%
add>X_Position,1
if>X_Position=100
let>X_Position=0
add>Y_Position,1
if>Y_Position=100,What_Is_The_Color
endif
GoTo>Get_Color_Loop
Label>What_Is_The_Color
GetTime>End_Time1
GetTime>Start_Time2
GetRectCheckSum>0,0,100,100,Pixel_Color
GetTime>End_Time2
MessageModal>Search 1 started at: %Start_Time1%%crlf%Search 1 completed at: %End_Time1%%crlf%GetRectCheckSum times%crlf%Search 2 started at: %Start_Time2%%crlf%Search 2 completed at: %End_Time2%


User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Jan 16, 2006 2:20 pm

GetRectCheckSum checks every single pixel, and uses it's position and colour, to calculate a unique checksum. That's why it's slow. It should only be used for small rectangles.

For larger areas, for image comparison or to find an image on a screen (or wait for a screen area to change) you'll get better results from the Image Recognition Library which is really fast:
http://www.mjtnet.com/imagerecognition.htm
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Mon Jan 16, 2006 2:43 pm

10000 Pixels was an extreme example to point out how much faster a simple add loop is. I normally search a much smaller area that is roughly 50 pixels and by using my add loop I keep my scripts fast.

I have played it with the Image Recognition Library and had good results.
But here is my question. If I want to use it in an exe on a client’s computer does my client have to install the Image Recognition Library? If that’s the case the Image Recognition Library is not helping me at all. It would be a hassle to tell my clients they have to download and install another piece of software to run my programs.

Thanks

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Jan 16, 2006 2:47 pm

Rain wrote:But here is my question. If I want to use it in an exe on a client’s computer does my client have to install the Image Recognition Library? If that’s the case the Image Recognition Library is not helping me at all. It would be a hassle to tell my clients they have to download and install another piece of software to run my programs.
No, just the DLL. They don't have to download anything. You can use the Image Recognition Library functions in your exe and then you just have to send your client the EXE and the DLL. With WinZip you could create a simple self extracting exe which puts both your exe and the dll into the same folder. your exe would load the DLL from the script dir:

LibLoad>%SCRIPT_DIR%\imglib.dll,ilh
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Mon Jan 16, 2006 2:53 pm

Thanks for the quick reply. I guess I should have asked a little sooner. :oops:

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Mon Jan 16, 2006 3:20 pm

this thread has been a big help. I will quickly ramp up on using the Image Lib.

I had considered the "pixel by pixel" search shown earlier, but was concerned about speed. I also thought there must be something better. One thing I have used very effectively is what I call "FingerPrint". That is pick set number of pixels (50 or so) to test for an image. Just as when a person is 'finger printed', you don't need to analyze the entire image, just need enough points to be sure of uniqueness. I think if a fingerprint system finds 10 'matches' in peculiarities of your print, it considers that a good match.

FingerPrint is super fast, can be written easily into a subroutine, and I've never mis-identified an image. (And you don't need to understand DLL's or include them in your zip, etc...)

SkunkWorks

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Jan 16, 2006 3:27 pm

SkunkWorks wrote:One thing I have used very effectively is what I call "FingerPrint". That is pick set number of pixels (50 or so) to test for an image. Just as when a person is 'finger printed', you don't need to analyze the entire image, just need enough points to be sure of uniqueness. I think if a fingerprint system finds 10 'matches' in peculiarities of your print, it considers that a good match.
The image recognition library uses a similar approach.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts