No internet connection
  1. Home
  2. How to

Modify clipboard value

By Richard Furch @Richard_Furch
    2020-10-12 20:41:47.368Z

    Trying to pick up a number from a value field in protools.

    Have done so by clicking, then pressing command c. So I have the value in the clipboard.

    Would like to change a variable starting from the clip board plus a modification.

    Such as (improvised): clipboardvalue=clipboardvalue+0.5

    Then paste the clipboard back into the field. Basically increasing value of whatever is in the field by 0.5 db everytime I press the key.

    How do I access clipboard?

    Thanks

    • 20 replies

    There are 20 replies. Estimated reading time: 9 minutes

    1. Kitch Membery @Kitch2020-10-12 20:54:29.815Z

      Hi @Richard_Furch,

      What field are you trying to adjust the value of?

      1. R
        In reply toRichard_Furch:
        Richard Furch @Richard_Furch
          2020-10-12 20:59:15.848Z

          Well, a few once I know how to do it :)

          Currently trying to increase the gain field in the EQ of clip effects in the high end by 0.5db every time I press a button.

          But copy, (computing values from clipgain plus modifier), paste will be a building block for many macros I'm writing. That's what I'm used to from macro languages like Keyboard Maestro.

          1. Hi Richard,

            Just a note here - typically, with SoundFlow, you don't need this to cycle through the clipboard, since we can read the value without having to simulate a Cmd+C keystroke.

            1. RRichard Furch @Richard_Furch
                2020-10-12 21:36:40.940Z

                Cool, Christian! Is there a list of the name of fields that I can read (or variable names) so I can address them?

                1. RRichard Furch @Richard_Furch
                    2020-10-12 21:37:24.689Z

                    I'm gonna assume you're German. Grüße an die alte Heimat, früher Berlin, jetzt LA.

                    1. Actually, I'm Danish, but I used to live in Berlin so I do speak "ein Bisschen Deutch"... ;)

                      @Kitch - maybe this would be worth showing in a video? How to use Click UI Element to find a field, then swap it out into a script and use title invalidate on it
                      Richard, this is a somewhat broad topic, but I think if we can get a video to showcase how to read information from the UI, it would be helpful to many.

                      1. Kitch Membery @Kitch2020-10-12 22:14:10.367Z

                        Absolutely worth doing a video of this @chrscheuer. I'll get on it!

                        1. RRichard Furch @Richard_Furch
                            2020-10-12 22:31:17.540Z

                            awesome. Yes. modifying values in fields is the foundation of many scripts.

                            1. In reply toKitch:

                              If this video can also include an explanation for why and when to use invalidate it would be a great help. I still get a bit confused about it at times.

                              1. Kitch Membery @Kitch2020-10-13 16:45:02.193Z

                                @Chris_Shaw,

                                Darn it! I am literally about to upload the tutorial and unfortunately didn't cover that. There is however a great post on invalidation in the forum where @chrscheuer goes into how and why in detail. It's worth a read. I may do a video on invalidation down the track :-)

                                Here is the link;

                                Rock on!

                            2. In reply tochrscheuer:
                              Kitch Membery @Kitch2020-10-12 22:30:27.610Z

                              @Richard_Furch,

                              This may not be easily achievable for the Clip Effects Parameters as the individual UI Elements in are not visible to SoundFlow, I'll take a further look and see if I can find a workaround.

                              1. RRichard Furch @Richard_Furch
                                  2020-10-12 22:36:01.351Z

                                  Ok. Sooo. Then we'd still need a:

                                  Command C

                                  (modify clipboard by operation or amount)

                                  Command P

                                  Version. Possible?

                                  1. Yea.. In that case you should be able to use this workflow here to learn how to click in the right place:

                                    Then, just add a "Press Keys" action for Command C.

                                    Now, you'd need to convert that to a script to modify the clipboard, but let's get there when you've gotten these bases covered.

                                    1. Kitch Membery @Kitch2020-10-12 22:42:57.749Z

                                      @chrscheuer, It seems that the only way to copy the text from the Gain text field is via a right click and selecting the copy field. Is there a way around this?

                                      1. Kitch Membery @Kitch2020-10-12 22:50:27.113Z

                                        @chrscheuer I've tried to map the elements within the Clip Effects window to possibly use AXIncrement with no success. I've also tried the macro below and it does not yield the results I'd expect (Expected Result: Opening the Right Click Menu);

                                        Have you any thoughts on how to get this to work?

                                        FYI, I will still do that video of course..

                                        1. Oh, shoot. Yea, I see. They appear to be very, very unfriendly to UI automation these ones :/

                                          1. RRichard Furch @Richard_Furch
                                              2020-10-26 18:27:25.450Z

                                              So, following up. In lieu of being able to address every field, how can we modify the clipboard? Or copy clipboard to a variable, modify that and paste it back into the clipboard. It's the easiest way to work around a non-addressable field I think.

                                              1. You can use something like this to increment the clipboard's value with 0.5 (expecting the clipboard to contain a number with "." as the decimal point):

                                                
                                                let textFromClipboard = sf.clipboard.getText().text;
                                                
                                                let textAsNumber = Number(textFromClipboard.trim());
                                                
                                                let newNumber = textAsNumber + 0.5;
                                                
                                                sf.clipboard.setText({ text: newNumber + '' });
                                                
                                                
                                                1. RRichard Furch @Richard_Furch
                                                    2020-11-03 22:46:31.653Z

                                                    This by the way, worked great and is super helpful.

                                                    1. Kitch Membery @Kitch2020-11-04 00:40:35.824Z

                                                      Here is another option using keystrokes (as these fields don't allow you to copy text due to the fact a clip is selected).

                                                      Change the functions call value as follows;
                                                      To increase the gain up 0.5 dB adjustFrequencyGain(0.5);
                                                      To decrease the gain up -0.5 dB adjustFrequencyGain(-0.5);

                                                      function adjustFrequencyGain(variation) {
                                                          sf.ui.proTools.appActivateMainWindow();
                                                      
                                                          sf.ui.proTools.mainWindow.children.whoseRole.is("AXStaticText").whoseValue.is('Clip:').first.mouseClickElement({
                                                              relativePosition: { "x": 551, "y": 75 },
                                                          });
                                                      
                                                          sf.wait({ intervalMs: 100 });
                                                      
                                                          let newNumber;
                                                      
                                                          if (variation >= 0) {
                                                              sf.keyboard.press({
                                                                  keys: "up",
                                                                  fast: true,
                                                                  repetitions: variation * 10
                                                              });
                                                          } else {
                                                              sf.keyboard.press({
                                                                  keys: "down",
                                                                  fast: true,
                                                                  repetitions: variation * -10
                                                              });
                                                          }
                                                      
                                                          //sf.wait({ intervalMs: 100 });
                                                      
                                                          sf.keyboard.press({
                                                              keys: "return",
                                                          });
                                                      }
                                                      
                                                      adjustFrequencyGain(0.5);