|
Post by Johnc on Aug 10, 2018 23:31:15 GMT
Hi Steve,
I have just been using %INTEGER% variables to avoid confusion but I really need a %STRING% this time. (to change a command line parameter in RUN VIA CMD/C) In addition, I can never get %STRING% and %CLIPBOARD% to work together. Once %CLIPBOARD% is assigned to %STRING%, %STRING% always follows values in %CLIPBOARD%. (You would think that %STRING% would be a snapshot of %CLIPBOARD%)
Other weird things happening too...
e.g. "Mike" in %STRING% and I can copy that to clipboard and ctrl-v would work to output "Mike" to stdout but keypress %STRING% won't work at times... (no output to stdout) Very inconsistent...
The use of %STRING% is not very intuitive for me. Do you have a complete documentation on how %STRING% works with keypress and with %CLIPBOARD%? I am sure there is something I am missing.
Thanks!
John
|
|
|
Post by Steve on Aug 12, 2018 4:48:23 GMT
Hi John,
1 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING%::%clipboard% 2 | RUN ACTION | | | | MESSAGE PROMPT | string is %string% and clipboard is %clipboard%:: Defining the value of %string% will set the value to the text word %clipboard%. At run-time during playback MMM reads all variables for the value they contain. %string% at playback reads to MMM as %clipboard% because the value is the literal word %clipboard%.
3 | RUN ACTION | | | | WAIT SECONDS | 5 4 | RUN ACTION | | | | MESSAGE PROMPT | string is %string% and clipboard is %clipboard%:: At line 1 the value of %string% was set to %clipboard%. At line 3 we wait for 5 seconds. During that wait time, the value of %clipboard% changes (I ctrl+c some text outside of MMM for example). Then at line 4 we see the value of %string% is the value of the system clipboard; the value kept within the %clipboard% variable. As you have written below, %string% is not a snapshot of %clipboard% instead when declared as %clipboard% becomes a representation of the true value of %clipboard%.
1 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING%::%clipboard% 2 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING1%::This is my string1 text 3 | RUN ACTION | | | | COPY TO CLIPBOARD | %string1% 4 | RUN ACTION | | | | RUN PROGRAM | Notepad.exe 5 | IF | WINDOW TITLE | Untitled - Notepad | EXIST | SELECT WINDOW BY NAME | Untitled - Notepad | ELSE | 5 | RUN ACTION | | | | GOTO MACRO LINE | %return%+1 6 | X | X | 500 | Keypress %string% 7 | X | X | 500 | Keypress Ctrl+ | v Above the value of string is set to clipboard at line 1. Line 2 we define the value of %string1% to 'This is my string 1 text'. Line 3 we copy %string1% to the system clipboard, in turn this sets the value of %clipboard% to the text value of %string1%. line 4 we open notepad.exe. Line 5 we select the new notepad document window. Line 6 we output to contents of %string%. Line 7 we output the system clipboard with a ctrl+v.
Here line 6 and 7 will produce the same values on the notepad document. They will both produces 'This is my string1 text'. This is because %string% is set to always keep the value of %clipboard%.
Does this help to clear things up a bit?
Regards, Steve.
|
|
|
Post by Johnc on Aug 13, 2018 3:15:56 GMT
Hi Steve,
Thanks very much for the detailed explanations. Much appreciated! I can follow you now. However, I think I did something silly where I re-DEFINEd %STRING% multiple times as follows:
1 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING%::initialx 2 | RUN ACTION | | | | INPUT BOX | Name?::Input Name::STRING 3 | RUN ACTION | | | | COPY TO CLIPBOARD | %STRING% ... ... do many cut & pastes using ctrl-c & ctrl-v ... ...
176 | RUN ACTION | | | | COPY TO CLIPBOARD | %STRING% 177 | 1548 | 326 | 902 | Keypress Ctrl+ | v 178 | 754 | 197 | 1000 | Keypress .txt 179 | 754 | 197 | 1000 | Keypress enter ... 189 | RUN ACTION | | | | SELECT WINDOW BY NAME | Google Chrome 190 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING%::%CLIPBOARD% 191 | RUN ACTION | | | | RUN VIA CMD /C | title=runscript & touch E:\File_John\F_variable\%STRING%.csv 192 | RUN ACTION | | | | WAIT SECONDS | 1 193 | IF | WINDOW TITLE | runscript | NOT EXIST | CONTINUE ...
So I am sure it was a mess! Just curious if one can define the same %STRING% multiple times?? Worst yet... I had %CLIPBOARD% there to add to the confusion! I have treated "DEFINE" as "ASSIGNMENT" here as I have no clue! Please enlighten.
Somehow the macro worked up to line 179 even for the ctrl-v, under my poor assumption!! Line 191 is where the problem is. I got a "noname" .csv file (i.e. ".csv") So I know Line 191 had a problem! Perhaps Line 190 is worse?? lol!
Thanks Steve once again!
|
|
|
Post by Steve on Aug 13, 2018 3:44:55 GMT
Hi John,
I'm not sure where you are going wrong with your macro. It looks ok to me. The problem is probably your assignment to STRING. To answer your question, yes you can define the same STRING multiple times. You can also use STRING1, STRING2, STRING3, and STRING4. Maybe use multiple string variables to help fix the confusion. Your line 190 and 191 look fine. I'd say the value of the system clipboard is "" if you are getting ".csv" for line 191. Try turning on verbose output in the MMM event log to help debugging the running macro. Verbose logging can affect playback performance (sometimes for time sensitive macros) so disable it if you dont need it after.
The latest version (6.7) has just been released. The OUTPUT TO FILE action helps a bit with some File IO. Might be worth a look.
Cheers, Steve.
|
|
|
Post by Johnc on Aug 13, 2018 14:43:56 GMT
Hi Steve, Thank you so much for your time and dedication in helping out! I really appreciate it! This makes MMM so much better than others! It is great that the new version is out! Let me try the new version ASAP. After some thinking about the whole %STRING% & Clipboard thing. Here are the questions that beg an answer: 1) If defining %STRING% as %CLIPBOARD% would effectively assimilate %STRING% into %CLIPBOARD%, then why do it? Why not just use %CLIPBOARD% directly? 2) Should we set up a rule of thumb not to define any string variables as %CLIPBOARD% as it doesn't serve any purpose? Or does it if I am missing something? 3) The real question is how we can store a "snapshot" of %CLIPBOARD% into a string variable. Is it possible in the current MMM architecture? Or perhaps in the new release? 4) I am guessing the following would waste the variables %STRING% and %STRING1%. Correct? 1 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING%::%CLIPBOARD% 2 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING1%::%STRING% This way, %STRING% and %STRING1% would be assimilated into %CLIPBOARD%. Might as well use %CLIPBOARD% directly, right? 5) This is a silly question but I will ask anyway... After running line 1 in Q4 above, how do I disconnect %STRING% from %CLIPBOARD% again? Just redefine %STRING% to something else?? Looks like the most important question is Q3. Everything will work out if Q3 has a solution. Thanks Steve for your patience once again!
|
|
|
Post by Johnc on Aug 13, 2018 17:51:37 GMT
I am sorry Steve but I must admit that I don't know how to use/read the event log! Yes, I did enable it and it did capture a list of events but I can't see how it can help me debug the macro as the list is similar to the original macro! Yes, verbose is checked. Any tutorial on how to use the event log? tks!
|
|
|
Post by Steve on Aug 13, 2018 23:28:44 GMT
Hi John, To answer your questions: 1) Yes I agree, why not just use CLIPBOARD. When defining STRING to CLIPBOARD it carries the current value. This is by design. STRING essentially becomes the text string '%CLIPBOARD%', and at runtime acts like %CLIPBOARD%. Maybe this needs to be changed...I'll add this one to the list to look at for the next update. 2) Defining variables as CLIPBOARD does not really achieve anything. It's cleaner to just use CLIPBOARD. No, your not missing anything. 3) Its difficult with the current MMM architecture as you have noticed. The IO thread comes to mind. File IO and reading variables in is on my to do list for the next update. 4) Yep might as well use CLIPBOARD directly. Saves confusion, quicker run time, better use of variables. 5) Yeah exactly. Redefine STRING to something else or it will carry the value of '%CLIPBOARD%' every time (assuming you have variable saves enabled in variable settings). Getting CLIPBOARD to a static variable is not pretty but I have a solution. Create this macro and save it: CLIPBOARD_IN.mmmacro1 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING%::%STRING% 2 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING1%:: | 3 | IF | FILE | D:\Macro\TX\in.mmmacro | EXIST | DELETE FILE | D:\Macro\TX\in.mmmacro 4 | RUN ACTION | | | | OUTPUT TO FILE | D:\Macro\TX\in.mmmacro::APPEND::1%STRING1% RUN ACTION%STRING1% %STRING1% %STRING1% %STRING1% DEFINE STRING VARIABLE%STRING1% 5 | RUN ACTION | | | | OUTPUT TO FILE | D:\Macro\TX\in.mmmacro::APPEND:: %STRING% 6 | RUN ACTION | | | | WAIT SECONDS | 1 7 | RUN ACTION | | | | RUN VIA CMD /C | echo ^:^:%CLIPBOARD%>>d:\macro\tx\in.mmmacro 8 | RUN ACTION | | | | WAIT SECONDS | 1 9 | FOR | EACH | LINE IN | d:\macro\tx\in.mmmacro | RUN 10 | RUN ACTION | | | | MESSAGE PROMPT | Value of STRING: %STRING%::STRING VALUE Line 1 we define STRING to the word '%STRING%' Line 2 we define STRING1 to ' |' (my current delim value is ' | ' however the trailing space is cut by the variable assignment) Line 3 if my input file exists I delete it Line 4 we start to create the file in.mmmacro. Notice the extra space I added after STRING1 for the correct delimiter. Line 5 we add the value of ' %STRING%'. We do this on a new APPEND line. Line 6 wait a second for the output just in case
Line 7 we add the TRUE value of CLIPBOARD to in.mmmacro Line 8 wait a second for the command window just in case Line 9 we run in.mmmacro and add in the TRUE value of %clipboard%
CLIPBOARD_IN.mmmacro can be called from other running macros like this: EXAMPLE.mmmacro1 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING%::Before 2 | RUN ACTION | | | | MESSAGE PROMPT | START:%string%:: 3 | FOR | EACH | LINE IN | D:\Macro\CLIPBOARD_IN.mmmacro | RUN 4 | RUN ACTION | | | | MESSAGE PROMPT | END:%string%:: Hope this helps, Steve.
|
|
|
Post by Johnc on Aug 14, 2018 1:48:22 GMT
Wow! Thanks Steve! Now I fully understand how %CLIPBOARD% should be used in MMM to spare string variables! Your complicated sub-macro worked too! (after I changed all the paths to my folder path) Indeed it is amazingly complicated and I don't claim to fully understand it but it works! It comes pretty handy and I will just blindly use it LOL!
Thank you so much Steve! You are the best! Cheers, John
|
|
|
Post by Johnc on Aug 16, 2018 14:48:07 GMT
Just wrote a new macro with MMM V6.7.0, making use of your CLIPBOARD_IN.mmmacro technique. It worked beautifully though I don't really know how it works lol! Would be nice to have a built-in function like this Thanks so much!
|
|
|
Post by Steve on Aug 16, 2018 23:45:59 GMT
Thanks John. Yeah I agree, there needs to be an easier way to get real data in from the environment rather than hacking the CLIPBOARD like we have.
|
|