How to use the clipboard.dispatchRead 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
response = 'Border blinking is off.';
                        } else {
                            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] + '"';
                        }
                    }
github Ylianst / MeshCentral / agents / meshcore.js View on Github external
} catch (e) { }
                            break;
                        }
                        */
                        case 'openUrl': {
                            // Open a local web browser and return success/fail
                            MeshServerLog('Opening: ' + data.url, data);
                            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': {