Jump to content

Drag and Drop - the other way around


Recommended Posts

Actually, some more troubleshooting shows it has to do with the working dir for notepad.

If I change the Run line to

Run("notepad.exe", @TempDir)
or whatever dir the file is created in, then it works OK.

Now I know what the problem is, but I'm still not sure why...

The problem seems to be with the macro @TempDir. If I try using it in the then it fails. If I replace @TempDir with the full path then it works.

If I show @TempDir using

ConsoleWrite(@TempDir @CR)

then it shows the abbreviated 8-character DOS version, so I assume that Notpad doesn't like that. Other macros like @ScriptDir work ok for me.

I expected that @TempDir would have the full path like the other macros so maybe it's an oversight.

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

  • Replies 94
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

@martin

Every program I've ever used always show the tempdir path with '~1', I dont know if its the same thing for other countrys, but It should work in the way its a 'shortcut' path instead of writting 'Local Settings' it writes 'LOCALS~1' ...

Edit : I've tried to create folder named 'LOCALS~1' and it failed, im sure the Local settings has '2' names for shortcuts like I said :P

Edit : same thing for 'DOCUME~1' instead of 'Documents and Settings'

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

@martin

Every program I've ever used always show the tempdir path with '~1', I dont know if its the same thing for other countrys, but It should work in the way its a 'shortcut' path instead of writting 'Local Settings' it writes 'LOCALS~1' ...

Edit : I've tried to create folder named 'LOCALS~1' and it failed, im sure the Local settings has '2' names for shortcuts like I said :P

Edit : same thing for 'DOCUME~1' instead of 'Documents and Settings'

Cheers, FireFox.

Trying to create a folder 'LOCAL~1' will fail because there is already a folder with that name. If a folder has more than 8 characters in its name it is saved as the first 7 characters then '~'. So 16 bit programs just see that, but windows stores the rest of the name after that which DOS doesn't know about. When Windows reads the name with '~' at the end it knows there are really more characters and so replaces the '~' with those extra characters.

@ResNullius

If you replace

@TempDir

with

FileGetLongName(@TempDir)

then I think it will work.

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

@Martin

I'm trying to drag and drop to explorer, but I'm not very successful. I'm using this code to detect if explorer was dragged to, and drop the file there. The code in red is the code that's not working.

$GUI_HEIGHT = 323

$GUI_WIDTH = 441

$startChecking = False

Func DoDropFiles($Wnd, $Files)

;$wnd is the handle of the control we are dropping onto

;$Files is the list of files separated by "|"

$dummy = DllStructCreate("int offset;int px;int py;byte fNC[1];byte fWide[1]")

;grab some memory

$hGlobal = _MemGlobalAlloc(DllStructGetSize($dummy) + StringLen($Files) + 2)

;DropFiles := GlobalLock(MemHandle)

;translates the memory handle to a pointer

$pDropFiles = _MemGlobalLock($hGlobal)

;create the struct in this memory

$DropFiles = DllStructCreate("int offset;int px;int py;byte fNC[1];byte fWide[1];char filelist[" & StringLen($Files) + 2 & "]", $pDropFiles)

DllStructSetData($DropFiles, "offset", DllStructGetSize($dummy))

$dummy = 0; done its job

DllStructSetData($DropFiles, "px", 0);tried setting a point inside Notepad

DllStructSetData($DropFiles, "py", 0);but it makes no difference

DllStructSetData($DropFiles, "fwide", 0)

DllStructSetData($DropFiles, "fNC", 0)

DllStructSetData($DropFiles, "filelist", $Files)

;set the nulls in place of the separaters

$Size = 0;

$Files = StringSplit($Files, "|")

For $I = 1 To $Files[0]

;// number of characters per string (as ANSI) plus one #0 terminator

;Inc(Size, Length(Files) + 1);

$Size += StringLen($Files[$I]) + 1

DllStructSetData($DropFiles, "filelist", 0, $Size)

Next

;now add the extra null to terminate the list of strings

DllStructSetData($DropFiles, "filelist", 0, $Size + 1)

_MemGlobalUnlock($hGlobal)

_WinAPI_PostMessage($Wnd, $WM_DROPFILES, $hGlobal, 0);

;// ... and finally release the memory

_MemGlobalFree($hGlobal)

EndFunc ;==>DoDropFiles

Func _IsMouseInWindow()

Local $MouseX, $MouseY, $mousePos

$mousePos = GUIGetCursorInfo()

$MouseX = $mousePos[0];X Axis info from getcursorinfo()

$MouseY = $mousePos[1];Y Axis info from getcursorinfo()

;Does the Mouse's X or Y Extend the window?

If ($MouseX < -3 Or $MouseX > $GUI_WIDTH+2 Or $MouseY < -29 Or $MouseY > $GUI_HEIGHT+2) Then

;The mouse is not in the window, return false

Return False

Else

;Yes, the mouse is in the window, return true

Return True

EndIf

EndFunc ;==>_IsMouseInWindow

Func _WinInfoFromPoint($nX, $nY);by Saio

Local $tStrBuff, $pStrBuff, $aRet, $hWnd, $hOwnerWnd, $sClassName, $sOwnerClass, $sWinText

$tStrBuff = DllStructCreate("char[100]")

$pStrBuff = DllStructGetPtr($tStrBuff)

$aRet = DllCall("user32.dll", "hwnd", "WindowFromPoint", "uint", $nX, "uint", $nY)

$hWnd = $aRet[0]

$aRet = DllCall("user32.dll", "int", "GetClassName", "hwnd", $hWnd, "ptr", $pStrBuff, "int", 100)

$sClassName = DllStructGetData($tStrBuff, 1)

DllStructSetData($tStrBuff, 1, "")

DllCall("user32.dll", "int", "GetWindowText", "hwnd", $hWnd, "ptr", $pStrBuff, "int", 100)

;~ DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "uint", $WM_GETTEXT, "uint", 100, "ptr", $pStrBuff)

$sWinText = DllStructGetData($tStrBuff, 1)

DllStructSetData($tStrBuff, 1, "")

$aRet = DllCall("user32.dll", "hwnd", "GetAncestor", "hwnd", $hWnd, "uint", 2);$GA_ROOT = 2

$hOwnerWnd = $aRet[0]

$aRet = DllCall("user32.dll", "int", "GetClassName", "hwnd", $hOwnerWnd, "ptr", $pStrBuff, "int", 100)

$sOwnerClass = DllStructGetData($tStrBuff, 1)

DllStructSetData($tStrBuff, 1, "")

Local $Array[5] = [$sWinText, $sClassName, $hWnd, $sOwnerClass, $hOwnerWnd]

;Window Text: $sWinText | $Array[0]

;ClassName: $sClassName | $Array[1]

;Window Handle: $hWnd | $Array[2]

;Owner ClassName: $sOwnerClass | $Array[3]

;Owner Handle: $hOwnerWnd | $Array[4]

ConsoleWrite(@CRLF & "{ WinInfo }" & @CRLF)

ConsoleWrite("Window Text: " & $sWinText & @CRLF)

ConsoleWrite("ClassName: " & $sClassName & @CRLF)

ConsoleWrite("Window Handle: " & $hWnd & @CRLF)

ConsoleWrite("Owner ClassName: " & $sOwnerClass & @CRLF)

ConsoleWrite("Owner Handle: " & $hOwnerWnd & @CRLF)

ConsoleWrite("{ WinInfo }" & @CRLF & @CRLF)

Return $Array

EndFunc ;==>_WinInfoFromPoint

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $GUI_EVENT_DROPPED

$File = @GUI_DragFile

If StringRegExp($File, "^.+\.(?i)((TTF)|(OTF))$") Then

MsgBox(0, "", $File & @CRLF & "Is a font file.")

Else

MsgBox(0, "", $File & @CRLF & "Is an invalid file type.")

EndIf

Case $Pic2

$startChecking = True

EndSwitch

If $startChecking Then

$cInfo = GUIGetCursorInfo()

If $cInfo[2] = 0 Then

;Left Mouse Key Up

If _IsMouseInWindow() = False Then

$mousePos = MouseGetPos()

$wInfo = _WinInfoFromPoint($mousePos[0], $mousePos[1])

If $wInfo[1] = "SysListView32" And $wInfo[3] = "Progman" Then

;Detect Desktop

;Maybe use FileCopy($file , @DesktopDir)

$startChecking = False

ElseIf $wInfo[1] = "SysListView32" And $wInfo[3] = "CabinetWClass" Then

;PROBLEM CODE!

;Detect Explorer.exe Window

DoDropFiles($wInfo[2], "C:\Documents and Settings\Owner\Desktop\k.txt")

$startChecking = False

Else

DoDropFiles($wInfo[4], "C:\Documents and Settings\Owner\Desktop\k.txt")

$startChecking = False

EndIf

Else

$startChecking = False

EndIf

EndIf

EndIf

WEnd

Edited by motionman95
Link to comment
Share on other sites

@Martin

I'm trying to drag and drop to explorer, but I'm not very successful. I'm using this code to detect if explorer was dragged to, and drop the file there. The code in red is the code that's not working.

I don't think that what we did with the DoDropFiles function is what you need to drag files to an explorer window. I don't know how to do what you want but this is some of what I looked up. I don't think it's so easy. Using the clipboard is apparently the easiest way but at the moment I don't know how to create the data object required. Maybe it's the same as, or very similar to, the struct we created in global memory. If you can create the data object then it looks easy to write a pointer to the clipboard for that data object and then all (all?) you have to do is detect when you are over an explorer window when the mouse button is released, like you alrerady have done, and send the drop message.

You need someone with more knowledge and skill than I have.

Of course it might all be a lot easier than I think and someone will tell us.

Since you have been good at finding relevant code so far I assume that you have searched these forums for ideas.

I think I would try and do it another way. I would have some way of making it look like something was being dragged, say a little popup window which was layered with an icon from shell32.dll and made partly transparent, then when the mouse button is released, check if the cursor is over an explorer window, find the title to that window then use that title as the target path for a FileCopy instruction.

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

The problem seems to be with the macro @TempDir. If I try using it in the then it fails. If I replace @TempDir with the full path then it works.

If I show @TempDir using

ConsoleWrite(@TempDir @CR)

then it shows the abbreviated 8-character DOS version, so I assume that Notpad doesn't like that. Other macros like @ScriptDir work ok for me.

I expected that @TempDir would have the full path like the other macros so maybe it's an oversight.

I'm not so sure that I agree with your assessment...I'm trying to "drop" a drawing file into AutoCAD using this method, and I'm getting "Path not found" from AutoCAD. So I tried "dropping" it into notepad, and get a similar message. But if I launch Notepad with its' working directory set to the directory of the file I'm trying to "drop", it works. Then back to AutoCAD, same thing. If I launch it having set the working directory to the same path as the file I'm trying to drop, it works there too.

So it seems like it is a working directory issue, after all.

"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

  • Moderators

martin, motionman95,

I have been playing with your very interesting scripts today and come to the same result as james3mg. If I open the app from the function with the working directory set to the file's path - all is well. But if the app is already running or I set the working directory to some other value - "Cannot find path" - or something similar.

I am following this with great interest - please do not take this as negative feedback and give up (not that I think you will!). If I can help in any way - just let me know.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

martin, motionman95,

I have been playing with your very interesting scripts today and come to the same result as james3mg. If I open the app from the function with the working directory set to the file's path - all is well. But if the app is already running or I set the working directory to some other value - "Cannot find path" - or something similar.

I am following this with great interest - please do not take this as negative feedback and give up (not that I think you will!). If I can help in any way - just let me know.

M23

I agree something is not quite as I thought because yesterday I could drop various files onto Notepad and they all worked. Today they don't unless I add "\\" to the front.

So instead of having

$path = FileGetLongName("T:\TC043\fermoy.txt");doesn't work

I use

$path = FileGetLongName("\\T:\TC043\fermoy.txt");does work.

Can someone try that and see if it makes any difference?

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

I agree something is not quite as I thought because yesterday I could drop various files onto Notepad and they all worked. Today they don't unless I add "\\" to the front.

So instead of having

$path = FileGetLongName("T:\TC043\fermoy.txt");doesn't work

I use

$path = FileGetLongName("\\T:\TC043\fermoy.txt");does work.

Can someone try that and see if it makes any difference?

Interesting, that worked.

Edit: I just put \\ in front of the path in the DoDropFiles() call.

Edited 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

I'm not so sure that I agree with your assessment...I'm trying to "drop" a drawing file into AutoCAD using this method, and I'm getting "Path not found" from AutoCAD. So I tried "dropping" it into notepad, and get a similar message. But if I launch Notepad with its' working directory set to the directory of the file I'm trying to "drop", it works. Then back to AutoCAD, same thing. If I launch it having set the working directory to the same path as the file I'm trying to drop, it works there too.

So it seems like it is a working directory issue, after all.

I tried on the CAD program I use (TurboCad) and it worked fine whether I added the preceeding "\\" or not when I tried to drop a file from a path on C:. However, when I tried a file from G:, even though G: was at th estart of the path, then TuboCAD gave an error message referring to the path I had given but with G: replaced by C:. I don't understand that, but if I use "\\G:\..." then it works ok.

EDIT: I was too slow for you james3mg :P

Edited 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

  • Moderators

martin,

Same here. "\\Path" works with a preopened Notepad. "Path" does not.

But I have rebooted my machine since I last tried (for an unrelated matter) and now the function works if I open Notepad from within the function, and do NOT specify (or leave as "") the working directory. It did not work like that this afternoon. And, yes I tried on both occasions with files on different paths in case it was some kind of cached memory. ;-)

Sorry to add to the confusion....

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

OK, so I've got one more question for you, that's only half related. If you wish, I'll pull out here and start another thread.

In AutoCAD, when you drag-n-drop a file from explorer into the AutoCAD window, it begins a block insert routine with that file. When I use this script, it OPENS that file for editing instead.

Are there other methods/slight variations on this script that you could think of for me to try and see if I could get the "insert" behavior instead of the "open" behavior?

Thanks for your work on this- I actually started a thread on this topic more than a year ago, and nobody got anywhere. This is so close, I can taste it! :P

"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

OK, so I've got one more question for you, that's only half related. If you wish, I'll pull out here and start another thread.

In AutoCAD, when you drag-n-drop a file from explorer into the AutoCAD window, it begins a block insert routine with that file. When I use this script, it OPENS that file for editing instead.

Are there other methods/slight variations on this script that you could think of for me to try and see if I could get the "insert" behavior instead of the "open" behavior?

Thanks for your work on this- I actually started a thread on this topic more than a year ago, and nobody got anywhere. This is so close, I can taste it! :P

Yes I remember your post about that but I still can't help.

I think it's related to posts #44 and #45 in this thread.

Dragging and dropping looks very complicated to me and what motionman95 and I have done is about as simple as it gets I think.

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

Yes I remember your post about that but I still can't help.

I think it's related to posts #44 and #45 in this thread.

Dragging and dropping looks very complicated to me and what motionman95 and I have done is about as simple as it gets I think.

I don't care so much about the dragging and dropping action itself (though that would be ideal), I'm just wondering if there are functions related to (or variations of) _WinAPI_PostMessage() that might send the same signal to AutoCAD that a drag-n-drop from explorer would. I've already tried the _SendMessage() that you'd had in there before, and it crashed AutoCAD. (not that I expected any better luck than you'd had, but I thought maybe AutoCAD was different than notepad :P )
"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

I think the results of this function center around how the struct looks. I'll have to do more research, but I promise to post my findings!

if that was directed at me, thank you :P
"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

OK, so I've got one more question for you, that's only half related. If you wish, I'll pull out here and start another thread.

In AutoCAD, when you drag-n-drop a file from explorer into the AutoCAD window, it begins a block insert routine with that file. When I use this script, it OPENS that file for editing instead.

Are there other methods/slight variations on this script that you could think of for me to try and see if I could get the "insert" behavior instead of the "open" behavior?

Thanks for your work on this- I actually started a thread on this topic more than a year ago, and nobody got anywhere. This is so close, I can taste it! :unsure:

@james3mg: This is directed at you. :P

I have 3 ideas about getting what you want, but since I don't use AutoCAD I can't test them:

  • In the function you could take the $Files path passed to it and read the file's contents and assign it to the $Files variable, and send that instead.
  • You may not be getting the insert operation because the PY and PX vars are null. Try changing them to some coords that are over the textbox in AutoCAD.
  • Also, use the AutoIt Window Info tool to get the Handle of the textbox in AutoCAD, and not the window's Handle.
Edited by motionman95
Link to comment
Share on other sites

@james3mg: This is directed at you. :P

I have 3 ideas about getting what you want, but since I don't use AutoCAD I can't test them:

  • In the function you could take the $Files path passed to it and read the file's contents and assign it to the $Files variable, and send that instead.
  • You may not be getting the insert operation because the PY and PX vars are null. Try changing them to some coords that are over the textbox in AutoCAD.
  • Also, use the AutoIt Window Info tool to get the Handle of the textbox in AutoCAD, and not the window's Handle.
Interesting thoughts. I don't think the text box has anything to do with it: when dragging from explorer, you drop the file over the drawing window, not the text box. Still, I'll try both.

I'll try sending the contents of the file, rather than the file path, but I'm guessing that's not the answer because there'd be no way of having AutoCAD assign the correct block name (the file name) in that case.

I'll also try getting the handle of the drawing window rather than the gui, as well as the textbox.

I'll report back; I appreciate your thoughts.

"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

I have found out why there was a problem with the paths, why setting the working directory was sometimes needed and why prefixing with "\\" helped. It was of course an error in the function.

Here is the corrected version and it seems to work faster now. (Possibly me kidding myself.)

Func DoDropFiles($wnd, $Files)
;$wnd is the handle of the control we are dropping onto
;$Files is the list of files separated by "|"
   $tagStruct1 = "int offset;int px;int py;byte fNC;byte fWide"
 
;grab some memory
     $hGlobal = _MemGlobalAlloc(14 + StringLen($Files) + 2)
;DropFiles := GlobalLock(MemHandle)
;translates the memory handle to a pointer
     $pDropFiles = _MemGlobalLock($hGlobal)
;create the struct in this memory
     $DropFiles = DllStructCreate($tagStruct1 & ";char  filelist[" & StringLen($Files) + 2 & "]", $pDropFiles)
     DllStructSetData($DropFiles, "offset", 14);14 = int+int+int+byte+byte
     $dummy = 0; done its job
     DllStructSetData($DropFiles, "px", 0);tried setting a point inside Notepad
     DllStructSetData($DropFiles, "py", 0);but it makes no difference
     DllStructSetData($DropFiles, "fwide", 0)
     DllStructSetData($DropFiles, "fNC", 0)
     DllStructSetData($DropFiles, "filelist", $Files)
;set the nulls in place of the separaters
     $Size = 0;
     $Files = StringSplit($Files, "|")
     For $I = 1 To $Files[0]
 
   ;// number of characters per string (as ANSI) plus one #0 terminator
   ;Inc(Size, Length(Files[I]) + 1);
         $Size += StringLen($Files[$I]) + 1
         DllStructSetData($DropFiles, "filelist", 0, $Size)
     Next
     ConsoleWrite(DllStructGetData($DropFiles, "filelist") & @CRLF)
;now add the extra null to terminate the list of strings
     DllStructSetData($DropFiles, "filelist", 0, $Size + 1)
     _MemGlobalUnlock($hGlobal)
     _WinAPI_PostMessage($wnd, $WM_DROPFILES, $hGlobal, 0);
;// ... and finally release the memory
 
     _MemGlobalFree($hGlobal)
 EndFunc;==>DoDropFiles

EDIT:I changed it yet again after I realized that the problem had been to do with byte alignment with the dummy struct which I have stopped using.

EDIT again:replaced $DllstructGetSize($dummy) with 14

Edited 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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...