It is currently April 16th, 2024, 8:23 pm

Clipboard manager (C# + Rainmeter)

Share and get help with Plugins and Addons
zzeneg
Posts: 7
Joined: October 18th, 2011, 10:07 am

Clipboard manager (C# + Rainmeter)

Post by zzeneg »

Hi everybody.
I'm Rainmeter fan and it has totally replaced Windows Gadgets for me, except one gadget - Clipboard Manager. It monitores clipboard, save text from it and show you this history. I think it's very useful, and so I want to find Rainmeter skin with same functionality.
Unfortunately, I couldn't find such skin, and (as I realise) this functionality cannot be reached with standard Rainmeter functions or existing plugins. So, as I'm .NET (C#) developer (beginner only :) ) I've decided to write C# application, which will iteract with Rainmeter (application as back-end, and Rainmeter as front-end :) ).
The easiest way to iteract with Rainmeter is to programmatically change settings file and refresh Rainmeter.
I found code for monitoring clipboard, writing text to Variables.inc and refreshing Rainmeter. Then I made a skin for Rainmeter, which loads values from file and show them to user. Click on text line in skin launches another application, that puts this text to clipboard. I also have to write this application, because I need to store and handle multiline text (Rainmeter variable doesn't support it).

This is examle skin looks like:
Image

Tray menu:
Image

Instructions:
- download Clipboard.zip and unzip it to folder with your Rainmeter theme. Refresh your Rainmeter and enable Clipboard.ini skin.
- launch GetClipboard.exe. You can see an icon of application in system tray (icon looks like Rainmeter's). Only one instance of application can be launched.
- try to copy some text (Ctrl+C or another way).
- if everything is allright, you'll see copied text in Rainmeter skin.
- try to copy another text. This text will be added to skin.
- now try to click on second line. This line will became first, and it's value will be copied to clipboard.


Settings
Application also support settings file, in which you can set your path to rainmeter.exe, variables.inc, variable name and hide tray icon. Settings file will be automatically generated and opened in case of some error, or you can manually create it by clicking "Settings" in ContextMenu in tray.
Settings file name should be "GetClipboard.ini", and it should contain section name "[Settings]". There are 4 available options:
- VariablesPath (string) - path to variables.inc file with clipboard variables in it. By default, application searches this file in the same folder.
- VariableName (string) - name of clipboard variable. All variables are named as VariableName0, VariableName1, VariableName2, etc. You need to use these names in your Rainmeter skin's code. Default value - "clipboard".
- RainmeterPath (string) - path to rainmeter.exe. By default, application searches this file in %ProgramFiles%/Rainmeter/.
- EnableTrayIcon (bool). You need to set it to "0", if you want to hide tray icon.

Example of file:
[Settings]
VariablesPath=C:\Users\UserName\Documents\Rainmeter\Skins\Rainify\@Settings\Variables.inc
VariableName=ClipboardApp
RainmeterPath=C:\Soft\Rainmeter\Rainmeter.exe
EnableTrayIcon=0

If you want to store more than 5 lines, you need to modify skin and Variables.inc.

Credits
Arcticle about monitoring clipboard in C#
Storing settings in .ini file
Rainmeter skin was originally created by poiru and named Rainify (many thanks to him for this brilliant skin)

Downloads
Example skin and source code are attached to this post

Any questions, replies, report bugs are welcome.

P.S. I'm sorry for my language, English is not my native.
You do not have the required permissions to view the files attached to this post.
Last edited by zzeneg on January 8th, 2014, 6:23 am, edited 2 times in total.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Clipboard manager (C# + Rainmeter)

Post by jsmorley »

Clever bit of work! I'd rather you used a different icon to eliminate confusion in the system tray, but other than that this looks real nice.
User avatar
AlC
Posts: 329
Joined: June 9th, 2011, 6:46 pm

Re: Clipboard manager (C# + Rainmeter)

Post by AlC »

Hey zzeneg,

I really like the idea and will use your skin.
But there are 2 things, which would be nice I think.

1. When I select an older clipboard, it does a full refresh. Would be nicer if it only refresh the clipboard skin and not all skins.

2. A bang that close the GetClipboard.exe process, like this for example:
MiddleMouseDownAction=!Execute ["#CURRENTPATH#\GetClipboard.exe" "Close"]

So can you do that, is it possible ?
Rainmeter - You are only limited by your imagination and creativity.
zzeneg
Posts: 7
Joined: October 18th, 2011, 10:07 am

Re: Clipboard manager (C# + Rainmeter)

Post by zzeneg »

Hi AlC! Thank you for your reply.

1. I didn't find an opportunity to refresh one skin through external program :( Do you know how can I do this?

2. It is impossimble to close any application using bangs, because they can only start applications... The only way - to write some GetClipboardKiller.exe :)
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Clipboard manager (C# + Rainmeter)

Post by poiru »

zzeneg wrote:2. It is impossimble to close any application using bangs, because they can only start applications... The only way - to write some GetClipboardKiller.exe :)
You could also have GetClipboard.exe close existing GetClipboard.exe processes if /CLOSE or something is passed to it.
User avatar
AlC
Posts: 329
Joined: June 9th, 2011, 6:46 pm

Re: Clipboard manager (C# + Rainmeter)

Post by AlC »

To 1
If you send a kind of bang from your exe to RM, then ... maybe you use !RefreshApp instead of !Refresh Clipboard.
(I have no idea of higher programming languages, so it's just a very poor try to help you, sorry)

But it would wonder me, if you can't do this.

Edit:
I tried now other little addons like RainRGB, RainFile, ColorPicker and every addon do a full refresh, so apperently you can't do this unfortunately.
Or a full refresh was wanted in the addons (that could be, too).
Rainmeter - You are only limited by your imagination and creativity.
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: Clipboard manager (C# + Rainmeter)

Post by dragonmage »

zzeneg wrote:Hi AlC! Thank you for your reply.

1. I didn't find an opportunity to refresh one skin through external program :( Do you know how can I do this?

2. It is impossimble to close any application using bangs, because they can only start applications... The only way - to write some GetClipboardKiller.exe :)

1. Definitely possible. If you use the skin to start GetClipboard.exe you can have the skin send the configname to GetClipboard.exe (or to your settings file I guess) with #CURRENTCONFIG#. Then have GetClipboard.exe use !Refresh and the configname that was given instead of !RefreshApp. Now I normally would not suggest having a skin autorun an exe when it is loaded, but the skin is kind of pointless without it.
I would probably on first load of the skin make a "popup" in the skin that asks the user if they want to auto start GetClipboard.exe when the skin loads. If they select "Yes" then a variable is changed which will allow the skin to start GetClipboard.exe with OnRefreshAction=

Here is your skin with the AutoStart variables set up. I didn't add the "popup" but it should be easy enough for you. If you choose to have GetClipboard.exe pull the config name from the settings file you could add
[!WriteKeyValue Settings ConfigName #CURRENTCONFIG# "#CURRENTPATH#\GetClipboard.ini"]
to
on=!Execute ["#CURRENTPATH#\GetClipboard.exe"]

Code: Select all

[Rainmeter]
Author=poiru
AppVersion=2001000
Update=1000
OnRefreshAction=#AutoStart#
MouseActionCursor=0
MiddleMouseDownAction=!RainmeterDeactivateConfig
MouseLeaveAction=!Execute [!RainmeterHideMeter Shutdown][!RainmeterHideMeter Restart][!RainmeterHideMeter Logout][!RainmeterHideMeter X][!RainmeterRedraw]

[Metadata]
Name=Clipboard
Description=Save multiple text values from clipboard.
Instructions=Click on the line to copy it to clipboard
Version=1.0.0
License=Creative Commons BY-NC-SA 3.0

[Variables]
on=!Execute ["#CURRENTPATH#\GetClipboard.exe"]
off=!Execute
AutoStart=#on#
Page=1
@Include=Variables.inc

; STYLES ======================================

@Include2=Styles.inc

; METERS ======================================

[Outline]
Meter=IMAGE
MeterStyle=sOutline
ImageName=200x116.png

[TextArea]
Meter=IMAGE
MeterStyle=sTextArea
H=116

[Gradient]
Meter=IMAGE
MeterStyle=sGradient
MouseOverAction=!Execute [!RainmeterShowMeter Shutdown][!RainmeterShowMeter Restart][!RainmeterShowMeter Logout][!RainmeterShowMeter X][!RainmeterRedraw]

[Title]
Meter=STRING
MeterStyle=sTitle
Text="Clipboard Manager"
LeftMouseUpAction=!Execute ["#CURRENTPATH#\GetClipboard.exe"]

[X]
Meter=BUTTON
MeterStyle=sX

[Left1]
Meter=STRING
Y=25r
MeterStyle=sLeft
Text="#clipboard0#"
LeftMouseDownAction=!Execute ["#CURRENTPATH#\SetClipboard.exe" "#clipboard0#"]

[Left2]
Meter=STRING
MeterStyle=sLeft
Text="#clipboard1#"
LeftMouseDownAction=!Execute ["#CURRENTPATH#\SetClipboard.exe" "#clipboard1#"]

[Left3]
Meter=STRING
MeterStyle=sLeft
Text="#clipboard2#"
LeftMouseDownAction=!Execute ["#CURRENTPATH#\SetClipboard.exe" "#clipboard2#"]

[Left4]
Meter=STRING
MeterStyle=sLeft
Text="#clipboard3#"
LeftMouseDownAction=!Execute ["#CURRENTPATH#\SetClipboard.exe" "#clipboard3#"]

[Left5]
Meter=STRING
MeterStyle=sLeft
Text="#clipboard4#"
LeftMouseDownAction=!Execute ["#CURRENTPATH#\SetClipboard.exe" "#clipboard4#"]

2. You would have to make GetClipboard.exe accept an argument to close
Bloody_T
Posts: 9
Joined: November 21st, 2011, 3:50 pm

Re: Clipboard manager (C# + Rainmeter)

Post by Bloody_T »

great prog, really hope it gets updated to accept file clips, cause until then im sticking to clipboarder (a desktop gadget), although it isnt quite so pretty , as i can customize yours to fit my theme :P.., acceptance of screenshots, and file clips is a dealbreaker.
(the rainmeter UI should just show the filename of whatevers copied, not a picture)

also i agree it probably should open the clipboard exe automatically :P, and close it respectively, (the rainmeter UI should just show the filename of whatevers copied, not a picture)
Bloody_T
Posts: 9
Joined: November 21st, 2011, 3:50 pm

Re: Clipboard manager (C# + Rainmeter)

Post by Bloody_T »

I know its been practically forever, but I ended up updating this skin to fit with gnometer today...
Just throw these files in the same folder, replacing any duplicates and then refresh the skin
You do not have the required permissions to view the files attached to this post.