mike2003 Posted March 30, 2019 Posted March 30, 2019 I want to transfer (drag-and-drop) the link from the browser to AutoIt. I can do this in a regular text editor. But it does not work with my window. "WS_EX_ACCEPTFILES" does not work. The image file name is inserted under the link in the temporary files.
Subz Posted March 31, 2019 Posted March 31, 2019 You can use RichEdit, see Rovers post, just create a copy of GuiRichEdit.au3 from the includes and add the global variables + overwrite the function and save as GuiRichEditEx.au3 and use this in the example he has given.
qwert Posted April 1, 2019 Posted April 1, 2019 Sort of. Quote I want to transfer (drag-and-drop) the link from the browser to AutoIt. Yes, you can use a rich edit control. They accept links by default. There's even a feature for highlighting links (_GUICtrlRichEdit_AutoDetectURL). The gui does not have to be set up with "accept files". You can also use a basic input control. But there's more to it than just setting the gui to have WS_EX_ACCEPTFILES. The control has to have a state of $GUI_DROPACCEPTED. Check the help file example for input controls. Regarding Rover's method, it was fashioned to allow a rich edit to accept a dropped file path (not url). I was never able to get it working in the context of my own scripts.
Nine Posted April 1, 2019 Posted April 1, 2019 @qwert subz is right. And I don't think you can make it work with a basic input control. Well I could but cursor will not respond correctly. I would love to see a working example of your assumption... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
qwert Posted April 2, 2019 Posted April 2, 2019 @Nine: LOL, your are correct! I went back and looked at some of my early drag/drop examples. I had changed them all to use RichEdit controls. Thanks for your response.
mike2003 Posted April 9, 2019 Author Posted April 9, 2019 All this is good to say. But what code is needed ???
Nine Posted April 9, 2019 Posted April 9, 2019 2 hours ago, mike2003 said: All this is good to say. But what code is needed ??? Look at reference of Subz post above ! He told you what steps you need to go through... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
mike2003 Posted April 13, 2019 Author Posted April 13, 2019 I tried that code, but it doesn’t do that. It does not work with other programs at all.
FrancescoDiMuro Posted April 13, 2019 Posted April 13, 2019 @mike2003 Post the code. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Nine Posted April 13, 2019 Posted April 13, 2019 11 hours ago, mike2003 said: I tried that code, but it doesn’t do that. It does not work with other programs at all. I tried it and made it work easily. Follow each step carefully, use the example provided. It is working... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
mike2003 Posted April 19, 2019 Author Posted April 19, 2019 (edited) What step? If it for other purpose! On 4/13/2019 at 2:42 PM, Nine said: I tried it what code? Edited April 19, 2019 by mike2003
Subz Posted April 20, 2019 Posted April 20, 2019 He is referring to my post above, with regards to Rovers code, here is a complete step by step version: nb: I'm going to use C:\AutoItScript directory as an example just change it to where ever you wish to save your script a. Copy "C:\Program Files (x86)\AutoIt3\Include\RichEdit.au3" to "C:\AutoItScripts\RichEdit.au3" b: Rename: "C:\AutoItScripts\RichEdit.au3" to "C:\AutoItScripts\RichEditEx.au3" b. Open "C:\AutoItScripts\RichEditEx.au3" in Scite c. At line 25 add the following variables: Global Const $DROPEFFECT_COPY = 1 Global Const $DROPEFFECT_MOVE = 2 Global Const $MK_ALT = 0x20 Global Const $MK_CONTROL = 0x8 Global $iMode, $hDragSource, $_GRE_sRTFClassName d. Replace the following function nb: On my version of RichEditEx.au3 it starts at line 3707 ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __RichCom_Object_GetDragDropEffect ; Description ...: ; Syntax.........: __RichCom_Object_GetDragDropEffect ( $pObject, $bDrag, $iGrfKeyState, $piEffect ) ; Parameters ....: ; Return values .: ; Author ........: ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func __RichCom_Object_GetDragDropEffect($pObject, $bDrag, $iGrfKeyState, $piEffect) #forceref $pObject, $bDrag, $iGrfKeyState, $piEffect Return $_GCR_E_NOTIMPL EndFunc ;==>__RichCom_Object_GetDragDropEffect With expandcollapse popup; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __RichCom_Object_GetDragDropEffect ; Description ...: ; Syntax.........: __RichCom_Object_GetDragDropEffect($pObject, $fDrag, $grfKeyState, $pdwEffect) ; Parameters ....: ; Return values .: ; Author ........: ; Modified.......: rover 2k12 ; Remarks .......: Patch to demonstrate issue with RichEdit defaulting to DROPEFFECT_COPY+DROPEFFECT_MOVE for drag and drop events between source/destination ($pdwEffect value = 3) ; ...............: Drop Effect should change depending on source/destination. Key modifiers should work the same way as Wordpads RichEdit (MS WordPad would be a RichEdit standard I assume?) ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func __RichCom_Object_GetDragDropEffect($pObject, $fDrag, $grfKeyState, $pdwEffect) #forceref $pObject, $fDrag, $grfKeyState, $pdwEffect If $fDrag Then ;only sent once at start of drag within same edit or between edits in script process ;TRUE if the query is for a IDropTarget::DragEnter or IDropTarget::DragOver. FALSE if the query is for IDropTarget::Drop. $hDragSource = _WinAPI_GetFocus() ;get drag source handle (only used for comparing to another AutoIt Richedit control) Return $_GCR_E_NOTIMPL EndIf If $grfKeyState = ($MK_CONTROL + $MK_ALT) Then $grfKeyState = 0 ; A Ctrl/Alt key combination does a drag copy between windows, so might as well allow for it. Switch $grfKeyState ;= 0 or key modifier only when mouse released, now we set the drop effect Case 0, $MK_CONTROL, $MK_ALT ;_WinAPI_GetFocus() not working here, always returns source handle of 1st richedit when over 2nd richedit in same gui Local $tDROPEFFECT = DllStructCreate("dword", Ptr($pdwEffect)) Local $tPoint = DllStructCreate($tagPOINT) Local $iOpt = Opt("MouseCoordMode", 1) DllStructSetData($tPoint, "x", MouseGetPos(0)) DllStructSetData($tPoint, "y", MouseGetPos(1)) Opt("MouseCoordMode", $iOpt) Local $hWnd = _WinAPI_WindowFromPoint($tPoint) $iMode = $DROPEFFECT_COPY ;default: $MK_LBUTTON Or $MK_RBUTTON - DD between source/destination If $grfKeyState = $MK_ALT Then $iMode = $DROPEFFECT_MOVE ;DD between source/destination If $hDragSource = $hWnd And (IsHWnd($hDragSource) + IsHWnd($hWnd)) <> 0 Then $iMode = $DROPEFFECT_COPY + $DROPEFFECT_MOVE ;DD within same edit (No key, $MK_ALT or $MK_CONTROL modifier keys) DllStructSetData($tDROPEFFECT, 1, $iMode) $hDragSource = 0 ;reset source handle (not set for a drag from an external process ($fDrag = False )) EndSwitch Return $_GCR_E_NOTIMPL EndFunc ;==>__RichCom_Object_GetDragDropEffect e. Save "C:\AutoItScripts\RichEditEx.au3" f. Create a new script: "C:\AutoItScripts\RichEdit_DragDrop_Example.au3" g. Paste the following and run, you should now be able to drag and drop urls from browser into either of the RIchEdit text boxes: expandcollapse popup#include <GUIConstantsEx.au3> #include "GuiRichEditEx.au3" #include <WindowsConstants.au3> #Include <GuiScrollBars.au3> #include <ScrollBarConstants.au3> #include <WinAPI.au3> #include <Misc.au3> Opt("GUIOnEventMode", 1) Opt('MustDeclareVars', 1) Global $g_iDLLUser32 = DllOpen("User32.dll"), $g_idRich1, $g_idRich2 _DualRichEdit() Func _DualRichEdit() Local $hForm = GUICreate("", 600, 300, -1, -1,-1 ,BitOR($WS_EX_WINDOWEDGE, $WS_EX_TOPMOST)) GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate") GUICtrlCreateLabel("First Rich Text Field", 10, 10) GUICtrlCreateLabel("Second Rich Text Field", 304, 10) GUICtrlCreateLabel("Enter text into the first field ... then highlight it and drag/drop it into the second field.", 10, 250, 580, -1) GUICtrlSetFont(-1, 11, 400, -1, "Arial") GUICtrlCreateLabel("I need the dropped text to remain in the first field ... and preferably remain highlighted.", 10, 270, 580, -1) GUICtrlSetFont(-1, 10, 800, -1, "Arial") $g_idRich1 = _GUICtrlRichEdit_Create($hForm, "", 15, 30, 280, 215, BitOR($ES_WANTRETURN, $ES_MULTILINE, $WS_VSCROLL)) _GUICtrlRichEdit_SetEventMask($g_idRich1, $ENM_DRAGDROPDONE) _GUIScrollBars_ShowScrollBar($g_idRich1, $SB_VERT, True) $g_idRich2 = _GUICtrlRichEdit_Create($hForm, "", 305, 30, 280, 215, BitOR($ES_WANTRETURN, $ES_MULTILINE, $WS_VSCROLL)) _GUICtrlRichEdit_SetEventMask($g_idRich2, $ENM_DRAGDROPDONE) _GUIScrollBars_ShowScrollBar($g_idRich2, $SB_VERT, True) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() While 1 Sleep(50) WEnd EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iWparam, $iLparam) #forceref $hWnd, $iMsg, $iWparam Local $hWndFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $iLparam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch __WinAPI_GetClassName($hWndFrom) ;replace with handles, Case $_GRE_sRTFClassName ;~ if not restoring text selection on multiple richedits Switch $iCode Case $EN_DRAGDROPDONE If $hWndFrom <> _WinAPI_GetFocus() Then ;re-show selected text only on drag beween edits _GUICtrlRichEdit_HideSelection($hWndFrom, False) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func __WinAPI_GetClassName($hWnd) Local $aResult = DllCall($g_iDLLUser32, "int", "GetClassNameW", "hwnd", $hWnd, "wstr", "", "int", 4096) If @error Then Return "" Return $aResult[2] EndFunc ;==>__WinAPI_GetClassName Func Terminate() _GUICtrlRichEdit_Destroy($g_idRich1) _GUICtrlRichEdit_Destroy($g_idRich2) Exit EndFunc
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