joe
Full Member
Posts: 46
|
Post by joe on Oct 8, 2022 4:44:34 GMT
So, the solution to my last post, "Random Number generator" was so good that I thought up of another problem.
So originally I created ten macros, lets call them A, B, C, D, E, F, G, H, I, and J.
I then created a macro that would pick one of those macros at random and then play it. What I was wondering is can I make a macro that would pick one of the above mentioned macros at random, play it, and then pick another one of the above macros at random and then play it without repeating the macro that was already played?
For example, if I could create this macro and ran it. And then the first macro that it picked at random to play was E. Then it would go back and pick randomly from a smaller list of macros (A, B, C, D, F, G, H, I, J) cause it doesn't pick the previous macro that was played, and it picked A. Then it would go back and pick randomly from B, C, D, F, G, H, I, J and so forth.
Is this possible? I was going to ask for help with something else but I have forgotten it already.
Thanks again!
|
|
|
Post by philranger on Oct 11, 2022 1:54:35 GMT
I don’t see an easy way apart from listing the macros in an external text file?
|
|
|
Post by zeak on Oct 11, 2022 3:25:31 GMT
Hi Joe,
Try this out.
* | START 1 | RUN ACTION | DEFINE INTEGER VARIABLE | %RAND%::%RANDOM_0-5% 2 | IF | INTEGER VARIABLE | %RAND% | = | %STORE% | GOTO MACRO LINE | START 3 | RUN ACTION | DEFINE INTEGER VARIABLE | %STORE%::%RAND% 4 | RUN ACTION | MESSAGE PROMPT | RAND = %RAND%::Random::1::OK 5 | IF | INTEGER VARIABLE | %RAND% | = | 1 | LOAD MACRO | D:\Dropbox\Macro\A.mmmacro 6 | IF | INTEGER VARIABLE | %RAND% | = | 2 | LOAD MACRO | D:\Dropbox\Macro\B.mmmacro 7 | IF | INTEGER VARIABLE | %RAND% | = | 3 | LOAD MACRO | D:\Dropbox\Macro\C.mmmacro 8 | IF | INTEGER VARIABLE | %RAND% | = | 4 | LOAD MACRO | D:\Dropbox\Macro\D.mmmacro 9 | IF | INTEGER VARIABLE | %RAND% | = | 5 | LOAD MACRO | D:\Dropbox\Macro\E.mmmacro
Added a remark and two extra lines to Steve's code, a check line and store integer line. rename them as you see fit.
|
|
joe
Full Member
Posts: 46
|
Post by joe on Oct 20, 2022 0:47:47 GMT
Hi Zeak, Thanks for replying to my post. Your solution didn't work for me in the way that I had hoped. The START macro just keeps playing the A, B, C, D, and E macros. I had hoped the START macro would stop playing after it played all of the macros. Maybe, I did some of the code wrong? Below I posted my START macro, which is pretty much a copy of your example. Below my START macro I posted my A macro. These are two separate macros and in between where the START macro ends and the A macro begins I put the words "new macro".
* | START 1 | RUN ACTION | DEFINE INTEGER VARIABLE | %RAND%::%RANDOM_0-5% 2 | IF | INTEGER VARIABLE | %RAND% | = | %STORE% | GOTO MACRO LINE | START 3 | RUN ACTION | DEFINE INTEGER VARIABLE | %STORE%::%RAND% 4 | RUN ACTION | MESSAGE PROMPT | RAND = %RAND%::Random::1::OK 5 | IF | INTEGER VARIABLE | %RAND% | = | 1 | LOAD MACRO | C:\Users\josep\Desktop\MiniMouseMacros\A.mmmacro 6 | IF | INTEGER VARIABLE | %RAND% | = | 2 | LOAD MACRO | C:\Users\josep\Desktop\MiniMouseMacros\B.mmmacro 7 | IF | INTEGER VARIABLE | %RAND% | = | 3 | LOAD MACRO | C:\Users\josep\Desktop\MiniMouseMacros\C.mmmacro 8 | IF | INTEGER VARIABLE | %RAND% | = | 4 | LOAD MACRO | C:\Users\josep\Desktop\MiniMouseMacros\D.mmmacro 9 | IF | INTEGER VARIABLE | %RAND% | = | 5 | LOAD MACRO | C:\Users\josep\Desktop\MiniMouseMacros\E.mmmacro
new macro
* | A 1 | RUN ACTION | MOUSE CLICK | Left click at 894 1054 1 times with 0 ms delay 2 | RUN ACTION | WAIT SECONDS | 5 3 | RUN ACTION | MOUSE CLICK | Left click at 514 54 1 times with 0 ms delay 4 | RUN ACTION | WAIT SECONDS | 5 5 | RUN ACTION | KEYPRESS | A 6 | RUN ACTION | WAIT SECONDS | 5 7 | RUN ACTION | MOUSE CLICK | Left click at 1896 16 1 times with 0 ms delay 8 | RUN ACTION | WAIT MILLISECONDS | 500 9 | RUN ACTION | LOAD MACRO | C:\Users\josep\Desktop\MiniMouseMacros\START.mmmacro
|
|
|
Post by zeak on Oct 24, 2022 6:49:22 GMT
Hi Joe, Do you have the "Clear variables on playback" turned on in options? If you do it will clear the STORE variable when the other macro loads. I also made a rookie mistake of not declaring variables before using them. please see fixed code below and make sure to untick the clear variables on playback. 1 | RUN ACTION | DEFINE INTEGER VARIABLE | %RAND%::0 2 | RUN ACTION | DEFINE INTEGER VARIABLE | %STORE%::0 * | START 3 | RUN ACTION | DEFINE INTEGER VARIABLE | %RAND%::%RANDOM_0-5% 4 | IF | INTEGER VARIABLE | %RAND% | = | %STORE% | GOTO MACRO LINE | START 5 | RUN ACTION | DEFINE INTEGER VARIABLE | %STORE%::%RAND% 6 | IF | INTEGER VARIABLE | %RAND% | = | 1 | LOAD MACRO | D:\Dropbox\Macro\A.mmmacro 7 | IF | INTEGER VARIABLE | %RAND% | = | 2 | LOAD MACRO | D:\Dropbox\Macro\B.mmmacro 8 | IF | INTEGER VARIABLE | %RAND% | = | 3 | LOAD MACRO | D:\Dropbox\Macro\C.mmmacro 9 | IF | INTEGER VARIABLE | %RAND% | = | 4 | LOAD MACRO | D:\Dropbox\Macro\D.mmmacro 10 | IF | INTEGER VARIABLE | %RAND% | = | 5 | LOAD MACRO | D:\Dropbox\Macro\E.mmmacro
|
|
joe
Full Member
Posts: 46
|
Post by joe on Oct 28, 2022 5:52:17 GMT
Hello Zeak,
I made the changes that you suggested and the macro is still repeating. Should there be a stop command somewhere on the macro?
Thanks again!
|
|
|
Post by stevenm on Oct 28, 2022 9:15:30 GMT
Here's something I was playing with since I was interested in how to do what you wanted.
All the # lines are not actually part of the script, and you should remove them but they help explain what each section does...
yes, I could have done "* | Whatever", but didn't
# Define used numbers and times tried -- the , in USED_NUMBERS is important to set the variable up so all the numbers will be like ,1,3,4,2,5, once they are tried 1 | RUN ACTION | DEFINE STRING VARIABLE | %USED_NUMBERS%::, 2 | RUN ACTION | DEFINE INTEGER VARIABLE | %TIMES_TRIED%::0
* | START
3 | RUN ACTION | DEFINE INTEGER VARIABLE | %RAND%::%RANDOM_0-5%
# check to see if we already used the number that was randomly retrieved 4 | IF | STRING VARIABLE | %USED_NUMBERS% | CONTAINS | ,%RAND%, | GOTO MACRO LINE | START
# record how many times we tried since we found a random number that wasn't previously tried 5 | RUN ACTION | DEFINE INTEGER VARIABLE | %TIMES_TRIED%::+1
6 | RUN ACTION | MESSAGE PROMPT | RAND = %RAND% -- Tried: %TIMES_TRIED%::Random::1::OK
# update the used numbers list so we don't reuse numbers -- note, the commas are so we know the difference between 1 and 12 although I didn't test higher than 5 7 | RUN ACTION | DEFINE STRING VARIABLE | %USED_NUMBERS%::%USED_NUMBERS%%RAND%,
# Display the used numbers string 8 | RUN ACTION | MESSAGE PROMPT | USED_NUMBERS=%USED_NUMBERS%
# Right about here, you'd have to deal with your different macro files, but I think you have that already worked out so I didn't want to test that myself
# if we haven't tried more times than there are numbers, then do it again 9 | IF | INTEGER VARIABLE | %TIMES_TRIED% | LESS THAN | 5 | GOTO MACRO LINE | START
HTH
Steven M
|
|