Sign in to follow this  
Followers 0
sandyd

Registering Events

3 posts in this topic

Hi everyone,

I am wanting to create a program that does some tidying of MP3 filenames and would like to be able to DRAG a list of files in explorer and DROP them into say, a LIST control.

I can get this to work on an EDIT control using the attached unfinished example, but have to click the 'Tidy' button to get it to do work.

Is there anyway I can setup a GUIRegisterMsg to catch the DROP event and therefore remove the need to click the 'Tidy' button.

P.S. Where do people search to get the information required for the GUIRegisterMsg event

MP3Renamer.au3


----[ SandyD ]---

Share this post


Link to post
Share on other sites



here's an example to demonstrate multiple filedrops on a list.

(credits: FlyingBoz)

;===============================================================================

; Script Name:            DragDrop.Au3
; Description:            Demonstrate Handling a FileDrop Operation in Autoit 3.x
; Parameter(s):           None
; Requirement(s):         Not tested under 3.1.0 or earlier
; Return Value(s):        None
; Author(s):              FlyingBoz
; Date:                   20 Feb 2005
;===============================================================================


#include <GuiConstants.au3>

; GUI
;Note GUI Created with the Extended Windows Style ACCEPTFILES
GUICreate("Drag/Drop Demo", 220, 220, -1, -1, -1, $WS_EX_ACCEPTFILES)
GUISetIcon(@SystemDir & "\mspaint.exe", 0)

; INPUT
;string for default status of InputBox
Global Const $txtInput = "Input Box Accepts Files"
;Create handle for Input Box.
Global $hInput = GUICtrlCreateInput($txtInput, 10, 10, 200, 200);Specify that the control can respond to ACCEPTFILES messages
GUICtrlSetState(-1, $GUI_ACCEPTFILES)
GUISetState()
;Initialize Message Status
Local $msg = ""
; GUI MESSAGE LOOP
While $msg <> $GUI_EVENT_CLOSE
   $msg = GUIGetMsg()
  ;UDF to Monitor Controls that Accept Drag / Drop
  ;This is necessary becuase the drop operation does NOT send a message to the control,
  ;It simply dumps the CRLF separated list of files in the control, appending them to what went before.
   _MonitorFiles()
  
WEnd
Exit $msg

;===============================================================================
;
; Function Name:      _MonitorFiles
; Description:        Demonstrate Looping to Monitor the change of a drag/drop file operation
; Parameter(s):       None
; Requirement(s):     Autoit3.1.0
; Return Value(s):    None
; Author(s):          FlyingBoz
; Date:               20 Feb 2005

Func _MonitorFiles()
  ;FlyingBoz - monitor contents of $hinput control,
  ;display and reset when triggered.
   Local $text = GUICtrlRead($hInput)
   If $text <> $txtInput Then;Something has changed
    ;strip the default text
      $text = StringReplace($text, $txtInput, "")
    ;display what's left.
      MsgBox(0, "Change In Input Box!", $text, 0)
    ;NOTE: Obviously, more sophisticated handling
   ;should occur here - You will see when Files are
  ;dropped, this @CRLF separated list
    ;can be parsed, tested with If FileExists(), etc.
    
      GUICtrlSetData($hInput, $txtInput)
   EndIf
EndFunc  ;==> _MonitorFiles
;===============================================================================

Share this post


Link to post
Share on other sites

Thanks, works a treat.


----[ SandyD ]---

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  
Followers 0