how to change mouseposition depending on found image?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
brunop
Junior Coder
Posts: 38
Joined: Mon Dec 03, 2007 2:29 pm

how to change mouseposition depending on found image?

Post by brunop » Mon Jul 20, 2009 9:54 pm

Hi

Im using waitscreenimage to wait for a specific image to appear on the screen and when it does I want the mouse to move to a specific position depending on where this image shows up e.g. 2 cm to the right and 1 cm down.

How do i do this?

thank you in advance

Bruno

brunop
Junior Coder
Posts: 38
Joined: Mon Dec 03, 2007 2:29 pm

Post by brunop » Mon Jul 20, 2009 9:59 pm

here is my very simple script



label>start
WaitScreenImage>C:\gul haand.bmp,0
Wait>2
MouseMove>1000,44
LClick>
Wait>10
MouseMove>1201,631
lclick>
Wait>20
Goto>start



This does not take into consideration where the image pops up but only goes to a specific position on the screen regardless of where the image pops up

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Tue Jul 21, 2009 5:05 am

Hi brunop,

Something like this?

Code: Select all

label>start
Let>needle=C:\gul haand.bmp
//wait up to 20 seconds until image is found on screen
Let>WSI_TIMEOUT=20
Let>ct=0
WaitScreenImage>%needle%,%ct%
//Get coordinates of upper left corner of image.
Let>ul=0
FindImagePos>%needle%,SCREEN,%ct%,%ul%,X,Y,NumFound
Wait>2
//MouseMove>1000,44 (upper left coordinates?)
MouseMove>X_0,Y_0
LClick>
Wait>10
//MouseMove>1201,631 (2cm to right, 1cm down?)
//Move mouse so many pixels to the right and down
Let>X_0=%X_0%+200
Let>Y_0=%Y_0%+100
MouseMove>X_0,Y_0
lclick>
Wait>20
Goto>start 
Warning: untested script. No error handling.

Do you want to move 2cm to right, 1cm down regardless of monitor size and screen resolution, for example if your image is a correctly scaled ruler?

Not sure why you want the GoTo loop, does the image disappear and reappear when you click?




Gale

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