15 Replies Latest reply on Sep 5, 2016 5:56 AM by Loic.Aigon

    [JS, Win/Mac] String Variable to Clipboard?

    tobias.wantzen Level 1



      I want to set the contents of a string variable to the system clipboard. For Mac it's simple via AppleScript, but how could it work for windows? I searched and read all relevant posts and did some research with google.

      Here's my potion of code:

      // copy to clipboard
      if ( $.os.toLowerCase().indexOf('mac') >= 0 ) {  
          app.doScript ( 'set the clipboard to item 1 of arguments', ScriptLanguage.applescriptLanguage, [_stringOUT] );  // mac
      } else {
          app.doScript ( 'echo ' + _stringOUT + ' | clip', ScriptLanguage.visualBasic );  // win

      A friend of mine tested the Windows part – I'm only working on a Mac –, but it doesn't work. Can someone please help me figure this out?