It is currently October 19th, 2020, 3:50 pm

Plugin QuickLink

Share and get help with Plugins and Addons
cfixd
Posts: 31
Joined: September 1st, 2014, 1:38 am

Plugin QuickLink

Post by cfixd »

Get the name, path, icon of a file/folder and write to the config by drag in the file to the rainmeter window or choose file in a window.
It's used to set the dock, launcher or something like that.
It's still a "Work in Progress" plugin.

I decided to write this plugin after seen the Drag&Drop trash plugin by gafusss
http://rainmeter.net/forum/viewtopic.php?f=18&t=20518

Forgive my poor English.

Options and Bangs:
Measure Options:

Drag= (Default:0)
1:Enable drag during initialize

GetTarget= (Default:1)
1:Get the target and argument of a shortcut, or the path may point to a .lnk file.

IconCache=
A existing folder for saving the images

IconSize= (Default:2)
0 : 16x16 / 20x20(125%)
1 : 32x32 / 40x40(125%)
2 : 48x48 / 60x60(125%)
3 : 256x256 / 256x256

IconClassify= (Default:1)
1:The icon will be same for the same type of files (e.g. xxx.doc), except the .exe file

IconReplace= (Default:1)
1:Replace the image when image file exists.

LinkAction=
Bangs to command after file is dragged in or chosen.
One or more of followings can be used in LinkAction:

$Path$
the file path

$[Path]$
the file path with format ["path" argument] ,remember to write as """$[Path]$"""
When there is no argument,
[!SetOption $Meter$ LeftMouseUpAction """$[Path]$"""] equals to
[!SetOption $Meter$ LeftMouseUpAction """["$Path$"]"""]

$Name$
the file name

$Meter$
the meter name inputed by bang

$N$
the number in the meter name, recommend whlie using variables
e.g. [!WriteKeyValue Variables Path$N$ """$[Path]$"""]

$Icon$
a path to the icon gotten, as a .png file

Bangs:

_#CurrentSection#
Input meter name after '_' when drag is enabled.

+#CurrentSection#
Input meter name after '+',then a window will be opened for choosing file/folder.

EnableDrag
Enable the drag

DisableDrag
Disable the drag
Example of measure and meter:
[MeasureQuickLink]
Measure=Plugin
Plugin=QuickLink
Drag=1
GetTarget=1
IconCache=#@#
IconSize=2
IconReplace=0
IconClassify=1
LinkAction=[!SetOption $Meter$ LeftMouseUpAction """$[Path]$"""][!SetOption $Meter$ Text "$Name$"][!UpdateMeter $Meter$][!Redraw][!WriteKeyValue $Meter$ LeftMouseUpAction """$[Path]$"""] [!WriteKeyValue $Meter$ Text "$Name$"]

[Meter1]
Meter=String
Text=Drag in
MouseOverAction= [!CommandMeasure MeasureQuickLink "_#CurrentSection#"]
LeftMouseUpAction=
RightMouseUpAction=[!CommandMeasure MeasureQuickLink "+#CurrentSection#"]
Example skin and source code
QuickLink_0.9.1e.rmskin
PluginQuickLink_SourceCode_0.9.1.rar
Latest skin in test:
The new options in the test skin may change, and sorry for changing the option.
You'd better not release it with your own skin, or just with beta version.
There is an introduction file in the skin folder.

I've used RmReplaceVariables function ,I'm not sure whether it's thread safe...
QuickLink_0.9.1.2e.rmskin
PluginQuickLink_SourceCode_0.9.1.2.rar
You do not have the required permissions to view the files attached to this post.
Last edited by cfixd on April 14th, 2015, 8:09 am, edited 6 times in total.
User avatar
fonpaolo
Moderator
Posts: 1397
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: Plugin QuickLink

Post by fonpaolo »

Now this is very interesting! :thumbup:

I hope to find some time to try your plugin, because it can really solve the problem I had with almost all the other solutions I used and make my code more lighter and user friendly with less clik.
User avatar
Kaz28100
Posts: 57
Joined: May 3rd, 2012, 3:59 pm
Location: France

Re: Plugin QuickLink

Post by Kaz28100 »

This is really a helpful plugin and user-friendly.
Very great work :)

Ps: It should be pinned ;-)
User avatar
fonpaolo
Moderator
Posts: 1397
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: Plugin QuickLink

Post by fonpaolo »

Ok, I couldn't resist! :lol:

...I can only say it's great. :thumbup:
Not only it must be pinned, but also the Rainmeter team should take in consideration to include it as a plugin, as they've done with AudioLevel.
The main reason is that using this plugin there's no need to rely on third party programs or hybrid solutions.

My only suggestion is to add a way to browse for images (with preview), not only files or folders, to complete the functionality and ease of use.
User avatar
Active Colors
Moderator
Posts: 618
Joined: February 16th, 2012, 3:32 am

Re: Plugin QuickLink

Post by Active Colors »

Oh my God. It's staggering! Amazing!
Besides the functional this plugin has, would it be possible for you to make drag-and-droppable meters?
cfixd
Posts: 31
Joined: September 1st, 2014, 1:38 am

Re: Plugin QuickLink

Post by cfixd »

fonpaolo wrote: My only suggestion is to add a way to browse for images (with preview), not only files or folders, to complete the functionality and ease of use.
I’ve built a 0.9.1.1 version, with ImageAction.
However I can't get the file name only with the meter name unless image must be chosen after file is chosen, I think it's a little unfriendly.
So if image file is chosen, it will be saved as $Meter$.xxx or just get the path.

0.9.1.1 : what's new

BoxStyle= (Default:0)
1:A new dialog box style for win7 when "+#CurrentSection#" is commanded.

ImageAction=
Bangs to command after image file is chosen.
One or more of followings can be used in ImageAction:

$Path$
the image file path

$Meter$
the meter name inputed by bang

$N$
the number in the meter name

Bangs:
&#CurrentSection#
Input meter name after '&',then a window will be opened for choosing image.
ImageAction will be executed after image file is chosen.

$#CurrentSection#
Input meter name after '$',then a window will be opened for choosing image.
ImageAction will be executed after image file is chosen, and the image file will be copied to IconCache
Last edited by cfixd on April 8th, 2015, 2:38 pm, edited 1 time in total.
cfixd
Posts: 31
Joined: September 1st, 2014, 1:38 am

Re: Plugin QuickLink

Post by cfixd »

Active Colors wrote: Besides the functional this plugin has, would it be possible for you to make drag-and-droppable meters?
It defines the meter with bang "_#CurrentSection#" in MouseOverAction now.
I have no idea how to get the meter automaticlly...

What do you want to do with drag-and-droppable meters?
Last edited by cfixd on April 8th, 2015, 2:38 pm, edited 1 time in total.
User avatar
fonpaolo
Moderator
Posts: 1397
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: Plugin QuickLink

Post by fonpaolo »

cfixd wrote:I’ve built a 0.9.1.1 version, with ImageAction.
However I can't get the file name only with the meter name unless image must be chosen after file is chosen, I think it's a little unfriendly.
So if image file is chosen, it will be saved as $Meter$.xxx or just get the path.
Thanks, I have to eagerly wait until the week-end to find some time to test it.
A quick look at the code in your skin is already telling me that there will be no problems.

I asked to have the ability to also choose an image, simply because there may be a possibility to change the default icon, after using your plugin to set a file or folder path (so, a path is already existing).

I'm already seeing a lot of implementations for your plugin.
cfixd wrote:It defines the meter with bang "_#CurrentSection#" in MouseOverAction now.
I have no idea how to get the meter automaticlly...

What do you want to do with drag-and-droppable meters?
I must thank Active Colors for have posted the question, I was afraid to ask it myself... :lol:

I think we had the same intuition, this will give the chance to move strings (paths) from a meter to another, an easy way to set up launchers or anything else.

Correct me if I'm wrong, Active Colors.
User avatar
jsmorley
Developer
Posts: 21421
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Plugin QuickLink

Post by jsmorley »

While I can see having a skin or even a location in a skin window containing a meter react to an external object from Windows being dropped on it, I think you are going to run into a functional brick wall if you try to treat a meter as an object that can be dragged with the mouse. That just isn't how Rainmeter works.

A meter isn't a distinct "object", but simply graphics that are "drawn" on a single object, the "skin window". Think of the skin window as a "canvas". Once the meters are drawn during the "redraw" cycle of the skin update, they are just pixels. You can never redraw just some individual meter, but only the entire skin window. You will never be able to simply drag a meter to a new location.

In order to trick Rainmeter into treating a meter as an "object" you can manipulate, I think you are going to have to detect the mouse down / drag and just change the cursor to some "I'm dragging" image. Then keep track of what meter "owns" the pixel the mouse was on, and what meter "owns" the pixel where the mouse is released.

I'm not entirely certain how you would implement this, as a meter doesn't REALLY "own" a pixel. When Rainmeter gets a "mouse event" from Windows, it checks to see if any meters, in the order they are in the skin, (last wins if two meters share a pixel location) has a mouse action defined on the meter. If the location of the mouse, when the event takes place, is on a solid pixel and within the meter container boundaries, defined by X/Y/W/H relative to the skin window, then the mouse action is fired.

I'm not trying to be discouraging, but You are rapidly getting into an area where you are going to run up against what Rainmeter "is" vs. what Rainmeter "isn't".
cfixd
Posts: 31
Joined: September 1st, 2014, 1:38 am

Re: Plugin QuickLink

Post by cfixd »

jsmorley wrote: In order to trick Rainmeter into treating a meter as an "object" you can manipulate, I think you are going to have to detect the mouse down / drag and just change the cursor to some "I'm dragging" image. Then keep track of what meter "owns" the pixel the mouse was on, and what meter "owns" the pixel where the mouse is released.
Thank you for your reply very much.
I think I've misunderstood the "drag-and-droppable meters" before.

As you've said, when "From#CurrentSection#", change the cursor, set the skin undraggable, when mouse is released on another meter, "To#CurrentSection#" is commanded.Then both meter names are goten.
Is this the aim of the "drag-and-droppable meters" ?

However it's hard to move strings from one to another and maybe a lua script will be better for this.

e.g:
[Meter1]
LeftMouseDownAction=[!CommandMeasure LUA "From#CurrentSection#"]
LeftMouseUpAction=[!CommandMeasure LUA "To#CurrentSection#"]

[Meter2]
LeftMouseDownAction=[!CommandMeasure LUA "From#CurrentSection#"]
LeftMouseUpAction=[!CommandMeasure LUA "To#CurrentSection#"]
Last edited by cfixd on April 8th, 2015, 3:08 pm, edited 1 time in total.