HandleFileDragDrop plug-in

From NSIS Wiki
Jump to navigationJump to search
Author: Anders (talk, contrib)


Links

HandleFileDragDrop.zip (4 KB)

Description

Version: 0.2 - 20181123
Supported on: Win95+/NT4+ (Only tested on XP, should work on any platform)

This plugin will respond to files dropped on the window you specify, it can call a nsis function for each file/folder dropped on the window, or just set the window's text (Useful for file/folder inputs)

Example

OutFile Test.exe
ShowInstDetails show
RequestExecutionLevel user
CompletedText "Drop files on me..."
DirText "You can drop a folder on the text field!"
SpaceTexts none
InstallDir $temp
 
Page Directory "" onDirShow
Page InstFiles
 
Function onDirShow
FindWindow $1 "#32770" "" $HWNDPARENT ; Find inner dialog
GetDlgItem $1 $1 0x3FB ; Get the handle of the control (Replace with INSTALLOPTIONS_READ ... "HWND" on a custom page)
HandleFileDragDrop::Register $1 ""
FunctionEnd
 
Function InstPageDrop
DetailPrint Drop:$0
StrCpy $0 "" ; Set to empty string if you want the next file (if any)
FunctionEnd
 
Section
FindWindow $1 "#32770" "" $HWNDPARENT ; Find inner dialog
GetFunctionAddress $0 InstPageDrop
HandleFileDragDrop::Register $1 $0
SectionEnd

Remarks

In Windows Vista and later UIPI (an UI component of UAC) blocks drag & drop from low integrity processes (like Explorer) to high integrity processes (like the installer if set to require elevation). To work this around, add the following code:

System::Call 'user32::ChangeWindowMessageFilter(i563, i1)'
System::Call 'user32::ChangeWindowMessageFilter(i74, i1)'
System::Call 'user32::ChangeWindowMessageFilter(i73, i1)'

Credits

Written by Anders (For fun and profit?)

Vista+ workaround by Anonymous, with the help of https://stackoverflow.com/a/14091973