Copy to clipboard with n4m

fraction's icon

does anyone know a node.js script "copy to clipboard" for a string as input that works in max?
i tired several without success.
thx!

Source Audio's icon

why bother with node ?
you seem to be using shell ...
Windows :
echo "string to copy" | clip
Mac:
echo "string to copy" | pbcopy

Source Audio's icon

P.S. shell on windows can run powershell commands as well.
for example
Powershell.exe Get-Clipboard (shell outputs clipboard contents)
or Powershell.exe Set-Clipboard -Value "string to copy into clipboard"
or use -Append to add to clipboard without wiping it etc

fraction's icon

hi guys,
thanks. I know shell on both OS. If i ask for n4m script it's because i have my reasons.
There are few such tasks that are more appropriated to be handled by js/n4m script, rather by externals, which also would be better for further development/maintenance.

i will try to see if i can adapt scripts from npm.

fraction's icon

here you go with npm module :" copy-paste"

const readline = require("readline");
const ncp = require("copy-paste");
const Max = require('max-api');

const rl = readline.createInterface({
input: process.stdin,
terminal: false
})

rl.on("line", async line => {
ncp.copy(line)
})