I'm not too sure of the correct terminology here as it's been a few years since I last wrote a macro that had to consider screen resolutions and even then it was through more luck than judgement.
So I've written a macro that works perfectly on my PC but others are saying that it stops at a particular point on their PC's. It sounds like it might be stopping at the point it's using WaitPixelColor>0,1037,711,500
Essentially in a program I'm trying to automate when a file has finished loading in it, the background to a particular part of the application window turns black (until then it's a dark grey). I've set such a long time out because some of the files are very large and can take a couple of minutes to load in.
Earlier in the macro I maximise the application to full screen anyway so even if the coordinates are screen res rather than application specific they should be pretty much the same and they don't need to be pixel accurate anyway. My laptop is running at 1920x1080 but if someone is using a different resolution then those coordinates will be looking at a different position. I know I can detect the screen resolution but I can't work out how I would then convert the coordinates at my resolution to that of another resolution so that it looks at the same place regardless of screen resolution. Does that make sense or am I massively over complicating things?
WaitPixelColor & Screen Resolution
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: WaitPixelColor & Screen Resolution
Yeh, this isn't going to be portable.
Have you thought about using WaitScreenImage instead, which might be a little more portable (using CCOEFF).
https://www.mjtnet.com/manuals/v15/HTML ... image.html
Have you thought about using WaitScreenImage instead, which might be a little more portable (using CCOEFF).
https://www.mjtnet.com/manuals/v15/HTML ... image.html
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?
- Dorian (MJT support)
- Automation Wizard
- Posts: 1414
- Joined: Sun Nov 03, 2002 3:19 am
Re: WaitPixelColor & Screen Resolution
All other things being equal, my method below also might be worth trying.
I just successfully experimented with it on my two laptops. Wrote it on a 3840x2160 one, successfully ran it on a 1366x768 one. I have edited it to meet your criteria.
Of course things could also be being thrown off by colour schemes or text size... so if it's possible to get anything that might be a constant and work out the mouse position in relation to that. If the black area is quite large you might even have a lot of leeway.
I just successfully experimented with it on my two laptops. Wrote it on a 3840x2160 one, successfully ran it on a 1366x768 one. I have edited it to meet your criteria.
Of course things could also be being thrown off by colour schemes or text size... so if it's possible to get anything that might be a constant and work out the mouse position in relation to that. If the black area is quite large you might even have a lot of leeway.
Code: Select all
//Compensating for differing display resolutions for use with WaitPixelColor
//Known, working resolution (1920x1080)
Let>OldResX=1920
Let>OldResY=1080
//Known, working coordinates
Let>OldX=1037
Let>OldY=711
//Get new screen res
GetScreenRes>ScreenX,ScreenY
//Calculate the ratio
Let>XRatio=ScreenX/OldResX
Let>YRatio=ScreenY/OldResY
//Calculate the new coordinates
Let>NewX=OldX*XRatio
Let>NewY=OldY*YRatio
//Make coords integers
Let>NewX={int(%NewX%)}
Let>NewY={int(%NewY%)}
WaitPixelColor>0,NewX,NewY,500
Re: WaitPixelColor & Screen Resolution
Thank you both for your replies.
I think I may have found a way of doing this with image recognition but I really like that script for converting screen resolutions and that has given me an idea to adapt another macro which can only work with mouse movements and is always falling over when someone changes the resolution so many, many thanks for that!
I think I may have found a way of doing this with image recognition but I really like that script for converting screen resolutions and that has given me an idea to adapt another macro which can only work with mouse movements and is always falling over when someone changes the resolution so many, many thanks for that!
- Dorian (MJT support)
- Automation Wizard
- Posts: 1414
- Joined: Sun Nov 03, 2002 3:19 am
Re: WaitPixelColor & Screen Resolution
You're welcome. Just make sure to convert any results to an integer, otherwise things won't work as expected. I'd be interested to know how it works out, as it's not something I have tried before.