No internet connection
  1. Home
  2. Support

Get Clipboard text throwing funky message.

By Mike Wax @mikewax
    2020-10-18 05:20:49.689Z

    I have a script that copies the current file name that's in the Bounce Name text field. Than i have a prompt that asks what to name the file, and should show the Clipboard text (so you knonw what the current name is if you want to keep it).

    This is the message i get: What would you like your File Name to be? Your Clipboard text is SoundFlow.Shortcuts.Automation.Actions.ClipboardGetTextResult

    Not sure what that means or how to fix it.
    Thanks so much for the help!

    // Copy current file name to clipboard in case you want it.
    sf.ui.proTools.windows.whoseTitle.is('Bounce').first.textFields.first.elementClick();
    
    sf.keyboard.press({
        keys: "cmd+a, cmd+c",
    });
    
    sf.wait({
        intervalMs: 500,
    });
    
    // Prompt for file name
    var clipboardText = sf.clipboard.getText();
    var fileName = prompt("What would you like your File Name to be? " + "Your Clipboard text is " + clipboardText);
    
    
    
    // Place file name into FILE NAME field.
    sf.ui.proTools.windows.whoseTitle.is('Bounce').first.textFields.first.elementSetTextFieldWithAreaValue({
        value: fileName,
    });
    
    Solved in post #2, click to view
    • 5 replies
    1. Hi Mike,

      You need to take the text output variable of the getText() action call:

      var clipboardText = sf.clipboard.getText().text;
      
      Reply1 LikeSolution
      1. Mike Wax @mikewax
          2020-10-19 04:49:32.773Z

          Dam, i was so close!

          So The text I was getting was basically just pulling the function, which is why i was getting that message? And adding the .text; converts it to text?

          1. Mike Wax @mikewax
              2020-10-19 04:56:00.922Z

              Ok, quick follow-up question...how do i stylize the text that i'm putting in the prompt?

              So for this text:
              var fileName = prompt("What would you like your File Name to be? " + "Your Clipboard text is " + clipboardText);

              How could i make it this?
              var fileName = prompt("What would you like your File Name to be? " + <br /> + "Your Clipboard text is " + <b>clipboardText</b>);

              If that makes sense?
              Thank you!

              1. Hi Mike,

                And adding the .text; converts it to text?

                Kind-of.. All SoundFlow actions return an object consisting of multiple potential properties. So you always need to specify the specific output property you want. There's no actual conversion happening, but yes you're telling SF that you want the text output of the clipboard getText action by adding the .text

                Unfortunately, prompt doesn't support rich text formatting.
                Instead, you could add a return:

                var fileName = prompt("What would you like your File Name to be?\nYour Clipboard text is:\n\n" + clipboardText);
                
                1. Mike Wax @mikewax
                    2020-10-19 17:14:05.401Z

                    Bummer about the formatting, but the rich text at least helps.

                    Totally makes sense on the SoundFlow actions.
                    Thank you so much!