Hi Folks,
Im New to Macro writing so please bear with me.
I have a simple scipt, that follows a target image around a web page, it does well and finds this target, thing is I wish to tell the mouse once it has found its target to move to another postion reletive to it, now I have read all the help files and cant figure this one out can any one help ? see code below:
Let>WW_TIMEOUT=5
LET>REPEAT=0
LABEL>REPEAT LOOP
wait>1
ADD>REPEAT,1
IF>REPEAT=100,DONE_REPEATING
GetScreenRes>sX,sY
ScreenCapture>0,0,sX,sY,D:\Desktop\AutoBot\screen.bmp
FindImagePos>D:\Desktop\AutoBot\4small.bmp,D:\Desktop\AutoBot\screen.bmp,0,1,XPos,YPos,hit
IF>hit>0
mousemove>XPos_0,YPos_0
PlayWav>D:\Desktop\AutoBot\send.wav
Endif
WaitScreenImage>D:\Desktop\AutoBot\4small.bmp,0
GOTO>REPEAT LOOP
LABEL>DONE_REPEATING
MDL>script run 100 times
// now im using "mousemove>XPos_0,YPos_0" to centre the mouse on the taget as it moves about once every 2 seconds, now there is a button that is always directly below each target (Always in the same reletive postion to the target that I would like to "Lclick" is this all possible ? cant see any offset mouse move commands or syntax to help ?
Any help would be greatly accepted
Regards
Steve
Off set mouse postion ? on target
Moderators: JRL, Dorian (MJT support)
Hi Steve,
Here are a couple ways to apply offsets to move the mouse 10 pixels down:
Gale
Here are a couple ways to apply offsets to move the mouse 10 pixels down:
Code: Select all
//Using simple expressions
Let>ywithoffset=%YPos_0%+10
MouseMove>XPos_0,ywithoffset
//Using complex expression
MouseMove>{%X_0%},{%Y_0%+10}
Gale
Now for a tweak
Ok going great,
Now if I only want a portion of my screen to be scanned for the target image how can I relate that to my Offset lines as if I use the Cords that I have added into my script the Offset does not seen to work any more, well it does but not where I want it. see below:
Let>WW_TIMEOUT=5
LET>REPEAT=0
LABEL>REPEAT LOOP
wait>1
ADD>REPEAT,1
IF>REPEAT=100,DONE_REPEATING
GetScreenRes>sX,sY
ScreenCapture>0,0,sX,sY,D:\Desktop\AutoBot\screen.bmp
//--> Cords of a portion of my screen 377,300,1082,852 to put above in the "ScreenCapture" Cords.
FindImagePos>D:\Desktop\AutoBot\twice_small.bmp,D:\Desktop\AutoBot\screen.bmp,30,1,XPos,YPos,hit
Let>FIP_SCANPIXELS=200
IF>hit>0
mousemove>XPos_0,YPos_0
Let>ywithoffset=%YPos_0%+120
MouseMove>XPos_0,ywithoffset
PlayWav>D:\Desktop\AutoBot\send.wav
Endif
WaitScreenImage>D:\Desktop\AutoBot\twice_small.bmp,30
GOTO>REPEAT LOOP
LABEL>DONE_REPEATING
MDL>I've repeated your script 100 times
Regards
Steve
Now if I only want a portion of my screen to be scanned for the target image how can I relate that to my Offset lines as if I use the Cords that I have added into my script the Offset does not seen to work any more, well it does but not where I want it. see below:
Let>WW_TIMEOUT=5
LET>REPEAT=0
LABEL>REPEAT LOOP
wait>1
ADD>REPEAT,1
IF>REPEAT=100,DONE_REPEATING
GetScreenRes>sX,sY
ScreenCapture>0,0,sX,sY,D:\Desktop\AutoBot\screen.bmp
//--> Cords of a portion of my screen 377,300,1082,852 to put above in the "ScreenCapture" Cords.
FindImagePos>D:\Desktop\AutoBot\twice_small.bmp,D:\Desktop\AutoBot\screen.bmp,30,1,XPos,YPos,hit
Let>FIP_SCANPIXELS=200
IF>hit>0
mousemove>XPos_0,YPos_0
Let>ywithoffset=%YPos_0%+120
MouseMove>XPos_0,ywithoffset
PlayWav>D:\Desktop\AutoBot\send.wav
Endif
WaitScreenImage>D:\Desktop\AutoBot\twice_small.bmp,30
GOTO>REPEAT LOOP
LABEL>DONE_REPEATING
MDL>I've repeated your script 100 times
Regards
Steve
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
You just need to add the top left position of the screen capture to whatever is returned. Hopefully this is obvious, but since it's been asked a few times I fear it isn't.
Think about it. If you capture a portion of the screen starting at position 50,50 and then look for a needle within that capture and the needle is found at position 60,60 within the haystack - which itself was taken from position 50,50 on the screen - then the screen position of the needle must be 110,110 (60 + 50, 60 + 50).
So all you need to do is add the top left coords to the result:
ScreenCapture>50,50,500,500,c:\cap.bmp
FindImagePos>needle.bmp,c:\cap.bmp,0,1,XArr,YArr,nF
Let>clickX=XArr_0+50
Let>clickY=XArr_0+50
MouseMove>clickX,clickY
LClick
In the example above we add 50 to both X and Y results because cap.bmp was a capture starting at position 50,50 on the screen and we want to end up with a screen position.
Try to realise that if you pass a BMP as a haystack to FindImagePos then FindImagePos is simply returning the relative position of located needles within that BMP. It is not to know where that BMP came from, and has no knowledge of your screen or where that BMP was on the screen if indeed it did come from your screen. Nothing in the command tells it anything about your screen. It is just looking in one image file for another.
Think about it. If you capture a portion of the screen starting at position 50,50 and then look for a needle within that capture and the needle is found at position 60,60 within the haystack - which itself was taken from position 50,50 on the screen - then the screen position of the needle must be 110,110 (60 + 50, 60 + 50).
So all you need to do is add the top left coords to the result:
ScreenCapture>50,50,500,500,c:\cap.bmp
FindImagePos>needle.bmp,c:\cap.bmp,0,1,XArr,YArr,nF
Let>clickX=XArr_0+50
Let>clickY=XArr_0+50
MouseMove>clickX,clickY
LClick
In the example above we add 50 to both X and Y results because cap.bmp was a capture starting at position 50,50 on the screen and we want to end up with a screen position.
Try to realise that if you pass a BMP as a haystack to FindImagePos then FindImagePos is simply returning the relative position of located needles within that BMP. It is not to know where that BMP came from, and has no knowledge of your screen or where that BMP was on the screen if indeed it did come from your screen. Nothing in the command tells it anything about your screen. It is just looking in one image file for another.
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?