Please help a newbie! WaitScreenImage Issues

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
cfry1986
Newbie
Posts: 4
Joined: Wed Oct 14, 2015 2:16 pm

Please help a newbie! WaitScreenImage Issues

Post by cfry1986 » Wed Oct 14, 2015 2:20 pm

Hi everyone,

I used to play with coding a long time ago, and am only just getting back into it now... I've written the below code, and it works perfect on the laptop that I coded it on! I compiled the exe, transfered it along with the image folder to another machine to test and it does nothing at all! The other comp is a diff version of windows, and a diff screen resolution but I didn't think that should make a difference?

I've even tried screenshotting the images from the other computer for the script to look for, thinking that might fix it, but it hasn't made any difference!

Any advice would be massively appreciated.

Kind Regards,
Chris

Code: Select all

Label>start

Let>FIP_SCANPIXELS=ALL

WaitScreenImage>%SCRIPT_DIR%\images\2.bmp,CCOEFF


Label>clickerstart

Random>12,result
Add>result,1

FindImagePos>%SCRIPT_DIR%\images\%result%.bmp,SCREEN,0,1,X,Y,NumFound,CCOEFF
If>NumFound>0
MouseMove>X_0,Y_0
LClick
Wait>3

Endif

FindImagePos>%SCRIPT_DIR%\images\exit.bmp,SCREEN,0,1,X,Y,NumFound,CCOEFF
If>NumFound>0
MouseMove>X_0,Y_0
LClick
Goto>start
Endif
Goto>clickerstart

cfry1986
Newbie
Posts: 4
Joined: Wed Oct 14, 2015 2:16 pm

Re: Please help a newbie! WaitScreenImage Issues

Post by cfry1986 » Wed Oct 14, 2015 2:31 pm

UPDATE

I've now got it working on the other computer, but I did have to take screenshots from that machine for the macro to search for... Is there anyway of making it so one set of images will be recognised across all or at least the majority of screen resolutions?

Kind Regards,
Chris

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Re: Please help a newbie! WaitScreenImage Issues

Post by armsys » Wed Oct 14, 2015 10:38 pm

Please try:

Code: Select all

// MA := MatchAlgorithm
Let>MA=0.3
Let>WSI_TIMEOUT=2
// --------------------------
Label>start
Let>FIP_SCANPIXELS=ALL
WaitScreenImage>%SCRIPT_DIR%\images\2.bmp,CCOEFF,MA
MDL>WSI_RESULT
// --------------------------
Label>clickerstart
Random>12,result
Add>result,1
FindImagePos>%SCRIPT_DIR%\images\%result%.bmp,SCREEN,0,1,X,Y,NumFound,CCOEFF,MA
If>NumFound>0
MouseMove>X_0,Y_0
LClick
Wait>3
Endif
FindImagePos>%SCRIPT_DIR%\images\exit.bmp,SCREEN,0,1,X,Y,NumFound,CCOEFF,MA
If>NumFound>0
MouseMove>X_0,Y_0
LClick
Goto>start
Endif
Goto>clickerstart

cfry1986
Newbie
Posts: 4
Joined: Wed Oct 14, 2015 2:16 pm

Re: Please help a newbie! WaitScreenImage Issues

Post by cfry1986 » Wed Oct 14, 2015 10:48 pm

Hi armsys,

Really appreciate the response, I will take a proper look tomorrow as I am about to goto bed but thanks again for the reply!

From a quick glance, "Let>WSI_TIMEOUT=2" will that end the macro if it does not detect the image in 2 seconds? It could take longer before the image is displayed on the screen is my only concern?

The end code you suggest:

Code: Select all

Goto>start
Endif
Goto>clickerstart
If the loop goes back to "start" but 2.bmp as already been detected and click on, which will change the look of the image making it undetectable again, that will also stop the script?

I appreciate your help and assistance, just wanted to double check! I will take your suggestions and try them tomorrow.

Kind Regards,
Chris

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Re: Please help a newbie! WaitScreenImage Issues

Post by armsys » Wed Oct 14, 2015 11:51 pm

Hi Chris,
cfry1986 wrote:From a quick glance, "Let>WSI_TIMEOUT=2" will that end the macro if it does not detect the image in 2 seconds? It could take longer before the image is displayed on the screen is my only concern?
Correct. You may consider the following change:

Code: Select all

// MA := MatchAlgorithm
Let>MA=0.2
Let>WSI_TIMEOUT=3
// --------------------------
Label>start
Let>FIP_SCANPIXELS=ALL
WaitScreenImage>%SCRIPT_DIR%\images\2.bmp,CCOEFF,MA
If>WSI_RESULT=0
  MDL>No image match is found. Sorry!
  Exit
Endif
cfry1986 wrote:If the loop goes back to "start" but 2.bmp as already been detected and click on, which will change the look of the image making it undetectable again, that will also stop the script?
The above code should stop/exit immediately if 2.bmp isn't detected within 2 seconds.

cfry1986
Newbie
Posts: 4
Joined: Wed Oct 14, 2015 2:16 pm

Re: Please help a newbie! WaitScreenImage Issues

Post by cfry1986 » Thu Oct 15, 2015 1:17 pm

Hi armsys,

Thanks again for your help! The code will still only work on the resolution that the images were cropped from the screenshot on. I guess my best solution although it is a lot of work, is to make a set of images for each screen resolution then use the code to detect the resolution and point to the correct images?

Is it possible to embed the image graber code into my script, so that the user selects the images the first time they are displayed themselves, and then they are saved for future instances?

Kind Regards,
Chris

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Re: Please help a newbie! WaitScreenImage Issues

Post by armsys » Thu Oct 15, 2015 10:27 pm

Hi Chris,
Appreciate your feedback.
cfry1986 wrote:...although it is a lot of work, is to make a set of images for each screen resolution...
Please try:

Code: Select all

// Capture a screen image
GetScreenRes>Width,Height
ScreenCapture>0,0,Width,Height,C:\Temp\Test.bmp
After repeated experiments, I found that storing .bmp on disk is a faster and more reliable solution to meet your requirement.
Hope it helps.
Best regards,
ArmSys

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