Jump to content

Drag & Drop, everything, not just file names ?!


Armand
 Share

Recommended Posts

hey guys,

seems like using: $WS_EX_ACCEPTFILES in combination with: GUICtrlSetState(-1, $GUI_DROPACCEPTED)

makes my GUI accept only filenames but not everything like i want it to...

I want to be able to mark whatever i want in FF and then drag it to my GUI for copying process... any idea how to ?!

WOW, i thought it to be rather simpler.... as it seems AU3 doesn't support it....

i wander if one can achieve it by using the OLE COM obj for the job....

Some info:

http://www.autoitscript.com/forum/index.ph...mp;hl=drag+drop

http://www.autoitscript.com/forum/index.ph...mp;hl=drag+drop

Some GUI for reproducing

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$parent1 = GUICreate("Parent1", -1, -1, -1, -1, -1, $WS_EX_ACCEPTFILES)
GUISetOnEvent($GUI_EVENT_DROPPED, "MyFunc")
$Ctrl = GUICtrlCreateInput("", 10, 10)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetState(@SW_SHOW)

; Just idle around
While 1
    Sleep(10)
WEnd

Func MyFunc()
    ConsoleWrite("ID: "&@GUI_DRAGID & " File: "&@GUI_DRAGFILE &" Drop: "&@GUI_DROPID&@CRLF)
EndFunc
Edited by Armand

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

Maybe...

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1) ;   ******** 0=disabled, 1=OnEvent mode enabled

$parent1 = GUICreate("Parent1", -1, -1, -1, -1, -1, $WS_EX_ACCEPTFILES)
GUISetOnEvent(-3, "Exiter") ; ******* This is GUI event
$Ctrl = GUICtrlCreateInput("", 10, 10)
GUICtrlSetOnEvent($GUI_EVENT_DROPPED, "MyFunc") ; ****** This is GUI Control event
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetState(@SW_SHOW)

; Just idle around
While 1
    Sleep(10)
WEnd

Func MyFunc()
    ConsoleWrite("ID: " & @GUI_DragId & " File: " & @GUI_DragFile & " Drop: " & @GUI_DropId & @CRLF)
EndFunc   ;==>MyFunc

Func Exiter()
    Exit 0
EndFunc   ;==>Exiter

8)

NEWHeader1.png

Link to comment
Share on other sites

This seems a bit complicated but you can drag marked text to your input like this.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <misc.au3>

$parent1 = GUICreate("Parent1", -1, -1, -1, -1, -1)
$Ctrl = GUICtrlCreateInput("", 10, 10)
GUISetState(@SW_SHOW)
; Just idle
While 1
    
    If _IsPressed(01) Then
        If WinActive("") <> $parent1 Then
            ConsoleWrite("down" & @CRLF)
            Sleep(50)
            Send("^{INS}")
            While _IsPressed(01)
                Sleep(10)
            WEnd
            If WindowFromPoint() = ControlGetHandle($parent1,"",$Ctrl) Then
                MouseClick("left")
                Send("^v")
            EndIf
        EndIf
    EndIf

    $msg = GUIGetMsg()
    Switch $msg
        Case - 3
            Exit
    EndSwitch

    Sleep(10)
WEnd


Func WindowFromPoint()
    Local $point, $cHwnd, $hwnd, $pos, $size
    $point = MouseGetPos()
    $hwnd = DllCall("user32.dll", "hwnd", "WindowFromPoint", "int", $point[0], "int", $point[1])
    Return $hwnd[0]
EndFunc  ;==>WindowFromPoint
Edited by martin
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.
Link to comment
Share on other sites

Thanks mates,

but i wasn't referring just to text... what if i want to drag-drop a picture from browser to the input box ?!

it's oky.... maybe in a couple of years AU3 will be able to do it :mellow:

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

  • 5 months later...

It already can. If you drag an image from your browser to an input, the file path will be inserted (probably from your cache). Work fine in Firefox, at least. I used it in my color pickin chooser to import images directly from the web.

(I was here looking for something else..)

;o)

(or

nothing is foolproof to the sufficiently talented fool..

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...