CLICK QUESTION
Moderators: Dorian (MJT support), JRL
-
- Newbie
- Posts: 17
- Joined: Sun Dec 21, 2008 6:58 am
CLICK QUESTION
I had just posted a question about the REPEAT command, but maybe the repeat command isn't even needed. Is there a command similar to LClick and double click that will click the left mouse a specified number of times?
Especially a number of times detected by a GetTextRect command.
It seems like there is or should be, but I can't find one.
Thank you all for your help so far.
Especially a number of times detected by a GetTextRect command.
It seems like there is or should be, but I can't find one.
Thank you all for your help so far.
-
- Newbie
- Posts: 17
- Joined: Sun Dec 21, 2008 6:58 am
Thanks for the reply. It seems like i've read about a
LClick *#
or
LClick *Variable
but can't seem to get anything like that to work.
I've also tried the repeat command, but it seems that the until command can't handle a variable such as
Let>k=0
Repeat>k
Let>k=k+1
LClick
until>K=variable
Thanks for your help.
Brad
LClick *#
or
LClick *Variable
but can't seem to get anything like that to work.
I've also tried the repeat command, but it seems that the until command can't handle a variable such as
Let>k=0
Repeat>k
Let>k=k+1
LClick
until>K=variable
Thanks for your help.
Brad
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
This works fine for me:
Code: Select all
Let>numTimes=5
Let>k=0
Repeat>k
Let>k=k+1
LClick
until>k=%numTimes%
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?
repeat with variables
I assume you already set variable to a value.
Let>variable=5
For your repeat/until, try:
until>K=%variable%
or maybe even better:
until>K>%variable%
Let>variable=5
For your repeat/until, try:
until>K=%variable%
or maybe even better:
until>K>%variable%
-
- Newbie
- Posts: 17
- Joined: Sun Dec 21, 2008 6:58 am
Thank you guys for your help.
Yes, gdyvig, I've set the variable to a value. I have the variable coming from a GetTextRect command. It is reading for the number in a small graphical box. I then take that number and use it as the UNTIL>K= (the GetTextRect answer).
I haven't tried it with the greater than symbol. I'll try that as soon as i get home.
Strangely, I've used an IF> condition within the the Repeat/Until that makes it exit the loop but it only works if the number is under 9. If it is over 9 it doesn't exit the loop.
Thanks again everyone.
Brad
Yes, gdyvig, I've set the variable to a value. I have the variable coming from a GetTextRect command. It is reading for the number in a small graphical box. I then take that number and use it as the UNTIL>K= (the GetTextRect answer).
I haven't tried it with the greater than symbol. I'll try that as soon as i get home.
Strangely, I've used an IF> condition within the the Repeat/Until that makes it exit the loop but it only works if the number is under 9. If it is over 9 it doesn't exit the loop.
Thanks again everyone.
Brad
-
- Newbie
- Posts: 17
- Joined: Sun Dec 21, 2008 6:58 am
Still Having troubles with Let & Repeat
With the question above, This is the code I've been trying to get working, since there isn't a better LClick multiple time option.
ScreenCapture>320,761,340,771,ChangingImage.BMP
CompareBitmaps>ChangingImage.BMP,ConstantImage.BMP,nPercent
If>NPercent320,761,340,771,NumOfClicks
MouseMove>316,282
Let>k=NumOfClicks
Repeat>k
Let>k=k-1
LClick
until>k=0
When I take out half of the code, it works as expected:
Let>k=10
Repeat>k
Let>k=k-1
LClick
until>k=0
This will cause 10 clicks to happen and then finish the script. But when I try the complete code, assuming the NumOfClicks equals 12, the watch list will look like this:
NPercent=28 (so the bmps aren't a match)
NumOfClicks=12 (so the GetTextInRect read 12 from the rectangle)
K=12
Then when it excecutes the Let>k=k-1 the watch list changes to say
K=k-1.
Any Ideas?
Thanks
Brad
ScreenCapture>320,761,340,771,ChangingImage.BMP
CompareBitmaps>ChangingImage.BMP,ConstantImage.BMP,nPercent
If>NPercent320,761,340,771,NumOfClicks
MouseMove>316,282
Let>k=NumOfClicks
Repeat>k
Let>k=k-1
LClick
until>k=0
When I take out half of the code, it works as expected:
Let>k=10
Repeat>k
Let>k=k-1
LClick
until>k=0
This will cause 10 clicks to happen and then finish the script. But when I try the complete code, assuming the NumOfClicks equals 12, the watch list will look like this:
NPercent=28 (so the bmps aren't a match)
NumOfClicks=12 (so the GetTextInRect read 12 from the rectangle)
K=12
Then when it excecutes the Let>k=k-1 the watch list changes to say
K=k-1.
Any Ideas?
Thanks
Brad
The first thing I see is that the syntax of your if statement is incorrect. I'd help you straighten it out but I'm not really sure what it is you're trying to accomplish with it. How about explaining what you think the line is doing and someone can tell you what you need to do to make that happen.If>NPercent320,761,340,771,NumOfClicks
That's because you set the value of the variable "k" equal to "NumOfClicks" which has no value as a variable. Therefore "k" is equal to the text string "NumOfClicks". Then when you get to the line Let>k=k-1 you are not doing any math function since the value of variable "k" is equal to the text string "NumOfClicks", so "k" gets set to another text string "k-1".Then when it excecutes the Let>k=k-1 the watch list changes to say
K=k-1.
One small point. Although many good working posts in the forum and some good working examples in Help use single characters as variables, its a bad habit to get into. Try making your variables a little more descriptive. "NumOfClicks" is an excellent variable name.
-
- Newbie
- Posts: 17
- Joined: Sun Dec 21, 2008 6:58 am
Thank you for the reply, JRL.
I think I'm frustrated with the forum more than I'm frustrated with MS. When I'm trying to copy and paste part of my code into the forum, it always loses some of it. GRRRRRRRRRRRR. I need to remember to disable the crap that forums do. I DON"T WANT SMILIES.....
Anyway, That code was supposed to include a GetTextRect command like this
ScreenCapture>320,761,340,771,ChangingImage.BMP
CompareBitmaps>ChangingImage.BMP,ConstantImage.BMP,nPercent
If>NPercent
GetTextRect>320,761,340,771,NumOfClicks
MouseMove>316,282
Let>k=NumOfClicks
Repeat>k
Let>k=k-1
LClick
until>k=0
I'm trying to learn how to run this program by controlling childrens games. I figure if i can do that, i can propose to my boss that I can program some of our redundant tasks at work. The programs are graphical in nature. The number for how many times to click are pictures. And the clicking needs to be repeated a certain amount of times.
Thank you for your help.
I think I'm frustrated with the forum more than I'm frustrated with MS. When I'm trying to copy and paste part of my code into the forum, it always loses some of it. GRRRRRRRRRRRR. I need to remember to disable the crap that forums do. I DON"T WANT SMILIES.....
Anyway, That code was supposed to include a GetTextRect command like this
ScreenCapture>320,761,340,771,ChangingImage.BMP
CompareBitmaps>ChangingImage.BMP,ConstantImage.BMP,nPercent
If>NPercent
GetTextRect>320,761,340,771,NumOfClicks
MouseMove>316,282
Let>k=NumOfClicks
Repeat>k
Let>k=k-1
LClick
until>k=0
I'm trying to learn how to run this program by controlling childrens games. I figure if i can do that, i can propose to my boss that I can program some of our redundant tasks at work. The programs are graphical in nature. The number for how many times to click are pictures. And the clicking needs to be repeated a certain amount of times.
Thank you for your help.
-
- Newbie
- Posts: 17
- Joined: Sun Dec 21, 2008 6:58 am
I've been trying everything I can think of. And I can get the script to work properly as long as my variable NumOfClicks is below 9. But as soon as I hit 9 or above, the loop doesn't end. The script looks like this:
ScreenCapture>320,761,340,771,ChangingImage.BMP
CompareBitmaps>ChangingImage.BMP,ConstantImage.BMP,nPercent
If>NPercent
GetTextRect>320,761,340,771,NumOfClicks
MouseMove>316,282
Let>k=1
Repeat>k
Let>k=k+1
LClick
until>k>NumOfClicks
It's as if the UNTIL line recognizes that 8 is below the NumOfClicks, but not 9 or above. I really don't get this.
ScreenCapture>320,761,340,771,ChangingImage.BMP
CompareBitmaps>ChangingImage.BMP,ConstantImage.BMP,nPercent
If>NPercent
GetTextRect>320,761,340,771,NumOfClicks
MouseMove>316,282
Let>k=1
Repeat>k
Let>k=k+1
LClick
until>k>NumOfClicks
It's as if the UNTIL line recognizes that 8 is below the NumOfClicks, but not 9 or above. I really don't get this.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
When I paste code into the forum I find this always works:
1. Use the CODE button
2. Check: Disable Smilies in this post
3. Check: Disable HTML in this post
That always works for me. If you need to change a previous post you'll need to paste the code again.
On to your code:
This line, looks wrong:
If>NPercent
Suspect you mean:
If>NPercentNumOfClicks,SPACE,,NumOfClicks
Maybe remove CRLFs for good measure:
StringReplace>NumOfClicks,CR,,NumOfClicks
StringReplace>NumOfClicks,LF,,NumOfClicks
Use the debugger to step through and look at the value of NumClicks and/or use a Message box to show you what it is:
MessageModal>|%NumOfClicks%|
I've put it between | chars because then if there are any hidden characters it will become obvious.
Finally you could also try:
Until>k>%NumOfClicks%
But most importantly we need to debug so that we can look at the value of NumOfClicks. I'm pretty confident you'll find it's not always just a number which is why some iterations work but others don't.
A way to test this is also to hard code NumOfClicks and see what happens. E.g. replace the GetTextInRect with Let>NumOfClicks=12 and if the loop now works properly we know I'm right - that the text being returned by GetTextInRect is not always a proper number.
[/code]
1. Use the CODE button
2. Check: Disable Smilies in this post
3. Check: Disable HTML in this post
That always works for me. If you need to change a previous post you'll need to paste the code again.
On to your code:
This line, looks wrong:
If>NPercent
Suspect you mean:
If>NPercentNumOfClicks,SPACE,,NumOfClicks
Maybe remove CRLFs for good measure:
StringReplace>NumOfClicks,CR,,NumOfClicks
StringReplace>NumOfClicks,LF,,NumOfClicks
Use the debugger to step through and look at the value of NumClicks and/or use a Message box to show you what it is:
MessageModal>|%NumOfClicks%|
I've put it between | chars because then if there are any hidden characters it will become obvious.
Finally you could also try:
Until>k>%NumOfClicks%
But most importantly we need to debug so that we can look at the value of NumOfClicks. I'm pretty confident you'll find it's not always just a number which is why some iterations work but others don't.
A way to test this is also to hard code NumOfClicks and see what happens. E.g. replace the GetTextInRect with Let>NumOfClicks=12 and if the loop now works properly we know I'm right - that the text being returned by GetTextInRect is not always a proper number.
[/code]
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?
-
- Newbie
- Posts: 17
- Joined: Sun Dec 21, 2008 6:58 am
Thank you for your helpful reply.
1)I've gone into my profile and disabled HTML and Smiles. We'll see how it works.
2) the extra > isn't really there. Just leftover from an incorrect paste. Thanks for pointing it out.
3) I've run it in the Watch window and things look fine, but I will add those couple lines and see if it helps. So, i should put
StringReplace>NumOfClicks,SPACE,,NumOfClicks
StringReplace>NumOfClicks,CR,,NumOfClicks
StringReplace>NumOfClicks,LF,,NumOfClicks
all together. And before what should i put them. Do they need to be repeated for each iteration of the code I've posted (it is repeated to look for about 50 different squares on the screen).
4) I will double check by watching the MessageModal.
5) I've tried hard coding NumOfClicks and you are correct, things work fine.
Thanks again for all your help. This has been a very fun and challenging program to learn.
Brad
1)I've gone into my profile and disabled HTML and Smiles. We'll see how it works.
2) the extra > isn't really there. Just leftover from an incorrect paste. Thanks for pointing it out.
3) I've run it in the Watch window and things look fine, but I will add those couple lines and see if it helps. So, i should put
StringReplace>NumOfClicks,SPACE,,NumOfClicks
StringReplace>NumOfClicks,CR,,NumOfClicks
StringReplace>NumOfClicks,LF,,NumOfClicks
all together. And before what should i put them. Do they need to be repeated for each iteration of the code I've posted (it is repeated to look for about 50 different squares on the screen).
4) I will double check by watching the MessageModal.
5) I've tried hard coding NumOfClicks and you are correct, things work fine.
Thanks again for all your help. This has been a very fun and challenging program to learn.
Brad
-
- Newbie
- Posts: 17
- Joined: Sun Dec 21, 2008 6:58 am
FIXED
That fixed it mtettmar.
It seems as though NumOfClicks had a space after the number and t would mess up the formula. I put
StringReplace>NumOfClicks,SPACE,,NumOfClicks
StringReplace>NumOfClicks,CR,,NumOfClicks
StringReplace>NumOfClicks,LF,,NumOfClicks
in there and now everything seems fine.
Thank you again.
It seems as though NumOfClicks had a space after the number and t would mess up the formula. I put
StringReplace>NumOfClicks,SPACE,,NumOfClicks
StringReplace>NumOfClicks,CR,,NumOfClicks
StringReplace>NumOfClicks,LF,,NumOfClicks
in there and now everything seems fine.
Thank you again.