2014-02-28 66 views
1

我发现这个代码,让我拖放文件到脚本图标并把它们放到一个指定的目录:的Visual Basic拖放窗口

Const MyDestinationFolder = "C:\Temp\" 
Const OverwriteExisting = True 

Dim objFile,objFolder 
Dim Arg 

Set objFSO = CreateObject("Scripting.FileSystemObject") 

If WScript.Arguments.Count > 0 Then 
    For Each Arg in Wscript.Arguments 
     Arg = Trim(Arg) 
    If InStr(Arg,".") Then 
    ' Assume a File 
     Set objFile = objFSO.GetFile(Arg) 
     ' Copy file to the Dest Folder using the same name 
     objFile.Copy MyDestinationFolder & objFile.Name,OverwriteExisting 
    Else 
    'Assume a Folder 
     Set objFolder = objFSO.GetFolder(Arg) 
     ' Copy Folder to the Dest Folder 
     objFolder.Copy MyDestinationFolder, OverwriteExisting 
    End If 
    Next 
End If 

不过我想提出一个脚本,运行,并有一个简单的矩形,说,在这里拖放。如果这是可能的,那就太好了。谢谢!

+0

这是不可能的只有WSH/VBScript。 VBScript没有GUI功能。除了MsgBox和InputBox之外,它根本没有窗口,并且它们都不能用作放置目标。 Windows,而不是VBScript,负责您在脚本图标上进行的拖放操作。你几乎可以肯定不得不使用HTA,但我不确定这是否可行。 IFrames是放弃目标,但我怀疑VBScript可能会收到他们的事件。 – Bond

+0

好的,是否有任何与Windows一起安装的语言可以用于我的目的? – drcomputer

+0

看看这个:http://msdn.microsoft.com/en-us/library/System.Windows.DragDrop(v=vs.110).aspx – Rich

回答