It is currently April 19th, 2024, 9:10 am

Clipboard Plugin

Share and get help with Plugins and Addons
User avatar
Brian
Developer
Posts: 2679
Joined: November 24th, 2011, 1:42 am
Location: Utah

Clipboard Plugin

Post by Brian »

Clipboard Plugin:
Version 1.0.3

This is a simple little plugin that will copy the contents of the Windows Clipboard. Once loaded, the plugin "remembers" any text that is copied to the Windows Clipboard until the skin is unloaded or refreshed. This plugin uses the Parent/Child structure.

Options include:

For Parent measures only:
  • TextOnly - When TextOnly=1, only text items are copied into the Parent measure. TextOnly=0 is default.
  • ErrorString - If non-text is copied into the Windows Clipboard, this string is copied into the Parent measure. (An empty string is default)
  • MaxIndex - This number represents the number of indices that will be available. This is to avoid high memory usage when running the skin for a long period of time. It is recommended to use the same number as indices you plan on referencing. Set this to 0 to only remember the current contents of the clipboard. If you set "MaxIndex=-1", this will remember everything you copy into the clipboard, this is not recommended. MaxIndex=15 is default.
For Child measures only:
  • ParentName - Represents the name of the Parent measure. Do not include brackets.
For both Parent and Child measures:
  • Index - Represents the current clipboard contents, or "old" text. Index=0 is default.
Commands:
Commands only work on Parent measures.
  • Clear - Clears contents of the clipboard. Also clears all indices of the Parent measure.
    Usage: !CommandMeasure ParentName Clear
  • ClearIndex n - Clears index n from the Parent measure. If n=0, the Windows Clipboard is also cleared, also Index=0 of other Parent measures are also cleared.
    Usage: !CommandMeasure ParentName "ClearIndex 2"
  • Copy string - Copies string into the Windows Clipboard.
    Usage: !CommandMeasure ParentName "Copy Hello World!"
    - Removed in version 1.0.1 - use !SetClip instead
  • CopyIndex n - Copies index n from the Parent measure into the Windows Clipboard.
    Usage: !CommandMeasure ParentName "CopyIndex 2"
Warning: When using the Clipboard plugin with a String meter, it is highly recommended that you use a W and H to define its size, otherwise you can use up a lot of screen space to display the entire string - especially when using DynamicWindowSize.

More information can be found here.

Changes can be found here.

Below is a simple test skin I made to show how it works. (The plugin is included with the skin, or you can down the plugin here)

-Brian
You do not have the required permissions to view the files attached to this post.
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Clipboard Plugin

Post by poiru »

I'd suggest using the SetClipboardViewer function with a listener window for change notifications. With the current implementation, changes may be missed (if the clipboard is altered multiple times between updates).
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Clipboard Plugin

Post by Kaelri »

Nice! I was expecting to use Lua to keep track of the "history," but your built-in solution will probably be more robust (especially with poiru's suggestion).

Question: is there a (functional) difference between !CommandMeasure ParentName "Copy Hello World!" and !SetClip "Hello World!"?
User avatar
Brian
Developer
Posts: 2679
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Clipboard Plugin

Post by Brian »

poiru wrote:I'd suggest using the SetClipboardViewer function with a listener window for change notifications. With the current implementation, changes may be missed (if the clipboard is altered multiple times between updates).
True, I did actually realize this when making the plugin, however SetClipboardViewer involves a slightly more complex implementation then what I chose. I will probably update to this method when I get time.

If we get to a point of dropping support for Windows XP, AddClipboardFormatListener is actually the preferred function.
Kaelri wrote:Nice! I was expecting to use Lua to keep track of the "history," but your built-in solution will probably be more robust (especially with poiru's suggestion).

Question: is there a (functional) difference between !CommandMeasure ParentName "Copy Hello World!" and !SetClip "Hello World!"?
Honestly, I had forgotten about !SetClip. But, to answer your question: No, there is not a difference between them as they both use the same function to copy text into the clipboard. So I might drop support for this command.

-Brian
User avatar
Brian
Developer
Posts: 2679
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Clipboard Plugin

Post by Brian »

Alright, I removed support for the command "Copy". Use the !SetClip bang instead.

Check the original post for more details.

I also changed the test skin to include the latest plugin, and it now uses the "!SetClip" bang.

-Brian
User avatar
UnforgivenRevival
Posts: 310
Joined: June 7th, 2012, 2:25 am
Location: Philadelphia, PA

Re: Clipboard Plugin

Post by UnforgivenRevival »

Exactly what I was looking for! Great job! :thumbup:
User avatar
Brian
Developer
Posts: 2679
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Clipboard Plugin

Post by Brian »

TextOnly now accepts "0" and "1" instead of "Off" and "On", respectively. This change is to be more consistent with how other "on/off" options work in Rainmeter.

-Brian
Alex Becherer

Re: Clipboard Plugin

Post by Alex Becherer »

thanks :)
User avatar
Brian
Developer
Posts: 2679
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Clipboard Plugin

Post by Brian »

Updated to version 1.0.3. This change adds MaxIndex to parent measures to avoid high memory usage overtime.

Check the original post for details.

-Brian
lexy
Posts: 4
Joined: September 29th, 2012, 2:58 pm

Re: Clipboard Plugin

Post by lexy »

Could this be implemented to use some clipboard sync services? I'd like to be able to sync my clipboard contents between computers and pull it's output through rainmeter. Any clue on how one could do that?