motionman95 Posted February 21, 2009 Author Share Posted February 21, 2009 How do I detect the mouse leaving the window? Link to comment Share on other sites More sharing options...
Authenticity Posted February 21, 2009 Share Posted February 21, 2009 Your window? WM_CAPTURECHANGED, SetCapture, GetCapture... Link to comment Share on other sites More sharing options...
motionman95 Posted February 21, 2009 Author Share Posted February 21, 2009 (edited) Thanks for all the patience given, especially the response by martin. But I have a new question: How would I go about sending the WM_DROPFILES to a window? This is how it was described to do it on E Exchange:Yes, it is possible and quite easy:1) Use ::GetDesktopWindow() to get the HWND to the desktop window.2) Use ::SendMessage() to send the WM_DROPFILES message to that window.The syntax is:::SendMessage(hWnd, WM_DROPFILES, (WPARAM)&hDrop, 0);3) hDrop is a pointer to an HDROP structI'm having trouble with number 3, because I have no clue as to what a struct is, or how to make one. Any suggestions?EDIT: Also, here's the MSDN page on it: http://msdn.microsoft.com/en-us/library/bb774303.aspxEDIT: I even found the ShellAPI.h file where the hDrop struct is defined!http://www.csee.umbc.edu/~squire/download/ShellAPI.h Edited February 21, 2009 by motionman95 Link to comment Share on other sites More sharing options...
bobchernow Posted February 21, 2009 Share Posted February 21, 2009 Thanks for all the patience given, especially the response by martin. But I have a new question: How would I go about sending the WM_DROPFILES to a window? This is how it was described to do it on E Exchange: I'm having trouble with number 3, because I have no clue as to what a struct is, or how to make one. Any suggestions? EDIT: Also, here's the MSDN page on it: http://msdn.microsoft.com/en-us/library/bb774303.aspx EDIT: I even found the ShellAPI.h file where the hDrop struct is defined!http://www.csee.umbc.edu/~squire/download/ShellAPI.h"</a>"> <a href="http://www.csee.umbc.edu/~squire/download/ShellAPI.h" target="_blank">http://www.csee.umbc.edu/~squire/download/ShellAPI.h</a> The structs can be a bit to handle but I would say to go look at the examples for DLLStructCreate, DLLStructSetData and DLLStructGetData for a starter. That really should be enough to get you going. Bob You seem to be getting a lot more replies since you placed the code in the forum :-) --------------------bobchernow, Bob ChernowWhat a long strange trip it's beenUDFs: [post="635594"]Multiple Monitor Screen Resolution Change[/post] Link to comment Share on other sites More sharing options...
motionman95 Posted February 21, 2009 Author Share Posted February 21, 2009 Well, I've gotten somewhere! :) This works: #include <SendMessage.au3> $WM_DROPFILES = 0x0233 $HWND = WinGetHandle("Untitled - Notepad") $WPARAM = 0 $hDrop = "C:\Documents and Settings\Owner\Desktop\testFile.txt" _SendMessage($HWND, $WM_DROPFILES, $WPARAM & $hDrop, 0); But notepad always pops up a message box saying "The specified file cannot be found". Any ideas? Link to comment Share on other sites More sharing options...
motionman95 Posted February 22, 2009 Author Share Posted February 22, 2009 Does anyone know if I can get the hDrop from a WM_DROPFILE sent to my app? I want it so I can see how it looks and how to send it, cause I'm getting nowhere farther than what I've posted above. Link to comment Share on other sites More sharing options...
motionman95 Posted February 22, 2009 Author Share Posted February 22, 2009 Bump Link to comment Share on other sites More sharing options...
motionman95 Posted February 22, 2009 Author Share Posted February 22, 2009 (edited) It looks like piccaso had a similar problem to the one I'm having, but his code makes no sense to me.http://www.autoitscript.com/forum/index.ph...st&p=184807 Edited February 22, 2009 by motionman95 Link to comment Share on other sites More sharing options...
motionman95 Posted February 25, 2009 Author Share Posted February 25, 2009 Can anyone help me convert this Delphi to Autoit? expandcollapse popupprocedure DoDropFiles(Wnd: HWND; Files: TStringList); var Size: Cardinal; DropFiles: PDropFiles; Run: PChar; MemHandle: THandle; I: Integer; begin // first determine size of string buffer we have to allocate Size := 0; for I := 0 to Files.Count - 1 do begin // number of characters per string (as ANSI) plus one #0 terminator Inc(Size, Length(Files[I]) + 1); end; if Size > 0 then begin // entire string list is terminated by another #0, add drop files structure size too Inc(Size, 1 + SizeOf(TDropFiles)); // allocate globally accessible memory MemHandle := GlobalAlloc(GHND or GMEM_SHARE, Size); DropFiles := GlobalLock(MemHandle); // fill the header with DropFiles^ do begin pFiles := SizeOf(TDropFiles); // offset of file list, it follows immediately the structure pt := Point(0, 0); // drop point (client coords), not important here fNC := False; // is it on NonClient area }, not important here fWide := False; // WIDE character switch, we pass ANSI string in this routine end; // and finally the file names Run := Pointer(DropFiles); Inc(Run, SizeOf(TDropFiles)); for I := 0 to Files.Count - 1 do begin StrPCopy(Run, Files[I]); Inc(Run, Length(Files[I])); end; // put a final #0 character at the end Run^ := #0; // release the lock we have to the memory,... GlobalUnlock(MemHandle); // ...do the message... SendMessage(Wnd, WM_DROPFILES, MemHandle, 0); // ... and finally release the memory GlobalFree(MemHandle); end; end; procedure TMainForm.Button1Click(Sender: TObject); var List: TStringList; begin List := TStringList.Create; try List.Add('C:\Data\Test.txt'); DoDropFiles(Handle, List); finally List.Free; end; end; Link to comment Share on other sites More sharing options...
martin Posted February 25, 2009 Share Posted February 25, 2009 (edited) Can anyone help me convert this Delphi to Autoit? expandcollapse popupprocedure DoDropFiles(Wnd: HWND; Files: TStringList); var Size: Cardinal; DropFiles: PDropFiles; Run: PChar; MemHandle: THandle; I: Integer; begin // first determine size of string buffer we have to allocate Size := 0; for I := 0 to Files.Count - 1 do begin // number of characters per string (as ANSI) plus one #0 terminator Inc(Size, Length(Files[I]) + 1); end; if Size > 0 then begin // entire string list is terminated by another #0, add drop files structure size too Inc(Size, 1 + SizeOf(TDropFiles)); // allocate globally accessible memory MemHandle := GlobalAlloc(GHND or GMEM_SHARE, Size); DropFiles := GlobalLock(MemHandle); // fill the header with DropFiles^ do begin pFiles := SizeOf(TDropFiles); // offset of file list, it follows immediately the structure pt := Point(0, 0); // drop point (client coords), not important here fNC := False; // is it on NonClient area }, not important here fWide := False; // WIDE character switch, we pass ANSI string in this routine end; // and finally the file names Run := Pointer(DropFiles); Inc(Run, SizeOf(TDropFiles)); for I := 0 to Files.Count - 1 do begin StrPCopy(Run, Files[I]); Inc(Run, Length(Files[I])); end; // put a final #0 character at the end Run^ := #0; // release the lock we have to the memory,... GlobalUnlock(MemHandle); // ...do the message... SendMessage(Wnd, WM_DROPFILES, MemHandle, 0); // ... and finally release the memory GlobalFree(MemHandle); end; end; procedure TMainForm.Button1Click(Sender: TObject); var List: TStringList; begin List := TStringList.Create; try List.Add('C:\Data\Test.txt'); DoDropFiles(Handle, List); finally List.Free; end; end;I think the function translates to something like this (rather hurredly done). I have not tested it. I have never tried allocating memory in the global heap and then creating a dllstruct there so what I've done might not work, but I think it's fairly close. If it does work, or if someone can educate me about this I would be interested. Of course I can experiment and find out for myself but not now. I haven't translated the Delphi code line for line because I thought it was easier (providing it works) to create the struct directly in the allocated memory and write the data to the struct. expandcollapse popupFunc 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;int fNC;int fWide") ;grab some memory $hGlobal = DllCall("kernel32.dll", "ptr", "GlobalLock", "uint", 0, "dword", DllStructGetSize($dummy + StringLen(Files) + 2) $hGlobal = $hGlobal[0] ;DropFiles := GlobalLock(MemHandle);translates the memory handle to a pointer $pDropFiles = DllCall("kernel32.dll", "ptr", "GlobalAlloc", "ptr", $hGlobal) $pDropFiles = $pDropFile[0] ;create the struct in this memory $DropFiles = DllStructCreate("int offset;int px;int py;int fNC;int fWide;char filelist[" & StringLen($Files) + 2 & "]", $pDropFiles) DllStructSetData($DropFiles, "offset", DllStructGetSize($dummy)) $dummy = 0; done its job DllStructSetData($DropFiles, "px", 0) DllStructSetData($DropFiles, "py", 0) DllStructSetData($DropFiles, "fwide", 0) DllStructSetData($DropFiles, "fNC", 0) ;set the nulls in place of the separaters $Size = 0; $Files = StringSplit($Files, "|") For $I = 1 To $Files[0] Do ;// number of characters per string (as ANSI) plus one #0 terminator ;Inc(Size, Length(Files[I]) + 1); $Size += StrLen($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) DllCall("kernel32.dll", "int", "GlobalUnlock", "ptr", $hGlobal) _SendMessage($wnd, $WM_DROPFILES, $hGlobal[0], 0); ;// ... and finally release the memory ;GlobalFree($hGlobal[0]); DllCall("kernel32.dll", "ptr", "GlobalFree", "ptr", $hGlobal) EndFunc ;==>DoDropFiles EDIT:Correct typo. "hptr" should have been "ptr" Edited February 25, 2009 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...
motionman95 Posted February 25, 2009 Author Share Posted February 25, 2009 I fixed it so now it only throws one error: (53) : ==> Subscript used with non-Array variable.: $hGlobal = $hGlobal[0] $hGlobal = $hGlobal^ ERROR expandcollapse popupFunc 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;int fNC;int fWide") ;grab some memory $hGlobal = DllCall("kernel32.dll", "hptr", "GlobalLock", "uint", 0, "dword", DllStructGetSize($dummy + StringLen($Files) + 2)) $hGlobal = $hGlobal[0] ;DropFiles := GlobalLock(MemHandle);translates the memory handle to a pointer $pDropFiles = DllCall("kernel32.dll", "ptr", "GlobalAlloc", "ptr", $hGlobal) $pDropFiles = $pDropFiles[0] ;create the struct in this memory $DropFiles = DllStructCreate("int offset;int px;int py;int fNC;int fWide;char filelist[" & StringLen($Files) + 2 & "]", $pDropFiles) DllStructSetData($DropFiles, "offset", DllStructGetSize($dummy)) $dummy = 0; done its job DllStructSetData($DropFiles, "px", 0) DllStructSetData($DropFiles, "py", 0) DllStructSetData($DropFiles, "fwide", 0) DllStructSetData($DropFiles, "fNC", 0) ;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 ;now add the extra null to terminate the list of strings DllStructSetData($DropFiles, "filelist", 0, $Size + 1) DllCall("kernel32.dll", "int", "GlobalUnlock", "ptr", $hGlobal) _SendMessage($wnd, $WM_DROPFILES, $hGlobal[0], 0); ;// ... and finally release the memory ;GlobalFree($hGlobal[0]); DllCall("kernel32.dll", "ptr", "GlobalFree", "ptr", $hGlobal) EndFunc ;==>DoDropFiles Link to comment Share on other sites More sharing options...
motionman95 Posted February 25, 2009 Author Share Posted February 25, 2009 Wouldn't using this function be better? I'm not sure how to use it though, or what param I'd pass to it... #include <Memory.au3> _MemGlobalLock() Link to comment Share on other sites More sharing options...
martin Posted February 25, 2009 Share Posted February 25, 2009 (edited) Wouldn't using this function be better? I'm not sure how to use it though, or what param I'd pass to it... #include <Memory.au3> _MemGlobalLock() Maybe. Is there a difference between what the functions in Memory do and what I did? If so then use the Memory udf because that's been tested. This line $hGlobal = DllCall("kernel32.dll", "hptr", "GlobalLock", "uint", 0, "dword", DllStructGetSize($dummy + StringLen($Files) + 2)) should be $hGlobal = DllCall("kernel32.dll", "ptr", "GlobalLock", "uint", 0, "dword", DllStructGetSize($dummy + StringLen($Files) + 2)) "hptr" is a typo in my earlier post. Edited February 25, 2009 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...
motionman95 Posted February 25, 2009 Author Share Posted February 25, 2009 Here's my new code, but notepad simply crashes. expandcollapse popup$HWND = WinGetHandle("Untitled - Notepad") DoDropFiles($HWND, "C:\Documents and Settings\Owner\Desktop\k.txt") 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;int fNC;int fWide") ;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;int fNC;int fWide;char filelist[" & StringLen($Files) + 2 & "]", $pDropFiles) DllStructSetData($DropFiles, "offset", DllStructGetSize($dummy)) $dummy = 0; done its job DllStructSetData($DropFiles, "px", 0) DllStructSetData($DropFiles, "py", 0) DllStructSetData($DropFiles, "fwide", 0) DllStructSetData($DropFiles, "fNC", 0) ;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 ;now add the extra null to terminate the list of strings DllStructSetData($DropFiles, "filelist", 0, $Size + 1) _MemGlobalUnlock($hGlobal) _SendMessage($wnd, $WM_DROPFILES, $hGlobal, 0); ;// ... and finally release the memory ;GlobalFree($hGlobal[0]); _MemGlobalFree($hGlobal) EndFunc ;==>DoDropFiles Link to comment Share on other sites More sharing options...
motionman95 Posted February 26, 2009 Author Share Posted February 26, 2009 Well, guess I'll have to keep looking! Thanks, martin! Link to comment Share on other sites More sharing options...
martin Posted February 26, 2009 Share Posted February 26, 2009 (edited) Well, guess I'll have to keep looking! Thanks, martin! I had another quick look and I see I missed out the most important line. I didn't know how a boolean type was stored so I had guessed as "int" so I also changed the boolean items from "int" to "byte". Notepad doesn't crash now but no files either. Maybe it's progress. Perhaps there is still something wrong with the struct. expandcollapse popup#include <memory.au3> #include <windowsconstants.au3> Const $WM_DROPFILES = 0x233 $HWND = WinGetHandle("Untitled - Notepad") DoDropFiles($HWND, "C:\Documents and Settings\Owner\Desktop\k.txt") 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", 300);tried setting a point inside Notepad DllStructSetData($DropFiles, "py", 300);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) _SendMessage($wnd, $WM_DROPFILES, $hGlobal, 0); ;// ... and finally release the memory _MemGlobalFree($hGlobal) EndFunc;==>DoDropFiles Maybe there is still something wrong with the way I created the struct. The thing to do is to try to examine the struct given to aby registering $WM_DROPFILES and see if it is what you would expect EDIT: for a working function after changes by motionma95 and by me see post #60 Edited February 28, 2009 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...
motionman95 Posted February 26, 2009 Author Share Posted February 26, 2009 Here - this new code works! You have to use _WinAPI_PostMessage() instead of SendMessage()! Thanks martin! You rock!expandcollapse popup#include <WinAPI.au3> #include <Memory.au3> #include <Misc.au3> Const $WM_DROPFILES = 0x233 $HWND = WinGetHandle("Untitled - Notepad") DoDropFiles($HWND, "C:\Documents and Settings\Owner\Desktop\k.txt") 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", 300);tried setting a point inside Notepad DllStructSetData($DropFiles, "py", 300);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 Link to comment Share on other sites More sharing options...
martin Posted February 26, 2009 Share Posted February 26, 2009 Here - this new code works! You have to use _WinAPI_PostMessage() instead of SendMessage()! Thanks martin! You rock! expandcollapse popup#include <WinAPI.au3> #include <Memory.au3> #include <Misc.au3> Const $WM_DROPFILES = 0x233 $HWND = WinGetHandle("Untitled - Notepad") DoDropFiles($HWND, "C:\Documents and Settings\Owner\Desktop\k.txt") 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", 300);tried setting a point inside Notepad DllStructSetData($DropFiles, "py", 300);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 ;==>DoDropFilesThat's amazing How did you find out that you have to use PostMessage? It means that Delphi code is wrong doesn't it. The 300,300 point can be changed back to 0,0 now. 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...
ResNullius Posted February 27, 2009 Share Posted February 27, 2009 (edited) @motionman95 & martin, Great work, but.... I'm having a problem where if my file to drop is in a different folder than the script proper, it fails and notepad gives a "Cannot open the \Temp\DoDropTest.txt file. Make sure a disk is in the drive you specified."message. Here is the modified beginning I am using for an example $winTitle = "Untitled - Notepad" If not WinExists($winTitle) then Run("notepad.exe") WinWait($WinTitle) EndIf WinActivate($WinTitle) $HWND = WinGetHandle($WinTitle) $fnTestText = @ScriptDir & "\DoDropTest.txt" ;$fnTestText = @TempDir & "\DoDropTest.txt" $fhTestText = FileOpen($fnTestText,2) FileWriteLine($fhTestText,"This is some text") FileWriteLine($fhTestText,"This is some more text") FileWriteLine($fhTestText,"This is the third line of text") FileWriteLine($fhTestText, "GoodBye!") FileClose($fhTestText) DoDropFiles($HWND, $fnTestText) Works fine like that, but if I uncomment the ;$fnTestText = @TempDir & "\DoDropTest.txt line to create the test file in the Temp directory instead of the same one the script is in it fails. Any thoughts? BTW, tested on Win 2000. Edited February 27, 2009 by ResNullius Link to comment Share on other sites More sharing options...
ResNullius Posted February 27, 2009 Share Posted February 27, 2009 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... 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