Jump to content
Sign in to follow this  
DJ VenGenCe

Simulate Drag & Drop on Control

Recommended Posts

DJ VenGenCe

I am having problems simulating a drag and drop onto Control SysListView3 which is a list view. Basically Dragging and Dropping MP3s works, but when I use ControlSetText, etc, it does not.

If more info is needed, I'll be happpy to oblige.

I have also attached the AutoIT Window Info Summary.

>>>> Window <<<<
Title:  Songtitle
Class:  #32770
Position:   241, 49
Size:   431, 457
Style:  0x94CA00CC
ExStyle:    0x00050115
Handle: 0x001506C0

>>>> Control <<<<
Class:  SysListView32
Instance:   1
ClassnameNN:    SysListView321
Advanced (Class):   [CLASS:SysListView32; INSTANCE:1]
ID: 1016
Position:   21, 52
Size:   383, 343
ControlClick Coords:    116, 88
Style:  0x5001884D
ExStyle:    0x00000204
Handle: 0x00080814

>>>> Mouse <<<<
Position:   137, 140
Cursor ID:  0
Color:  0xFFFFFF

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Repeat Playlist
On Air:

>>>> Hidden Text <<<<
Drag & Drop files here

AutoIT Window Info:

Share this post

Link to post
Share on other sites

You might be able to drop files onto the control by sending it a message if you can find it's handle.

This function was written by motionman and a bit by me

#include <WinAPI.au3>
#include <Memory.au3>
#include <Misc.au3>

Const $WM_DROPFILES = 0x233

Func DoDropFiles2($wnd, $Files)
;$wnd is the handle of the control we are dropping onto
;$Files is the list of files separated by "|"

 $tagStruct1 = "int offset;int px;int py;byte fNC;byte fWide"

;grab some memory
    $hGlobal = _MemGlobalAlloc(14 + StringLen($Files) + 2)
;DropFiles := GlobalLock(MemHandle)
;translates the memory handle to a pointer
    $pDropFiles = _MemGlobalLock($hGlobal)
;create the struct in this memory
    $DropFiles = DllStructCreate($tagStruct1 & ";char filelist[" & StringLen($Files) + 2 & "]", $pDropFiles)
    DllStructSetData($DropFiles, "offset", 14);14 = int+int+int+byte+byte
    $dummy = 0; done its job
    DllStructSetData($DropFiles, "px", 0);tried setting a point inside Notepad
    DllStructSetData($DropFiles, "py", 0);but it makes no difference
    DllStructSetData($DropFiles, "fwide", 0)
    DllStructSetData($DropFiles, "fNC", 0)
    DllStructSetData($DropFiles, "filelist", $Files)
;set the nulls in place of the separaters
    $Size = 0;
    $Files = StringSplit($Files, "|")
    For $I = 1 To $Files[0]

    ;// number of characters per string (as ANSI) plus one #0 terminator
    ;Inc(Size, Length(Files[I]) + 1);
    $Size += StringLen($Files[$I]) + 1
    DllStructSetData($DropFiles, "filelist", 0, $Size)
    ;ConsoleWrite(DllStructGetData($DropFiles, "filelist") & @CRLF)
;now add the extra null to terminate the list of strings
    DllStructSetData($DropFiles, "filelist", 0, $Size + 1)
    _WinAPI_PostMessage($wnd, $WM_DROPFILES, $hGlobal, 0);
;// ... and finally release the memory

EndFunc ;==>DoDropFiles2

But search for functions by Prog@ndy because after that function was written he wrote some very good code for drag-drop.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this