How to use the clipboard.read function in clipboard

To help you get started, we’ve selected a few clipboard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Ylianst / MeshCentral / agents / meshcore.js View on Github external
sendConsoleText('OpenURL: ' + data.url);
                            if (data.url) { mesh.SendCommand({ "action": "msg", "type":"openUrl", "url": data.url, "sessionid": data.sessionid, "success": (openUserDesktopUrl(data.url) != null) }); }
                            break;
                        }
                        case 'getclip': {
                            // Send the load clipboard back to the user
                            //sendConsoleText('getClip: ' + JSON.stringify(data));
                            if (require('MeshAgent').isService) {
                                require('clipboard').dispatchRead().then(function (str) {
                                    if (str) {
                                        MeshServerLog('Getting clipboard content, ' + str.length + ' byte(s)', data);
                                        mesh.SendCommand({ "action": "msg", "type": "getclip", "sessionid": data.sessionid, "data": str });
                                    }
                                });
                            } else {
                                require("clipboard").read().then(function (str) {
                                    if (str) {
                                        MeshServerLog('Getting clipboard content, ' + str.length + ' byte(s)', data);
                                        mesh.SendCommand({ "action": "msg", "type": "getclip", "sessionid": data.sessionid, "data": str });
                                    }
                                });
                            }
                            break;
                        }
                        case 'setclip': {
                            // Set the load clipboard to a user value
                            //sendConsoleText('setClip: ' + JSON.stringify(data));
                            if (typeof data.data == 'string') {
                                MeshServerLog('Setting clipboard content, ' + data.data.length + ' byte(s)', data);
                                if (typeof data.data == 'string') {
                                    if (require('MeshAgent').isService) { require('clipboard').dispatchWrite(data.data); } else { require("clipboard")(data.data); } // Set the clipboard
                                    mesh.SendCommand({ "action": "msg", "type": "setclip", "sessionid": data.sessionid, "success": true });
github Ylianst / MeshCentral / agents / meshcore.js View on Github external
response = 'Proper usage: border "on|off"'; // Display correct command usage
                        }
                    }
                    break;
                */
                case 'av':
                    if (process.platform == 'win32') { response = JSON.stringify(require('win-info').av()); } else { response = 'Not supported on the platform'; }
                    break;
                case 'log':
                    if (args['_'].length != 1) { response = 'Proper usage: log "sample text"'; } else { MeshServerLog(args['_'][0]); response = 'ok'; }
                    break;
                case 'getclip':
                    if (require('MeshAgent').isService) {
                        require('clipboard').dispatchRead().then(function (str) { sendConsoleText(str, sessionid); });
                    } else {
                        require("clipboard").read().then(function (str) { sendConsoleText(str, sessionid); });
                    }
                    break;
                case 'setclip': {
                    if (args['_'].length != 1) {
                        response = 'Proper usage: setclip "sample text"';
                    } else {
                        if (require('MeshAgent').isService) {
                            require('clipboard').dispatchWrite(args['_'][0]);
                            response = 'Setting clipboard to: "' + args['_'][0] + '"';
                        }
                        else {
                            require("clipboard")(args['_'][0]); response = 'Setting clipboard to: "' + args['_'][0] + '"';
                        }
                    }
                    break;
                }