I have 2 questions i hope you guys help me with

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

levelcap
Newbie
Posts: 17
Joined: Sat Sep 01, 2018 8:26 am

I have 2 questions i hope you guys help me with

Post by levelcap » Sat Sep 01, 2018 8:34 am

First of all good morning/evening to all!

my 1st question is I want to make the script to keep looking for an image I chose until it appears then continue with the script and I'm wondering how to do it

my 2nd question is I want the script to run in my 2nd windows 10 desktop screen without disturbing my mouse cursor, here's a picture of what I mean
222222222.png
I want to do that so I can continue on with my normal tasks in the 1st desktop screen

Thanks guys

User avatar
Marcus Tettmar
Site Admin
Posts: 7393
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: I have 2 questions i hope you guys help me with

Post by Marcus Tettmar » Sat Sep 01, 2018 11:45 am

To answer question 1, just use the WaitScreenImage function.

For question 2 - if your script needs to focus windows, move the mouse and/or send keystrokes, then what you want to do is impossible. You would need to run the macro on a separate PC or in a Virtual Machine. E.g. you could use VirtualBox or VirtualPC or Parallels or similar.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

levelcap
Newbie
Posts: 17
Joined: Sat Sep 01, 2018 8:26 am

Re: I have 2 questions i hope you guys help me with

Post by levelcap » Sat Sep 01, 2018 4:53 pm

ok so WaitScreenImage>something something .png

how can i make it click on that image like the normal FindImagePos

User avatar
Marcus Tettmar
Site Admin
Posts: 7393
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: I have 2 questions i hope you guys help me with

Post by Marcus Tettmar » Sat Sep 01, 2018 5:21 pm

The same way. WaitScreenImage returns the found position. Or use FindImagePos after it. Or use FindImagePos in a loop. Which is exactly what WaitScreenImage is - FindImagePos in a loop.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

levelcap
Newbie
Posts: 17
Joined: Sat Sep 01, 2018 8:26 am

Re: I have 2 questions i hope you guys help me with

Post by levelcap » Sat Sep 01, 2018 7:47 pm

Marcus Tettmar wrote:
Sat Sep 01, 2018 5:21 pm
The same way. WaitScreenImage returns the found position. Or use FindImagePos after it. Or use FindImagePos in a loop. Which is exactly what WaitScreenImage is - FindImagePos in a loop.
like this?
WaitScreenImage>C:\Users\x\Desktop\Capture22.PNG,0,CCOEFF
FindImagePos>C:\Users\x\Desktop\Capture22.PNG,SCREEN,0,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif

this will make the script wait for the image to appear?

User avatar
Marcus Tettmar
Site Admin
Posts: 7393
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: I have 2 questions i hope you guys help me with

Post by Marcus Tettmar » Sat Sep 01, 2018 7:49 pm

Yes, but the FindImagePos is unnecessary since you can return the found position from WaitScreenImage. Read the WaitScreenImage topic in the help file!
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

levelcap
Newbie
Posts: 17
Joined: Sat Sep 01, 2018 8:26 am

Re: I have 2 questions i hope you guys help me with

Post by levelcap » Sat Sep 01, 2018 8:05 pm

oh ok thanks
how can i make the script find the exact image? because sometimes if it didn't appear yet it clicks on an icon that is not even similar to it
should tolerance go to 0 or go to 1

i also get this error


Error in : testtt
Line: 7 - Invalid Numeric Value for MouseMove command.

this is my script

//Wait for
WaitScreenImage>C:\Users\x\Desktop\fuel.PNG,0,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
endif

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: I have 2 questions i hope you guys help me with

Post by ocnuybear » Mon Sep 03, 2018 7:05 am

Try this code:

Code: Select all

Let>x=0
Let>Timeout=10
While>x<%Timeout%
  Let>x=x+1
  FindImagePos>C:\Users\x\Desktop\fuel.PNG,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
  If>NumFound>0
    Let>x=%Timeout%
    MouseMove>XArr_0,YArr_0
    LClick
    //Input>,Image found at Center of this Location,X=%XArr_0% Y=%YArr_0%
  EndIf
EndWhile
If>NumFound=0
  Input>Image was not found
EndIf

levelcap
Newbie
Posts: 17
Joined: Sat Sep 01, 2018 8:26 am

Re: I have 2 questions i hope you guys help me with

Post by levelcap » Mon Sep 03, 2018 8:25 am

ocnuybear wrote:
Mon Sep 03, 2018 7:05 am
Try this code:

Code: Select all

Let>x=0
Let>Timeout=10
While>x<%Timeout%
  Let>x=x+1
  FindImagePos>C:\Users\x\Desktop\fuel.PNG,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
  If>NumFound>0
    Let>x=%Timeout%
    MouseMove>XArr_0,YArr_0
    LClick
    //Input>,Image found at Center of this Location,X=%XArr_0% Y=%YArr_0%
  EndIf
EndWhile
If>NumFound=0
  Input>Image was not found
EndIf
the script isn't waiting enough
I tried to modify the timeout to 20 and it still says no image found in just 7 or 8 seconds

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: I have 2 questions i hope you guys help me with

Post by ocnuybear » Mon Sep 03, 2018 8:33 am

Where did you get the 'fuel.PNG' file from?

Also make sure you have used the correct path to the image file.

Can you please try and capture the file with the Image Capture Tool under Tools menu, 7th option from the top?

MS is very sensitive with the images it finds and must be created with this tool otherwise it will most likely fail.

levelcap
Newbie
Posts: 17
Joined: Sat Sep 01, 2018 8:26 am

Re: I have 2 questions i hope you guys help me with

Post by levelcap » Mon Sep 03, 2018 10:59 am

ocnuybear wrote:
Mon Sep 03, 2018 8:33 am
Where did you get the 'fuel.PNG' file from?

Also make sure you have used the correct path to the image file.

Can you please try and capture the file with the Image Capture Tool under Tools menu, 7th option from the top?

MS is very sensitive with the images it finds and must be created with this tool otherwise it will most likely fail.
the paths are correct don't worry
I found a way around this problem by using wait command and now it instantly clicks on whatever i want

now comes another problem I didn't think of

there are 6 pictures of fuel.png(cars) in the screen for the script to chose
here comes the problem:
script chooses car1 for 10 minutes then it will choose car 2 until car 1 is ready(that's because the script checks for pictures in a pattern) and I don't want that to happen
what I want to do is to make the script understands that if you chose a picture from the 6 you have to keep clicking that picture until it's no longer there in that position THEN it can continue to look for another picture

there are commands that I typed after the first fuel command and I have the script in a loop so idk how I can coordinate my idea in it.
any ideas?

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: I have 2 questions i hope you guys help me with

Post by ocnuybear » Mon Sep 03, 2018 11:04 am

Can we see your script please?

levelcap
Newbie
Posts: 17
Joined: Sat Sep 01, 2018 8:26 am

Re: I have 2 questions i hope you guys help me with

Post by levelcap » Mon Sep 03, 2018 12:06 pm

ocnuybear wrote:
Mon Sep 03, 2018 11:04 am
Can we see your script please?
//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
Label>start
Let>x=0
Let>Timeout=10
While>x<%Timeout%
Let>x=x+1
FindImagePos>C:\Users\x\Desktop\fuel.PNG,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
Let>x=%Timeout%
MouseMove>XArr_0,YArr_0
LClick
//Input>,Image found at Center of this Location,X=%XArr_0% Y=%YArr_0%
EndIf
EndWhile
If>NumFound=0
Input>Image was not found
EndIf


Let>x=0
Let>Timeout=10
While>x<%Timeout%
Let>x=x+1
FindImagePos>C:\Users\x\Desktop\play.PNG,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
Let>x=%Timeout%
MouseMove>XArr_0,YArr_0
LClick
//Input>,Image found at Center of this Location,X=%XArr_0% Y=%YArr_0%
EndIf
EndWhile
If>NumFound=0
Input>Image was not found
EndIf

Wait>1

Let>x=0
Let>Timeout=10
While>x<%Timeout%
Let>x=x+1
FindImagePos>C:\Users\x\Desktop\close.PNG,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
Let>x=%Timeout%
MouseMove>XArr_0,YArr_0
LClick
//Input>,Image found at Center of this Location,X=%XArr_0% Y=%YArr_0%
EndIf
EndWhile
If>NumFound=0
Input>Image was not found
EndIf

Wait>1

Let>x=0
Let>Timeout=10
While>x<%Timeout%
Let>x=x+1
FindImagePos>C:\Users\x\Desktop\close.PNG,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
Let>x=%Timeout%
MouseMove>XArr_0,YArr_0
LClick
//Input>,Image found at Center of this Location,X=%XArr_0% Y=%YArr_0%
EndIf
EndWhile
If>NumFound=0
Input>Image was not found
EndIf

Wait>1

Let>x=0
Let>Timeout=20
While>x<%Timeout%
Let>x=x+1
FindImagePos>C:\Users\x\Desktop\close.PNG,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
Let>x=%Timeout%
MouseMove>XArr_0,YArr_0
LClick
//Input>,Image found at Center of this Location,X=%XArr_0% Y=%YArr_0%
EndIf
EndWhile
If>NumFound=0
Input>Image was not found
EndIf
Wait>1

Goto>start

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: I have 2 questions i hope you guys help me with

Post by ocnuybear » Mon Sep 03, 2018 12:18 pm

what I want to do is to make the script understands that if you chose a picture from the 6 you have to keep clicking that picture until it's no longer there in that position THEN it can continue to look for another picture
Must MS keep clicking on Picture 1 until the picture disappears or just moves to different location on screen?

levelcap
Newbie
Posts: 17
Joined: Sat Sep 01, 2018 8:26 am

Re: I have 2 questions i hope you guys help me with

Post by levelcap » Mon Sep 03, 2018 12:30 pm

ocnuybear wrote:
Mon Sep 03, 2018 12:18 pm
what I want to do is to make the script understands that if you chose a picture from the 6 you have to keep clicking that picture until it's no longer there in that position THEN it can continue to look for another picture
Must MS keep clicking on Picture 1 until the picture disappears or just moves to different location on screen?
keeps clicking untill it disappears then it looks for another one

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