Skip navigation
Currently Being Moderated

Manipulating the clipboard

Jul 4, 2013 6:26 AM

Tags: #clipboard

I wanted to set up a command and shortcut to surround clipboard contents by [[ and ]] before pasting.

The purpose is to insert temporary citations which are put into the clipboard by an external application (EndNote).

 

The method mentioned in discussion Can I pull clipboard contents into a script variable is more than clunky: use a file as an intermediate.

 

On the other hand in AutoHotKey it is very easy to manipulate the clipboard. I have even used it to make code-coversions on the fly.

^y::                                    ; {LaBonté, 1989 #11}
  Transform, utfString, Unicode         ; Retrieve the clipboard's Unicode text as a UTF-8 string
  StringTrimLeft, utfString, utfString, 1 ; remove EndNote's braces
  StringTrimRight,utfString, utfString, 1
  utfString := "[[" . utfString . "]]"  ; sourround with double brackets
  Transform, Clipboard, Unicode, %utfString%
  Send, ^v                              ; [[LaBonté, 1989 #11]]
return

Hence I decide to keep this function outside of the script and will invoke the AHK script (converted to an exe) at the start of the script. This will establish the shortcut for the function.

 
Replies
  • Currently Being Moderated
    Jul 14, 2013 4:33 AM   in reply to K.Daube

    Klaus,

     

    If I understand it correctly, you want to put a citation from the clipboard into your FM document by pasting, but the pasted text should have double angle brackets around it to make it show up as a citation. I would think that the easiest solution would be to have a script for "Paste as citation" instead of trying to tweak the clipboard contents before pasting it. The "Paste as citation" simply pastes whatever is in the clipboard to the text location and then adds the double angle brackets. Adding the "Paste as citation" command to the Edit menu is not a big deal and you can define your own shortcut to invoke the command.

     

    Would this not be much easier than changing the cilpboard contents ?

     

    Good luck

     

    Jang

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points