New time user here and have a few questions about referencing screen positions and making sure you are always hitting the right co-ordinates, regardless of the end user setup (to a degree)
I will use my lates messings around with screen capturing and image searching, which I am having great success with so far.
Here is the example code (please feel free to suggest a cleaner way of doing the below or any code tips you may have.
Code: Select all
ScreenCapture>1089,252,1211,734,e:\overviewt.bmp
FindImagePos>E:\criteria1.bmp,e:\overviewt.bmp,25,1,X,Y,NumFound
Repeat>NumFound
Let>X=X_0+1136
Let>Y=Y_0+252
MouseMove>X,Y
LClick
wait>0.4
ScreenCapture>1089,252,1211,734,e:\overviewta.bmp
FindImagePos>E:\criteria2.bmp,e:\overviewta.bmp,25,1,X,Y,NumFoundt
if>NumFoundt>0
ScreenCapture>959,155,1211,247,e:\overviewte.bmp
FindImagePos>E:\target.bmp,e:\overviewte.bmp,25,1,X,Y,NumFound1
Let>X=X_0+959
Let>Y=Y_0+155
MouseMove>X,Y
Wait>0.2
LClick
endif
Let>NumFound=NumFound-1
ScreenCapture>1089,252,1211,734,e:\overviewt.bmp
FindImagePos>E:\criteria1.bmp,e:\overviewt.bmp,25,1,X,Y,NumFound
Until>NumFound=0
Firstly I am searching for said criteria 1 on the screen, when that is found then I am moving to it and clicking on it.
Then I am searching for that click on criteria 1 (the button changes colour) to make sure I have selected the correct one (this is needed as sometimes the position of the button changes between when it is found and when the mouse moves and clicks on it, else I would hit the wrong button).
If it finds that it did indeed select the right item, it then performs the final action (the target.bmp search).
If all goes to plan correctly, then it finishes and does a final search for criteria 1.
It will continue to do this until Criteria 1 is no longer matched.
Now what I would like to be able to do, since as you can see above when it takes a screen capture, using those co-ordinates it is from a full screen.
Can you pass the same commands based on relative position to the active window?
This would make it a much more flexible program, as you can see from above i would only need to manually move my focused window and it would break the macro.
So come on macro guru's show my thy wisdom on this matter as I have tried searching and cannot find it mentioned anywhere?
Also, how do I make sure that my window that I am using always remains focused or on top?
Do I just need to run that into a consistant command in this macro? Or perhaps a seperate macro that keeps the window focused or runs the focus command every 30 seconds or so to make sure nothing interrupts it?
Oh and is there class support or function support creation in MS yet? If not I can see already that being able to create functions would certainly be very very helpfull. That way you could re-use them easily down the track.
If you cannot do this how do you guys get around it currently? Perhaps by tying this in with another programming language?
C# maybe?
Sorry for all the questions just trying to understand MS a bit more
Regards
Marc
[/code]