Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/07/2023 in all areas

  1. @KaFu That's true. I read now on MSDN: So it should be something like this: #include <Memory.au3> #include <Clipboard.au3> #include <WinAPIConv.au3> $sFilePath = '<path to your file'> _ClipPutFile($sFilePath) Func _ClipPutFile($sFile) Local $iLen = StringLen($sFile) _ClipBoard_Open(0) _ClipBoard_Empty() Local $hGlobal = _MemGlobalAlloc(($iLen + 2) * 2 + 20, $GMEM_MOVEABLE) Local $hLock = _MemGlobalLock($hGlobal) $tDROPFILES = DllStructCreate("dword pFiles;long x;long y;int fNC;int fWide;wchar File[" & $iLen & "];wchar Null[2]", $hLock) $tDROPFILES.pFiles = DllStructGetPtr($tDROPFILES, 'File') - DllStructGetPtr($tDROPFILES, 'pFiles') $tDROPFILES.x = 0 $tDROPFILES.y = 0 $tDROPFILES.fNC = 0 $tDROPFILES.fWide = 1 _WinAPI_MultiByteToWideCharEx($sFile, DllStructGetPtr($tDROPFILES, 'File')) $tDROPFILES.Null = Chr(0) & Chr(0) _ClipBoard_SetDataEx($hGlobal, $CF_HDROP) _MemGlobalUnlock($hGlobal) _ClipBoard_Close() EndFunc
    2 points
  2. I think it's wrong to free the Mem, as it will be handled by the OS. Here's a snippet I use in SMF. #include <ClipBoard.au3> #include <WinAPISysWin.au3> Global Const $DROPFILES = "DWORD pFiles; int pt[2]; int fNC; int fWide;" Global Const $CFSTR_PREFERREDDROPEFFECT = "Preferred DropEffect" Global Const $CF_PREFERREDDROPEFFECT = _ClipBoard_RegisterFormat($CFSTR_PREFERREDDROPEFFECT) Global Const $DROPEFFECT_COPY = 1 Global Const $DROPEFFECT_MOVE = 2 _Clipboard_Copy_File(@ScriptFullPath) ; _Clipboard_Move_File(@ScriptFullPath) Func _Clipboard_Copy_File($sFile) Local $hClip = _ClipBoard_Open(_WinAPI_GetDesktopWindow()) If $hClip Then _ClipBoard_Empty() Local $HDROP = _CreateDROPFILES($sFile) ; Mem must NOT be freed via_MemGlobalFree(), as script will crash or fail. Mem will be handled by OS. Local $DROPEFFECT = _CreatePREFERREDDROPEFFECT($DROPEFFECT_COPY) ; Mem must NOT be freed via_MemGlobalFree(), as script will crash or fail. Mem will be handled by OS. _ClipBoard_SetDataEx($HDROP, $CF_HDROP) _ClipBoard_SetDataEx($DROPEFFECT, $CF_PREFERREDDROPEFFECT) _ClipBoard_Close() EndIf EndFunc ;==>_Clipboard_Copy_File Func _Clipboard_Move_File($sFile) Local $hClip = _ClipBoard_Open(_WinAPI_GetDesktopWindow()) If $hClip Then _ClipBoard_Empty() Local $HDROP = _CreateDROPFILES($sFile) ; Mem must NOT be freed via_MemGlobalFree(), as script will crash or fail. Mem will be handled by OS. Local $DROPEFFECT = _CreatePREFERREDDROPEFFECT($DROPEFFECT_MOVE) ; Mem must NOT be freed via_MemGlobalFree(), as script will crash or fail. Mem will be handled by OS. _ClipBoard_SetDataEx($HDROP, $CF_HDROP) _ClipBoard_SetDataEx($DROPEFFECT, $CF_PREFERREDDROPEFFECT) _ClipBoard_Close() EndIf EndFunc ;==>_Clipboard_Move_File ;=============================================================================== ; ; Function Name: _CreateDROPFILES ; Description:: Creates a DROPFILES-structure ; Parameter(s): $Files - Pipe-separated list of files to copy: example: C:\File1.bin|D:\AnotherFile.dat ; Requirement(s): COM/OLE UDF ; Return Value(s): HGLOBAL-Pointer to a DROPFILES structure ; Author(s): prog@ndy ; ;=============================================================================== ; http://www.autoitscript.com/forum/index.php?showtopic=91046&view=findpost&p=654849 ; http://www.autoit.de/index.php?page=Thread&postID=81909&highlight=hdrop#post81909 Func _CreateDROPFILES($Files) $Files = String($Files) Local $hMem = _MemGlobalAlloc(_DragDrop_SIZEOF($DROPFILES) + ((StringLen($Files) + 2) * 2), $GPTR) $Files = StringSplit($Files, "|") Local $stDROPFILES = DllStructCreate($DROPFILES, $hMem) Local $hPtr = $hMem + DllStructGetSize($stDROPFILES) DllStructSetData($stDROPFILES, "fWide", 1) DllStructSetData($stDROPFILES, 1, DllStructGetSize($stDROPFILES)) For $i = 1 To $Files[0] $next = DllStructCreate("wchar[" & StringLen($Files[$i]) + 1 & "]", $hPtr) DllStructSetData($next, 1, $Files[$i] & ChrW(0)) $hPtr += (StringLen($Files[$i]) + 1) * 2 Next Local $next = DllStructCreate("wchar[1]", $hPtr) DllStructSetData($next, 1, ChrW(0)) Return $hMem EndFunc ;==>_CreateDROPFILES ; Prog@ndy Func _CreatePREFERREDDROPEFFECT($dwEffect) Local $pMem = _MemGlobalAlloc(4, $GPTR) ; 4 bytes - 1 DWORD If Not $pMem Then Return SetError(1, 0, 0) DllStructSetData(DllStructCreate("DWORD", $pMem), 1, $dwEffect) Return $pMem EndFunc ;==>_CreatePREFERREDDROPEFFECT ; Author: Prog@ndy Func _DragDrop_SIZEOF($tagStruct) Return DllStructGetSize(DllStructCreate($tagStruct, 1)) EndFunc ;==>_DragDrop_SIZEOF
    2 points
  3. Glad you were able to solve your own problem. FWIW, there is already some websocket UDFs on the forum that you may want to check out. This post has details on the original source and my modification.
    1 point
  4. My guess is that you have an issue with your unmask routine. Can you post an example of the raw data received by TCPRecv?
    1 point
  5. Try setting the default you want for: and see if that fixes it as i believe i haven't changed the default and am not sure i should. (Not at a computer right now so can't check) Will check when back at my computer.
    1 point
  6. The code works but it's not unicode. #include <Memory.au3> #include <Clipboard.au3> #include <WinAPIConv.au3> $sFilePath = '<path to your file'> _ClipPutFile($sFilePath) Func _ClipPutFile($sFile) Local $iLen = StringLen($sFile) _ClipBoard_Open(0) _ClipBoard_Empty() Local $hGlobal = _MemGlobalAlloc(($iLen + 2) * 2 + 20, $GMEM_MOVEABLE) Local $hLock = _MemGlobalLock($hGlobal) $tDROPFILES = DllStructCreate("dword pFiles;long x;long y;int fNC;int fWide;wchar File[" & $iLen & "];wchar Null[2]", $hLock) $tDROPFILES.pFiles = DllStructGetPtr($tDROPFILES, 'File') - DllStructGetPtr($tDROPFILES, 'pFiles') $tDROPFILES.x = 0 $tDROPFILES.y = 0 $tDROPFILES.fNC = 0 $tDROPFILES.fWide = 1 _WinAPI_MultiByteToWideCharEx($sFile, DllStructGetPtr($tDROPFILES, 'File')) $tDROPFILES.Null = Chr(0) & Chr(0) _ClipBoard_SetDataEx($hGlobal, $CF_HDROP) _MemGlobalUnlock($hGlobal) _ClipBoard_Close() _MemGlobalFree($hGlobal) EndFunc
    1 point
×
×
  • Create New...