I want to create a button for dragging and dropping image files

I want to create a button for dragging and dropping image files.

Under normal circumstances, the "COPY MOVEWHENSAME" command should be executed. However, in the state shown in the figure below, the "JPEGView.exe {filepath}" command should be executed.

I have searched many forum posts and found the following references, but I don't know how to write the code.

Please help me modify it, thank you!

function OnClick(clickData)
{
	var cmd = clickData.func.command;
	if (clickData.func.sourcetab.selected.count == 0)
	{
		cmd.RunCommand('CreateFolder READAUTO=no');
	}
	else
	{
		cmd.RunCommand('Help ABOUT');
	}
}

剪贴板图片

Drag and drop from where to where?

If you just want to send a file to a program, making a toolbar button, context menu item, or hotkey makes more sense than doing it via drag & drop.

Simply press and hold the file, drag it, and then release the mouse button. (As shown in the figure: the red prohibition icon appears.)
I don't want buttons. This is more efficient when previewing a large number of PSD images. I prefer drag and drop. (Double-clicking opens the file in Photoshop.)
Importantly, I want to know how to write this script? For learning purposes.

I'm afraid this "dragging to nowhere" move can't be intercepted with a script.

Wouldn't double-clicking with a modifier key work?

Don't like to use the keyboard. I hope a mouse can do everything.

Sounds like StrokesPlus.net could make you happy.

Hello, could we try a different approach? For example, after a drag-and-drop operation, check if the "copy" command was executed successfully. If not, run "JPEGView.exe {filepath}".

Then you'd have no way to cancel a drag & drop without sending the file to the image viewer instead.

You'd probably also find that you keep accidentally opening files in an image viewer because they were dragged slightly when clicking on them without intending it to be a drag (something we've seen lots of issues with any time a "drag on/beside self" type operation isn't prevented unless Ctrl/Alt/Shift is down to make it explicit).

It'd also conflict with the ability to drag items from sub-folders to the main folder when using Flat View and Expandable Folders.

Even it it was easy to configure, I would still recommend against using "drag to nowhere / current folder" as a way to send files to another program. There are better methods for doing that.

Okay! Actually, I would like to know how this script is written for learning purposes. I also have some other ideas. If you think it's not appropriate, I'll give up.