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
Problem with FindImagePos
Moderators: Dorian (MJT support), JRL
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?
Have you considered using the PushButton> function instead?
-
- Newbie
- Posts: 5
- Joined: Mon Mar 21, 2011 5:41 pm
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.
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
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
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):
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/
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
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?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Newbie
- Posts: 5
- Joined: Mon Mar 21, 2011 5:41 pm