Clipboard Watcher

Clipboard Watcher

Postby dgm5555 » Sun Feb 02, 2014 9:31 pm

I use this script for copying text I'm reading so I can subsequently arrange it into a mindmap.
If someone is able to extend it to add the ability to paste images into nodes I would be most grateful, as I can't seem figure out how to do it.
I've put (a slightly modified) script on the wiki at: http://freeplane.sourceforge.net/wiki/index.php/Scripting:_Example_scripts#Monitor_Clipboard

Code: Select all
//Script for freeplane to monitor the clipboard and create a new node containing text when it changes
// This script will loop endlessly until a single space (" ") is copied, at which point it will terminate
// David Mckenzie 2/2/14

import java.awt.Toolkit
import java.awt.datatransfer.Clipboard
import java.awt.datatransfer.DataFlavor
import java.awt.datatransfer.StringSelection
 
static void setClipboardContents(final String contents){    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(contents), null)    }
static String getClipboardContents(){    return Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).getTransferData(DataFlavor.stringFlavor)    }

// @ExecutionModes({ON_SELECTED_NODE})
curNode = node
curClip = getClipboardContents()
oldClip = getClipboardContents()
while (!curClip.equals(" ")) {
    if (!(curClip.equals(oldClip))) {
        chldNode = node.createChild()
        chldNode.text = getClipboardContents()
        oldClip = getClipboardContents()
        Toolkit.getDefaultToolkit().beep()
    }
    Thread.sleep(1000)
    curClip = getClipboardContents()
}
Last edited by dgm5555 on Mon Feb 03, 2014 8:51 pm, edited 1 time in total.
dgm5555
 
Posts: 4
Joined: Sun Feb 02, 2014 9:19 pm

Re: Clipboard Watcher

Postby boercher » Mon Feb 03, 2014 2:01 am

Hi, I have given you the permissions to edit the wiki.

Volker
boercher
 
Posts: 644
Joined: Tue Jul 26, 2011 7:13 am


Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 1 guest