same image different locations

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
KiKAS
Newbie
Posts: 7
Joined: Sat Dec 07, 2019 10:41 am

same image different locations

Post by KiKAS » Tue Jun 23, 2020 4:34 am

i have 3 questions if someone can help me or guide me to a topic, first one is that i have 1 image that leads to different locations what i want to do is when it finds the first location do something and then don't click on it again and so on until it click them all and exit.
second question if i want to click a button number of times but this button changes the number of clicks that i can do every time ex (first time the button needs to be clicked 25 times second time it only need to be clicked 10 times and so on)
third question how to assign image to a variable?

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1385
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: same image different locations

Post by Dorian (MJT support) » Tue Jun 23, 2020 8:53 am

Are you able to provide screenshots and more detailed explanations so that we might be able to understand more clearly?
Yes, we have a Custom Scripting Service. Message me or go here

KiKAS
Newbie
Posts: 7
Joined: Sat Dec 07, 2019 10:41 am

Re: same image different locations

Post by KiKAS » Tue Jun 23, 2020 10:41 am

Dorian (MJT support) wrote:
Tue Jun 23, 2020 8:53 am
Are you able to provide screenshots and more detailed explanations so that we might be able to understand more clearly?
Ok i am trying to press a button number of times but the amount of clicks are not the same every time like you see in the image first time it needed 25 clicks second time it needed 22 clicks
this is what i did :
//Find and Left Click Center of
Let>RecommendedFound=FALSE
While>RecommendedFound=FALSE
FindImagePos>C:\Users\KiKAS\Desktop\pics for last shelter\Adcanced\Recomended Donation.bmp,WINDOW:Screen One,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,{%YArr_0%+10}
LClick
Let>RecommendedFound=TRUE
Wait>2
Let>Donating=0
Repeat>Donating
Let>Donating=Donating+1
MouseMoveRel>286,773
LClick
Wait>0.5
Until>Donating=25
notice that this clicks 25 no matter what is their a way to make it click the exact number of times the button needs,
and i want to know how to assign image to variable so i can repeat the variable
i will try to show you what i mean
Let>KK=Pic
Repeat>Pic
mousemove>XArr_0,YArr_0
Lclick
wait>0.5
Until>Pic=0
what i mean here if the image is visible move mouse and lclick on it and repeat the command until you cant see the image exit

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1385
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: same image different locations

Post by Dorian (MJT support) » Tue Jun 23, 2020 11:34 am

Maybe you don't have to count at all. I notice on the 22/25 image you have a timer (00:19:54) at the bottom - does that disappear when you've completed all 25? If so, and if the ":" is always in the exact same position, can you monitor that pixel colour so the script clicks the button if the : is there (those pixels are grey) and doesn't if there's no timer. You could also use Image Recognition to only click if the ":" or "0:" are visible.

If you do have to count, then it's actually quite tricky, because the 22/25 and 25/25 images don't differ in any other way - no different colours, nothing greyed out. No visual clues except for the 22/25 and the 25/25 (and the timer) - none of which will probably be "grabbable" text. Maybe try the OCR Wizard on that tiny 22/25 area to see if it can read the numbers. If they can, that might be a good starting point.
Yes, we have a Custom Scripting Service. Message me or go here

KiKAS
Newbie
Posts: 7
Joined: Sat Dec 07, 2019 10:41 am

Re: same image different locations

Post by KiKAS » Tue Jun 23, 2020 12:08 pm

Dorian (MJT support) wrote:
Tue Jun 23, 2020 11:34 am
Maybe you don't have to count at all. I notice on the 22/25 image you have a timer (00:19:54) at the bottom - does that disappear when you've completed all 25? If so, and if the ":" is always in the exact same position, can you monitor that pixel colour so the script clicks the button if the : is there (those pixels are grey) and doesn't if there's no timer. You could also use Image Recognition to only click if the ":" or "0:" are visible.

If you do have to count, then it's actually quite tricky, because the 22/25 and 25/25 images don't differ in any other way - no different colours, nothing greyed out. No visual clues except for the 22/25 and the 25/25 (and the timer) - none of which will probably be "grabbable" text. Maybe try the OCR Wizard on that tiny 22/25 area to see if it can read the numbers. If they can, that might be a good starting point.
thank you for the reply my problem will be solved if i know how to assign pic to variable how to do that ?
when i write it like that it dosent work
Let>kk=C:\Users\KiKAS\Desktop\pics for last shelter\Adcanced\Recomended Donation.bmp
what is the proper way to do this ?

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1385
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: same image different locations

Post by Dorian (MJT support) » Wed Jun 24, 2020 9:33 am

Code: Select all

Let>kk=C:\Users\KiKAS\Desktop\pics for last shelter\Adcanced\Recomended Donation.bmp
...would work. Like this :

Code: Select all

Let>kk=C:\Users\KiKAS\Desktop\pics for last shelter\Adcanced\Recomended Donation.bmp
FindImagePos>%kk%,WINDOW:Screen One,0.7,1,XArr,YArr,NumFound,CCOEFF
If
If you're simply trying to click on an image until another image doesn't exist, then while/endwhile is a good way to do it. However, in your code, you don't have an endif to go with your if, and you don't have an endwhile to go with your while. You'll need to put these in the appropriate places, depending on what you want to do.

I'm not entirely sure where you want your endwhile/endif to be, so below are the two most likely canditates.

Code: Select all

//Donating ISN'T included in if/endif
Let>RecommendedFound=FALSE
While>RecommendedFound=FALSE
FindImagePos>C:\Users\KiKAS\Desktop\pics for last shelter\Adcanced\Recomended Donation.bmp,WINDOW:Screen One,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,{%YArr_0%+10}
LClick
Let>RecommendedFound=TRUE
Wait>2
Let>Donating=0
Endif

Repeat>Donating
Let>Donating=Donating+1
MouseMoveRel>286,773
LClick
Wait>0.5
Until>Donating=25
Endwhile

Code: Select all

//Donating ISN'T included in if/endif
Let>RecommendedFound=FALSE
While>RecommendedFound=FALSE
FindImagePos>C:\Users\KiKAS\Desktop\pics for last shelter\Adcanced\Recomended Donation.bmp,WINDOW:Screen One,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,{%YArr_0%+10}
LClick
Let>RecommendedFound=TRUE
Wait>2
Let>Donating=0

Repeat>Donating
Let>Donating=Donating+1
MouseMoveRel>286,773
LClick
Wait>0.5
Until>Donating=25
Endif
Endwhile
Yes, we have a Custom Scripting Service. Message me or go here

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