Action

Copy remote clipboard

Posted by dchar, Last update over 6 years ago

Copy the clipboard from a remote device.

This action is handy for copying text from a remote device if you don’t have access to something like Universal Clipboard. When modifying short scripts, I find this action faster than saving to and import from the cloud.

Setup

Enter the address of the remote device in the first script step of the action.

You’ll need a simple helper script on the remote device to receive an HTTP request and return the clipboard.

If you have Python, install pyperclip and try the following script.

#!/usr/bin/env python

PORT_NUMBER = 8080

import pyperclip
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer

class S(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header('Content-type','text/plain')
        self.end_headers()
        self.wfile.write(pyperclip.paste())

HTTPServer(('', PORT_NUMBER), S).serve_forever()

Steps

  • script

    const address="192.168.1.1";
    const port=8080;
  • script

    
    
    (() => {
        const url = "http://" + address + ":" + port.toString();
        const http = HTTP.create();
        const resp = http.request({
            "url": url,
            "method": "GET"
        });
        
        if (resp.success) {
            draft.setTemplateTag('remote_clipboard', resp.responseText);
        }
    })();
    
    
  • clipboard

    template
    [[remote_clipboard]]

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.