BigOneWay Posted March 19, 2010 Posted March 19, 2010 Hi am new to the forum, sorry if my English is not so good, i use google translator, and now the question: how do I make the recognition of a drag & drop in a window eg. I drag an icon from the desktop and release on a window, how to catch the values of all objects in the window, including the window. #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) $GUI = GUICreate('Drop a file in the edit', 400, 400, -1, -1, -1, $WS_EX_ACCEPTFILES) $ahIcons0 = GUICtrlCreateIcon(@SystemDir & '\shell32.dll' , -5, 10, 20) GUICtrlSetTip(-1,'Ciccio','',1,1) GuiCtrlSetState($ahIcons0 ,$GUI_DROPACCEPTED) GUISetOnEvent($GUI_EVENT_DROPPED, "Drop") GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") GUISetState() While 1 Sleep(2000) WEnd Func Quit() GUIDelete($GUI) Exit EndFunc Func Drop() ConsoleWrite('@GUI_DropID: ' & @GUI_DropID & ' @GUI_DragFile: ' & @GUI_DragFile & ' @GUI_DragID: ' & @GUI_DragID & @CRLF) EndFunc Any suggestions Thank you
martin Posted March 19, 2010 Posted March 19, 2010 (edited) Hi am new to the forum, sorry if my English is not so good, i use google translator, and now the question: how do I make the recognition of a drag & drop in a window eg. I drag an icon from the desktop and release on a window, how to catch the values of all objects in the window, including the window. #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) $GUI = GUICreate('Drop a file in the edit', 400, 400, -1, -1, -1, $WS_EX_ACCEPTFILES) $ahIcons0 = GUICtrlCreateIcon(@SystemDir & '\shell32.dll' , -5, 10, 20) GUICtrlSetTip(-1,'Ciccio','',1,1) GuiCtrlSetState($ahIcons0 ,$GUI_DROPACCEPTED) GUISetOnEvent($GUI_EVENT_DROPPED, "Drop") GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") GUISetState() While 1 Sleep(2000) WEnd Func Quit() GUIDelete($GUI) Exit EndFunc Func Drop() ConsoleWrite('@GUI_DropID: ' & @GUI_DropID & ' @GUI_DragFile: ' & @GUI_DragFile & ' @GUI_DragID: ' & @GUI_DragID & @CRLF) EndFunc Any suggestions Thank you The script you showed does tell you the file or icon which is dropped on the folder icon in your window. What else is it you want? I think your version of AutoIt is not the latest because I need to include "Windowsconstants.au3" to run your script. EDIT: Welcome BigOneWay Edited March 19, 2010 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.
BigOneWay Posted March 19, 2010 Author Posted March 19, 2010 Yes I have the 3.3 portable version. If I run the drag & drop over the icon it's OK, but I also need to run the drag & drop over the window to a different management of the link. I also tried inserting a picture as background, the result is that the image hides the object icon even if the icon is over the image I also tried to use the WinAPIEx.au3 but I did not understand much
Yashied Posted March 20, 2010 Posted March 20, 2010 (edited) Yes I have the 3.3 portable version. If I run the drag & drop over the icon it's OK, but I also need to run the drag & drop over the window to a different management of the link. I also tried inserting a picture as background, the result is that the image hides the object icon even if the icon is over the image I also tried to use the WinAPIEx.au3 but I did not understand much You have chosen not exactly an easy task. That's what I came (tested on Windows XP). expandcollapse popup#Include <GUIConstantsEx.au3> #Include <Icons.au3> #Include <WinAPIEx.au3> #Include <WindowsConstants.au3> Global $WM_DROPFILES = 0x0233 ; Create GUI $hForm = GUICreate('MyGUI', 800, 600) GUICtrlCreatePic(@WindowsDir & '\Web\Wallpaper\Ascent.jpg', 0, 0, 800, 600) GUICtrlSetState(-1, $GUI_DISABLE) $Pic = GUICtrlCreatePic('', 40, 40, 48, 48) $hPic = GUICtrlGetHandle(-1) ; Set icon with transparent background (works for RGB/A icons only) $hIcon = _Icons_Icon_Extract(@SystemDir & '\shell32.dll', 130, 48, 48) $hBitmap = _Icons_Bitmap_CreateFromIcon($hIcon) _WinAPI_FreeIcon($hIcon) _SetHImage($Pic, $hBitmap) _WinAPI_FreeObject($hBitmap) ; Register $Pic window procedure (need to changing cursor and registering WM_DROPFILES message) $hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam') $pDll = DllCallbackGetPtr($hDll) $hProc = _WinAPI_SetWindowLong($hPic, $GWL_WNDPROC, $pDll) ; Enable Drag&Drop (0 - Disable, 1 - Enable) _WinAPI_DragAcceptFiles($hPic, 1) GUISetState() ; Main loop While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Unregister $Pic window proc _WinAPI_SetWindowLong($hPic, $GWL_WNDPROC, $hProc) DllCallbackFree($hDll) GUIDelete() Exit ; $Pic control handler procedure Func _WinProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_DROPFILES Local $FileList = _WinAPI_DragQueryFileEx($wParam) If IsArray($FileList) Then ConsoleWrite('--------------------------------------------------' & @CR) For $i = 1 To $FileList[0] ConsoleWrite($FileList[$i] & @CR) Next EndIf _WinAPI_DragFinish($wParam) Return 0 EndSwitch Return _WinAPI_CallWindowProc($hProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_WinProc Icons.au3 WinAPIEx.au3 Edited March 20, 2010 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
BigOneWay Posted March 20, 2010 Author Posted March 20, 2010 I know, infact I came here because the AutoIt forums of my country did not arrive ideas He had also found something that I function expandcollapse popup#include <GUIConstants.au3> #Include <WinAPIEx.au3> Global Const $WM_DROPFILES = 0x0233 Global $hForm, $Msg, $Check, $Edit, $hEdit, $hDll, $pDll, $hProc $GUI = GUICreate('Drop a file in the edit', 200, 200);, -1, -1, -1, $WS_EX_ACCEPTFILES) ;~ GUICtrlSetState(-1, $GUI_DROPACCEPTED) $ahIcons0 = GUICtrlCreateIcon(@SystemDir & '\shell32.dll' , -5, 85, 85) GUICtrlSetTip(-1,'Ciccio','',1,1) GuiCtrlSetState($ahIcons0 ,$GUI_DROPACCEPTED) $hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam') $pDll = DllCallbackGetPtr($hDll) $hProc = _WinAPI_SetWindowLong($GUI, $GWL_WNDPROC, $pDll) ;~ $hProc = _WinAPI_SetWindowLong($ahIcons0, $GWL_WNDPROC, $pDll) _WinAPI_DragAcceptFiles($GUI) _WinAPI_DragAcceptFiles($ahIcons0) GUISetState() While 1 $gm = GUIGetMsg() Switch $gm Case $GUI_EVENT_DROPPED ConsoleWrite('@GUI_DragID: ' & @GUI_DragID & @CRLF & '@GUI_DropID: ' & @GUI_DropID & @CRLF & '@GUI_DragFile: ' & @GUI_DragFile & @CRLF) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _WinProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_DROPFILES Local $FileList = _WinAPI_DragQueryFileEx($wParam) If (Not @error) And ($FileList[0] = 1) Then ConsoleWrite('@GUI_DragFile: ' & $FileList[1] & @CRLF) ConsoleWrite('@GUI_DragID: ' & @GUI_DragID & @CRLF) EndIf _WinAPI_DragFinish($wParam) Return 0 EndSwitch Return _WinAPI_CallWindowProc($hProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_WinProc Note that with $HProc _WinAPI_SetWindowLong = ($ahIcons0, $GWL_WNDPROC, $pDll) work function: _WinProc if active: $HProc _WinAPI_SetWindowLong = ($ahIcons0, $GWL_WNDPROC, $pDll) disabling that for the GUI _WinProc function is turned off and starts working on: Case $ GUI_EVENT_DROPPED in più con la Gui attivata l'icona non viene più individuata e le variabili: @GUI_DragID @GUI_DropID @GUI_DragFile rimangono inutilizzate se individuasse sia icone che finestra sarebbe ottimo. idee? Sorry for my English
BigOneWay Posted March 20, 2010 Author Posted March 20, 2010 sorry Note that with $HProc _WinAPI_SetWindowLong = ($ahIcons0, $GWL_WNDPROC, $pDll) work function: _WinProc changes with Note that with $HProc _WinAPI_SetWindowLong = ($GUI, $GWL_WNDPROC, $pDll) work function: _WinProc
BigOneWay Posted March 20, 2010 Author Posted March 20, 2010 sorry again but you also disable ConsoleWrite('@GUI_DragID: ' & @GUI_DragID & @CRLF) otherwise continues to generate an error
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