ObscureStar - 2012-12-13

I wrote the following little bit of applescript last night to make a link from freemind to voodoopad on mac.

tell application "FreeMind"
    activate
    set oldclipboard to the clipboard
    tell application "System Events" to keystroke "c" using {command down, shift down}

end tell
delay 0.25
tell application "VoodooPad"
    activate
    do shell script "pbpaste | textutil -convert txt -stdin -stdout -encoding 30 | cut -d'<' -f1 | tr -d '\\n' | tr -d '\\r' | pbcopy"
    set voodoopage to the clipboard
    -- set the clipboard to oldclipboard

    open "Users:MYUSER:Documents:MYWIKI.vpdoc" as alias
    tell front document to open page with name voodoopage
end tell

To use, save the applescript as an app.  EG:  voodoolink.app
Name your Freemind node to the page name in voodoowiki.
Create a hyperlink to file from freemind to voodoolink.app
Now clicking the node should jump to your wiki.

After the first one, you can copy single node, paste, edit node, and change the text to link to a different page.

Things that could be improved:
- Using pbpaste and cmdln is awkward but I couldn't get any variants of the following to work:

set the clipboard to «class ktxt» of ((the clipboard as text) as record)

-  The static delay will probably fail in high system load.    Ideally I should wait for some response from freemind to let me know it has copied the text but I'm not terribly experienced with applescript and it was late.   If anyone has a better solution I'd appreciate it.