It is currently June 17th, 2019, 5:50 pm

Drag&Drop[V 3.1.3] - Drag and drop functionallity in Rainmeter, now with even more fancyness!

Share and get help with Plugins and Addons
User avatar
theAzack9
Developer
Posts: 520
Joined: March 2nd, 2016, 6:23 pm

Drag&Drop[V 3.1.3] - Drag and drop functionallity in Rainmeter, now with even more fancyness!

theAzack9 » April 9th, 2016, 10:59 pm

Information

I'm back with a huge rewrite of the entire plugin to make it Cooler, Better, Faster, Stronger.
You can check the changelog at the bottom for all the changes between versions!

Download:
Drag&Drop_3.1.3.rmskin
Redistributable:
Redistributable.zip
You have full permission to include this with your skin

Warning!
the plugin will probably not work if rainmeter is run as administrator due to rainmeter.exe then being a higher priority than the user which stops the possibility to drop items into the window. This is probably dependent on system settings in rainmeter though

Future ideas:
  • Being able to drag files/text from a rainmeter skin
Bugs:
  • None for now(i hope)
Documentation, Rainmeter style!
The measure will always return the path of the last dropped file!

Options

These options can be used on both parents and children
Action                                                        Default: Path | wrote: The action defines what function the plugin has, there are currently six options:

• Move - Moves the file/folder dropped to the path specified in the Path option. Note: if two bounds measures try to move the same file does the first one defined in the ini file always win!
• Copy - Copies the file / folder dropped to the path specified in the Path option.
• Shortcut - Creates a shortcut file (.lnk) to the file / folder dropped to the path specified in the Path option.
• Delete - This moves the file / folder to the recycle bin. It is still possible to undo with CTRL + Z. (This wont delete the file directly, just move it to the recycle bin!)
• Path - This is used to get information about the file dropped.
• FilePath [Deprecated] - Same as the above.

Note:
If this option is not set to any of the values it'll disable the drag&drop for this measure.
If you want to disable the measure properly use the Disabled option!
This is useful if it only should be possible to drop files in a portion of the skin.
Path (required for Move/Copy action!)                                                 | wrote: This is the full path to the directory you want the plugin to move / copy / create shortcut to.
Note:
If the target folder does not exist it'll be created when a file / folder is moved to it!
Silent                                                          Default: 0 | wrote: Stops the plugin from showing any confirmation dialogs.
Note:
This currently only used for the delete action.
ReplaceIfExists                                                      Default: 0 | wrote: Allows the plugin to overwrite existing files.
Note:
This is only needed for the actions move and copy!
FancyRenderer                                                      Default: 1 | wrote: Stops the plugin from using the OLE renderer.
Note:
If this option is changed in runtime while the cursor is dragging an item above the skin, won't it actually change until the next time an item is moved over the skin!
Note 2:
This option only works for the parent. The children will completely ignore it!
Hint:
Why would you ever disable this? ;) (unless your skin is quite small, then it's ok :P )
ProcessAllFiles                                                      Default: 0 | wrote: Allows the plugin to spam the action options to process all files. Each file can be numbered with the $FileNr$ substitute. If this is set to 0 will $FileNr$ always be 1.
Hint:
This is usefull if you want to handle all files that are dropped instead of just the first one.
Child Options

These options are only valid for children.
Parent                                                              | wrote: Defines the parent measure for the current measure.
Note:
This is required for a measure to be a child. If this is not set, will the measure see itself as a parent! This will also invalidate all other child options.
Bounds                                                              | wrote: The bounds in where it is possible to drop a file / folder.
Note:
It is possible to specify either the coordinates + size or a meter in which the measure will get the bounds from.
The coordinates + size is structured like X, Y, Width, Height.
To set this as a meter do you simply specify the name of the meter. This has to be a valid meter!
Example:
Bounds=0,0,100,200
or
Bounds=MeterBounds

Note 2:
If the bounds is a meter will the bounds reset every update!
X [Deprecated]                                                          | wrote: X coordinate for the bounds.
Y [Deprecated]                                                          | wrote: Y coordinate for the bounds.
W [Deprecated]                                                          | wrote: Width of the bounds.
Note:
The measure will be disabled if the width is less than or equal to 0!
H [Deprecated]                                                          | wrote: Height of the bounds.
Note:
The measure will be disabled if the height is less than or equal to 0!
Action Options

These options can be used on both parents and children
OnDropAction                                                            | wrote: Action to execute when the file is dropped in the skin / bounds.
Look at bottom for substitutions!
OnEnterAction                                                           | wrote: Action to execute when the cursor enters the skin / bounds while holding a file.
Look at bottom for substitutions!
OnLeaveAction                                                           | wrote: Action to execute when the cursor leaves the skin / bounds while holding a file.
Look at bottom for substitutions!
OnOverAction                                                            | wrote: Action to execute whilst the cursor is above the skin / bounds while also holding a file.
Look at bottom for substitutions!
Note:
This is called regularly so it's possible to create animations while the mouse is moving. The update rate is about once every 20 ms, this might not be entierly correct. This is controlled by Windows itself!


Substitutions
OnDropAction, OnEnterAction, OnLeaveAction, OnOverAction                                       | wrote:
• $Name$ - Replaced with the filename.
• $FileName$ [Deprecated] - Same as the above!
• $Directory$ - Replaced with the directory
• $FileDirectory$ [Deprecated] - Same as the above!
• $Type$ - Replaced with the file extension. (e.g exe, lnk, txt)
• $FileType$ [Deprecated] - Same as the above!
• $File$ - Replaced with the full file path.
• $FileNr$ - Replaced with the number of the currently processed file.
• $MouseX$ - X position of the mouse
• $MouseY$ - Y position of the mouse
Usage

To make a skin accept dropped do you only need Action, though you probably want some other options to make it usefull!

Code: Select all

[DragNDrop]
Measure=Plugin
Plugin=Drag&Drop
Action=Path
OnDropAction=[!log "Hey you dropped the file: $Directory$\$Name$.$Type$, or as i like to say $File$"]
This is all you need to make it possible for files to be dropped!

The plugin uses the parent-child paradigm to reimplement bounds in a sane and powerful way.

An example of this:

Code: Select all


[DragNDropParent]
Measure=Plugin
Plugin=Drag&Drop

[DragNDropChild1]
Measure=Plugin
Plugin=Drag&Drop
Parent=DragNDropParent
Bounds=0,0,100,200
Action=Path
OnDropAction=[!Log "You dropped a file in the first child!"]

[DragNDropChild2]
Measure=Plugin
Plugin=Drag&Drop
Parent=DragNDropParent
Bounds=DropMeter2
Action=Path
OnDropAction=[!Log "You dropped a file in the secound child!"]

[DropMeter1]
Meter=Image
W=100
H=200
SolidColor=255,255,255

[DropMeter2]
Meter=Image
X=200
W=100
H=200
SolidColor=255,255,255

Examples

Display the last item dropped. (Has to be something the image meter can display)

Code: Select all

	[Rainmeter]
	Update=-1

	[DragNDrop]
	Measure=Plugin
	Plugin=Drag&Drop
	Action=Path
	OnDropAction=[!UpdateMeter Image][!Redraw]

	[Image]
	Meter=Image
	MeasureName=DragNDrop
	W=100
	H=100
	SolidColor=255,255,255
	PreserveAspectRatio=2
Simple launcher where you drop the file you want to use later. It is not remembered between sessions.

Code: Select all


	[Rainmeter]
	Update=-1

	[Variables]
	Text1= Test
	Text2= Test2

	[DragNDropParent]
	Measure=Plugin
	Plugin=Drag&Drop
	Action=None

	[DragNDropChild1]
	Measure=Plugin
	Plugin=Drag&Drop
	Action=Path
	Parent=DragNDropParent
	Bounds=MeterBounds1
	OnDropAction=[!SetVariable Text1 "$Name$"][!UpdateMeter MeterText1][!Redraw]

	[DragNDropChild2]
	Measure=Plugin
	Plugin=Drag&Drop
	Action=Path
	Parent=DragNDropParent
	Bounds=MeterBounds2
	OnDropAction=[!SetVariable Text2 "$Name$"][!UpdateMeter MeterText2][!Redraw]

	[MeterBounds1]
	Meter=Image
	W=100
	H=100
	SolidColor=255,255,255
	LeftMouseUpAction=["[DragNDropChild1]"]
	DynamicVariables=1

	[MeterText1]
	Meter=String
	Text=#Text1#
	X=([MeterBounds1:X] + [MeterBounds1:W] / 2)
	Y=([MeterBounds1:Y] + [MeterBounds1:H] / 2)
	StringAlign=CenterCenter
	DynamicVariables=1

	[MeterBounds2]
	Meter=Image
	X=100
	W=100
	H=100
	SolidColor=255,255,255
	LeftMouseUpAction=["[DragNDropChild2]"]
	DynamicVariables=1

	[MeterText2]
	Meter=String
	Text=#Text2#
	X=([MeterBounds2:X] + [MeterBounds2:W] / 2)
	Y=([MeterBounds2:Y] + [MeterBounds2:H] / 2)
	StringAlign=CenterCenter
	DynamicVariables=1

	;It is just copying and renaming to create additional entries :P 


	;If you feel balsy can you extend this example to save a shortcut to the file to a folder in resources and use FileView to make a real launcher from it ;)



Here is a gif of how the fancy renderer looks in case you where wondering ;)

Image

If anything is unclear, missing or feel wrong, feel free to reply! :)

The source can be found at github!

Unlike earlier versions am i trying to preserve backwards compability, so if anything doesn't work like it did earlier, please reply and i'll try my best to make it work!

Warning

There are currently an issue where virustotal (Baidu) is having a false positive with my plugin. I have sent them a message with both source and built binaries, but i haven't gotten any response yet.
It is really odd because the 64-bit version is fine, but the 32-bit one is flagged. It is built with the exact same code...

Changelog
Version 3.1.2                                                            | wrote: • Sigh, the day of forgetting... forgot to remove another debug comment
Version 3.1.2                                                            | wrote: • Found another minor bug, this was probably your issue mor3bane
Version 3.1.1                                                            | wrote: • Forgot to remove some debugging
Version 3.1.0                                                            | wrote: • Fixed some major bugs that basically broke the plugin
• Fixed a crash when holding file and entering and exiting the skin window
Version 3.0.2                                                            | wrote: • Fixed bug where move/delete/copy/Shortcut would not be run unless you added an action(e.g OnDroppedAction)
Version 3.0.1                                                            | wrote: • Fixed bug where $Directory$ did not return correct value
• Added redistributable dll files to download
Version 3.0.0                                                            | wrote: • Rewritten the entire plugin to use c++ instead of c#
• Changed all the internals to use a better drag & drop system. This makes it possible for enter, leave, over actions and fancyer rendering :3
• Reimplemented bounds, you can now have multiple bounds
• Added ReplaceIfExists to make it possible to decide if a file should be replaced
• Added Silent to stop the plugin from bugging the user if the creator doesn't want it to
• Added ProcessAllFiles to make it possible to process all files or just one file
• FancyRenderer option to decide if you want to use it or not - Why would you not you devil >:c
• Readded some options to preserve BWC
• Removed OnDropActionSubstitute - I hope i can get away with this since the String measure does this! If it is used i'll have to implement it...
Version 2.0.0                                                            | wrote: • Changed the way i handled drag and drop, it's now 100% more efficient :D
• Removed X, Y, W, H, SetRelative Options for now. Might add this back inn if i see a demand for it.
• Source is now available here: https://github.com/TheAzack9/Drag-Drop
• Added new Action: Move, basically moves file to desired path
• Fixed that the Delete action permanently deletes file/folder instead of moving to the recycle bin!
• Removed $FilePath$ and added $FileDirectory$, you can achieve the $filepath$ by using the three others:
• $FilePath$ = $FileDirectory$\\$FileName$$FileType$
• The skin now works for all Z positions, since the drag&drop is handled directly from the skin
• Removed Debug option as it's not needed anymore
• If the target directory does not exist, it'll be created now!
Version 1.0.0                                                            | wrote: • Well, if anyone is traveling to the void of nothing, please bring back this changelog... ;)
You do not have the required permissions to view the files attached to this post.
Last edited by theAzack9 on March 19th, 2019, 2:25 pm, edited 18 times in total.
User avatar
Virginityrocks
Posts: 510
Joined: February 26th, 2011, 10:22 pm

Re: Drag&Drop - Drag and drop functionallity in Rainmeter

Virginityrocks » April 10th, 2016, 4:48 pm

Not near a PC right now, but as soon as I'm home I'm testing this out! I've been waiting for a quality drag & drop plugin for a long time. Hope it works out!
User avatar
theAzack9
Developer
Posts: 520
Joined: March 2nd, 2016, 6:23 pm

Re: Drag&Drop - Drag and drop functionallity in Rainmeter

theAzack9 » April 10th, 2016, 4:56 pm

Virginityrocks wrote:Not near a PC right now, but as soon as I'm home I'm testing this out! I've been waiting for a quality drag & drop plugin for a long time. Hope it works out!
If you find any problems, let me know and i'll try to fix it ;)
User avatar
Virginityrocks
Posts: 510
Joined: February 26th, 2011, 10:22 pm

Re: Drag&Drop - Drag and drop functionallity in Rainmeter

Virginityrocks » April 10th, 2016, 9:48 pm

I might be missing something. The file doesn't want to move to the destination folder. The variables are updating with the proper directory to the file, and there are no errors in the log.
User avatar
theAzack9
Developer
Posts: 520
Joined: March 2nd, 2016, 6:23 pm

Re: Drag&Drop - Drag and drop functionallity in Rainmeter

theAzack9 » April 10th, 2016, 10:01 pm

Virginityrocks wrote:I might be missing something. The file doesn't want to move to the destination folder. The variables are updating with the proper directory to the file, and there are no errors in the log.
Did you remember to change the Action? btw, found a thing i want to add, but it'll have to wait til next weekend. I'll add the option to move a file. Have no idea how i forgot that option, sorry.
User avatar
Virginityrocks
Posts: 510
Joined: February 26th, 2011, 10:22 pm

Re: Drag&Drop - Drag and drop functionallity in Rainmeter

Virginityrocks » April 10th, 2016, 10:08 pm

I did not change the action. Working now. Splendid. Well done. Yes, add the move option if it is simple. You've really shaken things up for me today. I have some work to do!

I think I'm actually going to use the shortcut action for my purposes.
User avatar
Virginityrocks
Posts: 510
Joined: February 26th, 2011, 10:22 pm

Re: Drag&Drop - Drag and drop functionallity in Rainmeter

Virginityrocks » April 22nd, 2016, 4:29 am

I'm still trying to find the best way to implement this plugin, since the 'drop' plugin box overlaps existing buttons, rendering them unusable. For example, if I were to create an image of a recycle bin, and place the plugin overtop of it to allow drag & drop, leftmouseupactions for the recycle bin image would be unusable to open the bin.

Do you think there could be a way for the skin to detect if a file is about to be dragged over the skin window (selected, dragged over the window, but not yet dropped) and allow actions to take place when that condition is true?

For example, the skin behaves normally until a file is hovering over the window, then, when a file is hovering over the window, the 'drop' area and plugin are enabled/displayed, allowing the drop.
User avatar
theAzack9
Developer
Posts: 520
Joined: March 2nd, 2016, 6:23 pm

Re: Drag&Drop - Drag and drop functionallity in Rainmeter

theAzack9 » April 22nd, 2016, 4:49 pm

Virginityrocks wrote:I'm still trying to find the best way to implement this plugin, since the 'drop' plugin box overlaps existing buttons, rendering them unusable. For example, if I were to create an image of a recycle bin, and place the plugin overtop of it to allow drag & drop, leftmouseupactions for the recycle bin image would be unusable to open the bin.

Do you think there could be a way for the skin to detect if a file is about to be dragged over the skin window (selected, dragged over the window, but not yet dropped) and allow actions to take place when that condition is true?

For example, the skin behaves normally until a file is hovering over the window, then, when a file is hovering over the window, the 'drop' area and plugin are enabled/displayed, allowing the drop.
That's what it is supposed to do, and what it's doing for me... >.>

Are the recycle bin and the plugin in separate skins or in the same skin? could you possibly send me the skin or a skin with this problem so i can try to replicate it?

Btw, currently there's a "bug" (i forgot how things worked... XDD) where the "delete" action totally removes the file/folder from your computer and doesn't move it to the recycle bin. This will be fixed in the next version (which i hope will be up before the end of the weekend :thumbup: :) )
User avatar
theAzack9
Developer
Posts: 520
Joined: March 2nd, 2016, 6:23 pm

Re: Drag&Drop - Drag and drop functionallity in Rainmeter

theAzack9 » April 26th, 2016, 8:07 pm

I am sorry for the extreme delay on the update, but i've found a much better way to handle the drag and drop. This way i don't need to create a custom window for the drag and drop to work! :D
User avatar
theAzack9
Developer
Posts: 520
Joined: March 2nd, 2016, 6:23 pm

Re: Drag&Drop - Drag and drop functionallity in Rainmeter

theAzack9 » April 26th, 2016, 9:55 pm

Virginityrocks wrote:I'm still trying to find the best way to implement this plugin, since the 'drop' plugin box overlaps existing buttons, rendering them unusable. For example, if I were to create an image of a recycle bin, and place the plugin overtop of it to allow drag & drop, leftmouseupactions for the recycle bin image would be unusable to open the bin.

Do you think there could be a way for the skin to detect if a file is about to be dragged over the skin window (selected, dragged over the window, but not yet dropped) and allow actions to take place when that condition is true?

For example, the skin behaves normally until a file is hovering over the window, then, when a file is hovering over the window, the 'drop' area and plugin are enabled/displayed, allowing the drop.
Your problem should now be fixed, good sir :D