Problem with FindImagePos

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
melsonmelvin
Newbie
Posts: 5
Joined: Mon Mar 21, 2011 5:41 pm

Problem with FindImagePos

Post by melsonmelvin » Mon Mar 21, 2011 5:46 pm

Hello everyone, i have a little problem,

At the moment i am automating something and the script needs to click on a button, but the button moves sometimes.

This script i have at he moment:

wait>1
mousemove>759,294
lclick
wait>1
WaitScreenImage>C:\Users\Melvin\Documents\Garage.bmp,0
mousemove>638,298
lclick
FindImagePos>C:\Users\Melvin\Documents\moeilijk.bmp,SCREEN,20,1,Xpos,YPos

Mousemove>%XPos%,%YPos%
lclick

Can someone help me with this issue?

Melvin
Hey

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Mar 21, 2011 9:45 pm

You have not indicated what problem you might be experiencing. You state that the button moves. FindImagePos> should help with that. So in what way is FindImagePos failing for you? Have you tried a short wait between the mousemove and the LClick?

Have you considered using the PushButton> function instead?

melsonmelvin
Newbie
Posts: 5
Joined: Mon Mar 21, 2011 5:41 pm

Post by melsonmelvin » Mon Mar 21, 2011 10:29 pm

Ow sorry, the problem is that i get a commandline error, Invalid Nummeric Value for MouseMove command.
Hey

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Mar 22, 2011 12:05 am

Sounds like your image isn't being found. Or.. oops just noticed you're using teh wrong variable output.

Try sticking a modal message in the script to see what result you're getting from the findimagepos. Numfound is a variable created by the function. It needs to be 1 or greater. The result of the variables you've defined will be XPos_0 and YPos_0.

Code: Select all

wait>1 
mousemove>759,294 
lclick 
wait>1 
WaitScreenImage>C:\Users\Melvin\Documents\Garage.bmp,0 
mousemove>638,298 
lclick 
FindImagePos>C:\Users\Melvin\Documents\moeilijk.bmp,SCREEN,20,1,Xpos,YPos 

MDL>%XPos_0%,%YPos_0%,%numfound%

Mousemove>%XPos_0%,%YPos_0% 
lclick 

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

Post by Marcus Tettmar » Tue Mar 22, 2011 7:33 am

First, the NumFound return variable is missing from the FindImagePos line. Second were it there you would want to check it before attempting to click on XPos_0,YPos_0 which would not exist (be non numeric) if an image was not found (thus cause an error):

Code: Select all

FindImagePos>C:\Users\Melvin\Documents\moeilijk.bmp,SCREEN,20,1,Xpos,YPos,NumFound
If>NumFound>0
  MouseMove>%XPos_0%,%YPos_0%
Else
  MessageModal>I did not find the needle image
Endif
Suspect your bmp is not being found. Make sure you use the built in image capture tool. Make sure you're calling FindImagePos at the right time (i.e. when the image you want to find is there ... e.g. if the app's screen hasn't fully loaded yet then you won't find it ... so maybe use WaitScreenImage on the same image first ...)

Take a look at:
http://www.mjtnet.com/blog/2009/02/13/i ... -mistakes/
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

melsonmelvin
Newbie
Posts: 5
Joined: Mon Mar 21, 2011 5:41 pm

Post by melsonmelvin » Tue Mar 22, 2011 11:15 am

First of all, thanx for the reply`s ill try them as soon as possible:)


It worked! Now the finishing touches to my script.
Hey

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