ilcaa
New Member
Posts: 3
|
Post by ilcaa on Oct 16, 2019 1:07:59 GMT
i want to play a macro2 from within macro1. i see a LOAD MACRO - which just stops macro1 and plays macro2 and ADD MACRO FROM FILE which appends a macro2 steps and the end of macro 1
i am running a loop, and instead of doing it with 1 macro i want to split it up into 2 macros, and in the middle of my loop call macro2, then once its done continue with next macro1 loop.
is this possible? thanks
|
|
|
Post by zeak on Oct 16, 2019 20:39:41 GMT
Hi Ilcaa,
Welcome to the forum,
You can do this by using the action RUN PROGRAM to open MMM with the argument to open your macro2 using ::
please see my example below.
1 | RUN ACTION | RUN PROGRAM | C:\Users\Zeak\Macros\MiniMouseMacro.exe::C:\Users\Zeak\Macros\Macro2.mmmacro This is given that both the program and the macro are located in the same folder, if you store your macros in a different location then refer to that location.
|
|
|
Post by Steve on Oct 27, 2019 4:18:18 GMT
Here's another example.
In this example Macro1 and Macro2 are communicating by sending UDP packets strings internally. When Macro2 receives a UDP packet with the string "MACRO2" is copies a string to the clipboard and then sends a UDP packet to Macro1 with the string "MACRO1". Macro1 waits for this UDP packet then takes the value of CLIPBOARD to use within the DRAW action. It loops through this 15 times in a FOR loop.
Macro1:
1 | RUN ACTION | SET TITLE | Macro1 2 | FOR | I | = | 0 TO 15 | NEXT 3 | IF | INTEGER VARIABLE | %I% | IS EVEN | MOD 2 = 0 | DEFINE STRING VARIABLE | %STRING%::RED | ELSE | 10 | RUN ACTION | DEFINE STRING VARIABLE | %STRING%::BLUE 4 | RUN ACTION | SEND UDP PACKET STRING | 127.0.0.1::41414::MACRO2 5 | IF | RECEIVE UDP PACKET STRING | 127.0.0.1::41415::MACRO1::0 | STRING FOUND | SEARCH FOR STRING | CONTINUE 6 | RUN ACTION | DRAW | TEXT::AT LOCATION [%CLIPBOARD%]::COLOR [%STRING% 3]::STRING [%TIME%]::FONT [Segoe Print, 15, Regular]::TIME [2 250]::WAIT NO 7 | FOR | NEXT Macro2:
1 | IF | RECEIVE UDP PACKET STRING | 127.0.0.1::41414::MACRO2::0 | STRING FOUND | SEARCH FOR STRING | CONTINUE 2 | RUN ACTION | SET TITLE | Macro2 3 | RUN ACTION | COPY TO CLIPBOARD | %RANDOM_200-1500% %RANDOM_200-800% 4 | RUN ACTION | WAIT MILLISECONDS | 1000 4 | RUN ACTION | SEND UDP PACKET STRING | 127.0.0.1::41415::MACRO1
|
|
jeff
Full Member
Posts: 15
|
Post by jeff on Mar 7, 2020 2:18:19 GMT
Unfortunately, these examples do not meet my goal. I was hoping to write multiple macro files that would essentially act as function. My main one would call the macros based on if statements, i.e.
(main macro)
If X, run macro XYZ (main macro waits, macro XYZ runs) (XYZ finishes running, main macro runs) If Y, run macro QRS (etc)
Basically wanted to do this to help keep things straight in my mind and simplify my problems and hone my focus. Thinking about it, maybe just being able to comment would help, not sure if that is possible?
|
|
|
Post by Steve on Mar 7, 2020 3:28:12 GMT
Unfortunately, these examples do not meet my goal. I was hoping to write multiple macro files that would essentially act as function. My main one would call the macros based on if statements, i.e. (main macro)
If X, run macro XYZ (main macro waits, macro XYZ runs) (XYZ finishes running, main macro runs) If Y, run macro QRS (etc) Basically wanted to do this to help keep things straight in my mind and simplify my problems and hone my focus. Thinking about it, maybe just being able to comment would help, not sure if that is possible?
Hi jeff Yep this logic will work with MMM. If your want to check out comments, see this post minimousemacro.proboards.com/thread/213/comments. These actions loadmacrofromurl, addmacrofromfile, and addmacrofromfile add macro's in statically. Another way, probably a better way, is to use a FOR EACH LINE IN FILE RUN statement to call a function. Like this: call_messageprompt.mmmacro is the main macro that contains the logic to call other macro files. In this example, one condition evaluates to call the messageprompt.mmmacro file. Note line 7 of this macro is long as it contains two AND actions and an ELSE statement call_messageprompt.mmmacro* | VARIABLES 1 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %BOOLEAN%::FALSE 2 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::1 * | FUNCTION_RunMacro 3 | IF NOT | BOOLEAN VARIABLE | %BOOLEAN% | IS | TRUE | GOTO MACRO LINE | DOWN 2 4 | FOR | EACH | LINE IN | %STRING% | RUN 5 | RUN ACTION | DEFINE BOOLEAN VARIABLE | %BOOLEAN%::FALSE * | FUNCTION_RunMacro_END * | MAIN 6 | RUN ACTION | MESSAGE PROMPT | Hit 'OK' to evaluate the condition::check::0 7 | IF | INTEGER VARIABLE | %INTEGER% | LESS THAN | 6 | DEFINE STRING VARIABLE | %STRING%::D:\Macro\Messageprompt.mmmacro | AND | X | RUN ACTION | DEFINE BOOLEAN VARIABLE | %BOOLEAN%::TRUE | AND | X | RUN ACTION | GOTO MACRO LINE | FUNCTION_RunMacro | ELSE | X | RUN ACTION | GOTO MACRO LINE | END * | END 8 | RUN ACTION | MESSAGE PROMPT | %integer% GTR 6::End of File messageprompt.mmmacro1 | RUN ACTION | MESSAGE PROMPT | Integer = %integer%::(%integer%/6)::1 2 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::+1 3 | RUN ACTION | MESSAGE PROMPT | Integer = %integer%::(%integer%/6)::1 4 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::+1 5 | RUN ACTION | MESSAGE PROMPT | Integer = %integer%::(%integer%/6)::1 6 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::+1
|
|
jeff
Full Member
Posts: 15
|
Post by jeff on Mar 7, 2020 6:07:06 GMT
I didn't think about defining strings from the file then looping through them, that is pretty clever and will suit my purposes. Thanks! Also, the comment system is really nice.
|
|
|
Post by Steve on Mar 9, 2020 3:43:40 GMT
Version 7.4 was released today with a new action RUN MACRO INLINE. It's better suited than the FOR condition above for calling inline functions.
The RUN MACRO INLINE action runs a saved macro file inline before progressing the macro. Consider the RUN MACRO INLINE example statement below taken from a macro condition: 1 | RUN ACTION | MESSAGE PROMPT | Start 2 | RUN ACTION | RUN MACRO INLINE | D:\Macro\Calculate.mmmacro 3 | RUN ACTION | MESSAGE PROMPT | End The example macro above first will run a MESSAGE PROMPT 'Start' then will proceed to execute all the macro lines within the 'Calculate.mmmacro' file. NOTE that the macro file will run without any macro flow control. This means that FOR loops and GOTO statements within the selected file when run inline will not work.
|
|