hamohd70 Posted July 29, 2014 Share Posted July 29, 2014 I have a form with 2 textboxes and both accept drag and drop of files. how can I detect where the file was dropped? is it on text 1 or text 2? based on this I will write my action for each case. Thanks Link to comment Share on other sites More sharing options...
computergroove Posted July 29, 2014 Share Posted July 29, 2014 Each text box will be labeled something different in autoit. You can write a loop that listens for data coming from each separate box. Do you have any code yet? Can you share it? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
hamohd70 Posted July 29, 2014 Author Share Posted July 29, 2014 here is my code expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiEdit.au3> $hGUI = GUICreate("Dropped Files", 500, 400, Default, Default, Default, $WS_EX_ACCEPTFILES) $hEdit = GUICtrlCreateEdit("", 10, 10, 480, 180) GUICtrlSetState($hEdit, $GUI_DROPACCEPTED) $hEdit_Handle = GUICtrlGetHandle($hEdit) $hEdit2 = GUICtrlCreateEdit("", 10, 210, 480, 180) GUICtrlSetState($hEdit2, $GUI_DROPACCEPTED) $hEdit_Handle2 = GUICtrlGetHandle($hEdit2) GUISetState(@SW_SHOW) Dim $EditControl While 1 $EditControl=GUIGetMsg(1) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED drop($EditControl) EndSwitch WEnd Func drop($EditControlArray) Switch $EditControlArray[0] Case $hEdit2 Local $sLine, $iLine, $m3u8AddedFromFile=False $hFile = FileOpen(@GUI_DragFile) If $hFile = -1 Then MsgBox(0,'ERROR','Unable to open file for reading.') Exit 1 EndIf While 1 $iLine += 1 $sLine = FileReadLine($hFile) If @error = -1 Then ExitLoop If StringInStr($sLine, "http://") Then GUICtrlSetData($hEdit2, $sLine) $m3u8AddedFromFile=True ExitLoop EndIf WEnd if $m3u8AddedFromFile=False then GUICtrlSetData($hEdit2, @GUI_DragFile) FileClose($hFile) Case $hEdit GUICtrlSetData($hEdit, @GUI_DragFile) EndSwitch EndFunc Link to comment Share on other sites More sharing options...
UEZ Posted July 29, 2014 Share Posted July 29, 2014 Try this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiEdit.au3> Opt("GUIOnEventMode", 1) $hGUI = GUICreate("Dropped Files", 500, 400, Default, Default, Default, BitOR($WS_EX_TOPMOST, $WS_EX_ACCEPTFILES)) $hEdit = GUICtrlCreateEdit("", 10, 10, 480, 180) GUICtrlSetState($hEdit, $GUI_DROPACCEPTED) $hEdit_Handle = GUICtrlGetHandle($hEdit) $hEdit2 = GUICtrlCreateEdit("", 10, 210, 480, 180) GUICtrlSetState($hEdit2, $GUI_DROPACCEPTED) $hEdit_Handle2 = GUICtrlGetHandle($hEdit2) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_DROPPED, "drop") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") Dim $EditControl While Sleep(1000) WEnd Func _Exit() GUIDelete() Exit EndFunc Func drop() Switch @GUI_DropId Case $hEdit2 Local $sLine, $iLine, $m3u8AddedFromFile=False $hFile = FileOpen(@GUI_DragFile) If $hFile = -1 Then MsgBox(0,'ERROR','Unable to open file for reading.') Exit 1 EndIf While 1 $iLine += 1 $sLine = FileReadLine($hFile) If @error = -1 Then ExitLoop If StringInStr($sLine, "http://") Then GUICtrlSetData($hEdit2, $sLine) $m3u8AddedFromFile=True ExitLoop EndIf WEnd if $m3u8AddedFromFile=False then GUICtrlSetData($hEdit2, @GUI_DragFile) FileClose($hFile) Case $hEdit GUICtrlSetData($hEdit, @GUI_DragFile) EndSwitch EndFunc Br, UEZ Emanoel 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
hamohd70 Posted July 30, 2014 Author Share Posted July 30, 2014 Try this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiEdit.au3> Opt("GUIOnEventMode", 1) $hGUI = GUICreate("Dropped Files", 500, 400, Default, Default, Default, BitOR($WS_EX_TOPMOST, $WS_EX_ACCEPTFILES)) $hEdit = GUICtrlCreateEdit("", 10, 10, 480, 180) GUICtrlSetState($hEdit, $GUI_DROPACCEPTED) $hEdit_Handle = GUICtrlGetHandle($hEdit) $hEdit2 = GUICtrlCreateEdit("", 10, 210, 480, 180) GUICtrlSetState($hEdit2, $GUI_DROPACCEPTED) $hEdit_Handle2 = GUICtrlGetHandle($hEdit2) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_DROPPED, "drop") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") Dim $EditControl While Sleep(1000) WEnd Func _Exit() GUIDelete() Exit EndFunc Func drop() Switch @GUI_DropId Case $hEdit2 Local $sLine, $iLine, $m3u8AddedFromFile=False $hFile = FileOpen(@GUI_DragFile) If $hFile = -1 Then MsgBox(0,'ERROR','Unable to open file for reading.') Exit 1 EndIf While 1 $iLine += 1 $sLine = FileReadLine($hFile) If @error = -1 Then ExitLoop If StringInStr($sLine, "http://") Then GUICtrlSetData($hEdit2, $sLine) $m3u8AddedFromFile=True ExitLoop EndIf WEnd if $m3u8AddedFromFile=False then GUICtrlSetData($hEdit2, @GUI_DragFile) FileClose($hFile) Case $hEdit GUICtrlSetData($hEdit, @GUI_DragFile) EndSwitch EndFunc Br, UEZ Working. Thanks alot Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now