james3mg Posted March 28, 2008 Share Posted March 28, 2008 So I know that AutoIt controls can ACCEPT drag-n-drop operations from other windows (explorer, etc), but is there any way to have it go the other way? The only thing I've tried is creating a listview with a listviewitem listing the full path to a file. I can drag-n-drop the listviewitem (at least, the cursor changes to indicate that's what I'm doing), but if I try to drop it in another window, Windows just plays the 'default beep' sound, and nothing happens. It was a long shot, anyway.Ideally I'd like to drag from a picture control which displays a thumbnail of the file in question, but I found in the helpfile (section GUICtrlSetState) the following:Only dragging a ListviewItem will start the drag & drop process. The @GUI_DRAGID will be the ListView controlID. Searching for and reading up on @GUI_DRAGID doesn't indicate anything different, so I don't think my 'ideal' situation will come to fruition. Dragging a specially formatted ListviewItem would be ok, if that's possible.The only other thought I had on how to get this to work would be embedding an explorer COM control instead of a Picture control, with view set to "thumbnails", and only displaying the file in question. That way, explorer would be handling the drag-n-drop operations itself (I've already confirmed that the program I want to drag to (AutoCAD) accepts drag-n-dropped files from explorer), and it would nearly look like my 'ideal' situation at the end result. I just don't know if it's possible to show only one file in an explorer object when it exists in a folder with other files, or how to go about forcing a certain view in that object.If anyone has experience or ideas on how to either allow file drag-n-drop operations from an AutoIt GUI, or how to manipulate an explorer control the way I want, I'd sure appreciate your pointers! Thanks "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110 Link to comment Share on other sites More sharing options...
martin Posted March 28, 2008 Share Posted March 28, 2008 So I know that AutoIt controls can ACCEPT drag-n-drop operations from other windows (explorer, etc), but is there any way to have it go the other way? The only thing I've tried is creating a listview with a listviewitem listing the full path to a file. I can drag-n-drop the listviewitem (at least, the cursor changes to indicate that's what I'm doing), but if I try to drop it in another window, Windows just plays the 'default beep' sound, and nothing happens. It was a long shot, anyway.Ideally I'd like to drag from a picture control which displays a thumbnail of the file in question, but I found in the helpfile (section GUICtrlSetState) the following: Searching for and reading up on @GUI_DRAGID doesn't indicate anything different, so I don't think my 'ideal' situation will come to fruition. Dragging a specially formatted ListviewItem would be ok, if that's possible.The only other thought I had on how to get this to work would be embedding an explorer COM control instead of a Picture control, with view set to "thumbnails", and only displaying the file in question. That way, explorer would be handling the drag-n-drop operations itself (I've already confirmed that the program I want to drag to (AutoCAD) accepts drag-n-dropped files from explorer), and it would nearly look like my 'ideal' situation at the end result. I just don't know if it's possible to show only one file in an explorer object when it exists in a folder with other files, or how to go about forcing a certain view in that object.If anyone has experience or ideas on how to either allow file drag-n-drop operations from an AutoIt GUI, or how to manipulate an explorer control the way I want, I'd sure appreciate your pointers! Thanks Are you dragging and dropping onto the icon of the AutoCAD exe, or are you dropping onto some control in an AutoCAD window? 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 More sharing options...
james3mg Posted March 28, 2008 Author Share Posted March 28, 2008 Are you dragging and dropping onto the icon of the AutoCAD exe, or are you dropping onto some control in an AutoCAD window?I'm trying to drag and drop into the drawing area of the AutoCAD window. But for demonstration purposes, it would work the same as dragging into a Notepad window...if I could drag some *.txt file representation from my GUI into the window of Notepad and notepad responds by opening the file in that window, the same process will work dragging a *.dwg file into the AutoCAD window. "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110 Link to comment Share on other sites More sharing options...
martin Posted March 28, 2008 Share Posted March 28, 2008 I'm trying to drag and drop into the drawing area of the AutoCAD window. But for demonstration purposes, it would work the same as dragging into a Notepad window...if I could drag some *.txt file representation from my GUI into the window of Notepad and notepad responds by opening the file in that window, the same process will work dragging a *.dwg file into the AutoCAD window.OK, is the effect of dragging from explorer into the AutoCAD window the same as if AutoCAD is running and you double click on the file? In the CAD program I use it is but I don't know about AutoCAD. 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 More sharing options...
james3mg Posted March 28, 2008 Author Share Posted March 28, 2008 OK, is the effect of dragging from explorer into the AutoCAD window the same as if AutoCAD is running and you double click on the file? In the CAD program I use it is but I don't know about AutoCAD.No...when I drag a file into AutoCAD, it inserts it as a block in the current drawing. "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110 Link to comment Share on other sites More sharing options...
martin Posted March 28, 2008 Share Posted March 28, 2008 No...when I drag a file into AutoCAD, it inserts it as a block in the current drawing.Would it be acceptable if when you dragged from the listview and dropped onto the AUtoCAD drawing it opened a menu item such as Edit|Insert Block from File and automatically entered the file name? (I assume there is a menu option to do something like that.) 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 More sharing options...
james3mg Posted March 29, 2008 Author Share Posted March 29, 2008 Would it be acceptable if when you dragged from the listview and dropped onto the AUtoCAD drawing it opened a menu item such as Edit|Insert Block from File and automatically entered the file name? (I assume there is a menu option to do something like that.)A better solution would be sending text to this control: Class: Afx:00400000:8:00010007:00000000:00000000 Instance: 1 ClassnameNN: Afx:00400000:8:00010007:00000000:000000001 ID: 2 Text: Headlands Style: 0x54000000 ExStyle: 0x00000000 The text would need to be-i [full file name] I've got to tell you, this method makes me nervous about its reliability and consistency, esp. when we upgrade. But maybe if you can deliver on that method, it could be improved on from there. Thanks for your interest. "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110 Link to comment Share on other sites More sharing options...
martin Posted March 29, 2008 Share Posted March 29, 2008 A better solution would be sending text to this control:The text would need to beI've got to tell you, this method makes me nervous about its reliability and consistency, esp. when we upgrade. But maybe if you can deliver on that method, it could be improved on from there. Thanks for your interest.I haven't really got a solution but I was thinking like this. The reason the drag drop doesn't work at the moment is because I (I think) you are dragging just the item ID from the list view which means nothing to AutoCAD. So I thought you could detect the LVN_BEGINDRAG notification from the list view and make a note of the text for the dragged item, ie the full path to the file. Then have an _Ispressed("01") which waits untill the left mouse button is released. If it's released over AutoCAD then you could perform some action, such as the controlsend idea, to give AutoCAD the full path to the file. Does that sound reasonable? 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 More sharing options...
james3mg Posted March 29, 2008 Author Share Posted March 29, 2008 (edited) I haven't really got a solution but I was thinking like this. The reason the drag drop doesn't work at the moment is because I (I think) you are dragging just the item ID from the list view which means nothing to AutoCAD. So I thought you could detect the LVN_BEGINDRAG notification from the list view and make a note of the text for the dragged item, ie the full path to the file. Then have an _Ispressed("01") which waits untill the left mouse button is released. If it's released over AutoCAD then you could perform some action, such as the controlsend idea, to give AutoCAD the full path to the file. Does that sound reasonable?...yes...I'm just reluctant to use this method- there are so many things that could interrupt the process. But it's a start. Do you think there's any way to get into whatever macro is storing the itemID as what's being dragged and replace the data in there so AutoCAD could handle it natively? I know I'm asking for the sky here...Edit: waxing a bit long about this method:It does take a little of the power away from the user, inserting a block via Cad's command prompt, vs. drag-n-drop. But if it's the best I can manage, at least for now, then that's what it is. I'd love to have AutoIt call a custom lisp routine stored in a custom toolbar, as that would be the most powerful way of automating the process, but again, too many variables. I can't guarantee that that button would always be available on all our stations, for one... Edited March 29, 2008 by james3mg "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110 Link to comment Share on other sites More sharing options...
martin Posted March 29, 2008 Share Posted March 29, 2008 (edited) ... yes... I'm just reluctant to use this method- there are so many things that could interrupt the process. But it's a start. Do you think there's any way to get into whatever macro is storing the itemID as what's being dragged and replace the data in there so AutoCAD could handle it natively? I know I'm asking for the sky here... Edit: waxing a bit long about this method: It does take a little of the power away from the user, inserting a block via Cad's command prompt, vs. drag-n-drop. But if it's the best I can manage, at least for now, then that's what it is. I'd love to have AutoIt call a custom lisp routine stored in a custom toolbar, as that would be the most powerful way of automating the process, but again, too many variables. I can't guarantee that that button would always be available on all our stations, for one... The way to do this properly is described here but it doesn't look easy. The way I've suggested, which I agree is a not great, needs something like this expandcollapse popupGlobal $DragItem = -1;nothing being dragged GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 If $DragItem > -1 Then $FilePath = _GUICtrlListView_GetItemText($hListView,$DragItem) While _IsPressed("01") Sleep(20) WEnd If WindowFromPoint() = $hAutocadWindow Then ;do whatever, ie controlsend EndIf $DragItem = -1 EndIf WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_BEGINDRAG $tNMLISTVIEW = DllStructCreate("hwnd;uint;uint;int iItem;int;uint iNewState;uint;uint;long;long;lparam", $lParam) $DragItem = DllStructGetData($tNMLISTVIEW, "iItem");index of selected item EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc;==>WM_NOTIFY Func WindowFromPoint() Local $point, $cHwnd, $hwnd, $pos, $size $point = MouseGetPos() $hwnd = DLLCall($dll, "hwnd", "WindowFromPoint", "int", $point[0], "int", $point[1]) If $hwnd[0] <> 0 Then $pos = WinGetPos($hwnd[0]) If @error Then Return 0 $size = WinGetClientSize($hwnd[0]) If @error Then Return 0 $pos[0] += (($pos[2] - $size[0]) / 2) $pos[1] += (($pos[3] - $size[1]) - (($pos[2] - $size[0]) / 2)) $cHwnd = DLLCall($dll,"hwnd","RealChildWindowFromPoint","hwnd",$hwnd[0], _ "int",$point[0] - $pos[0],"int",$point[1] - $pos[1]) If $cHwnd[0] <> 0 Then $hwnd[0] = $cHwnd[0] EndIf Return $hwnd[0] EndFunc Edited March 29, 2008 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 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