Sign in to follow this  
Followers 0
yair

drag and drop append to field

7 posts in this topic

both input fileds are configured to accept file drops.

the first works, the second doesn't replace data content but appends to it.

#include <GUIConstantsEx.au3>
#include <file.au3>
#include <array.au3>

$file1 = "test.jpg"
$file2 = "test2.jpg"

$Form1 = GUICreate("Form1", 625, 200, 192, 124, -1, 0x00000018); WS_EX_ACCEPTFILES
$file1GUI = GUICtrlCreateInput($file1, 80, 70, 513, 21)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)

$file2GUI = GUICtrlCreateInput($file2, 80, 118, 513, 21)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)

GUISetState(@SW_SHOW)

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The only difference I see when I start your script is that the content of the first input field is marked and therefore replaced when dropping a file.

The second input field isn't marked and therefore the dropped file is appended.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

ok, i didnt notice that.

so i understand i need to change the focus to the second input filed when i drag.

can you hint to how?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

To do it manually just tab to the second field.

If you want to do it automatically then you'll have to catch the GUI event of drag&drop (example)

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

thanks, this work

#include <GUIConstantsEx.au3>

$file1 = "test.jpg"
$file2 = "test2.jpg"

$Form1 = GUICreate("Form1", 625, 200, 192, 124, -1, 0x00000018); WS_EX_ACCEPTFILES

$file1GUI = GUICtrlCreateInput($file1, 80, 70, 513, 21)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)

$file2GUI = GUICtrlCreateInput($file2, 80, 118, 513, 21)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$msg = 0
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $GUI_EVENT_DROPPED
            If (@GUI_DropId == 3) Then
                GUICtrlSetState($file1GUI, $GUI_FOCUS)
                GUICtrlSetData($file1GUI,@GUI_DRAGFILE)
            ElseIf (@GUI_DropId == 4) Then
                GUICtrlSetState($file2GUI, $GUI_FOCUS)
                GUICtrlSetData($file2GUI,@GUI_DRAGFILE)
            EndIf
    EndSelect
WEnd

btw, whats the easiest way to convert a control id from

@GUI_DropId == 3

@GUI_DropId == $file1GUI

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

It's the same.

@GUI_DropId = Control identifier where the drop occurred = the value (ControlId) returned by GUICtrlCreateInput.

So the line

If (@GUI_DropId == 3) Then
can be written as
If (@GUI_DropId == $file1GUI) Then
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

thanks, the speed and quality of advice in au3 forums doesn't fail to amaze me.

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