Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/28/2025 in all areas

  1. I’m thrilled to introduce my IStream UDF, a sophisticated library designed to handle the COM IStream interface in AutoIt. This UDF enables management of data streams, whether from files, memory, or other sources, leveraging Windows IStream APIs. It provides a reliable solution for reading, writing, and administering streams in your AutoIt scripts. Whether you need to process large files, manipulate in-memory data, or handle transactional streams, this UDF is crafted to be versatile, well-documented, and user-friendly.Key Features Full Implementation of the IStream Interface: Supports all methods of the IStream interface (Read, Write, Seek, SetSize, CopyTo, Commit, Revert, LockRegion, UnlockRegion, Stat, Clone). Support for File and Memory Streams: Create streams from files using _SHCreateStreamOnFileEx or from in-memory data with _StreamCreateFromData, _SHCreateMemStream, and _StreamCreateFromDataOnHGlobal. Advanced Error Handling: Includes a detailed HRESULT error table ($tagIStreamErrorTable) and a _IStream_GetErrorInfo function for clear, understandable error messages. Utility Functions: Functions like _StreamGetSize, _StreamGetName, _StreamGetType, and _StreamStatDisplay simplify access to stream metadata. Comprehensive Documentation: Each function comes with standard UDF-format documentation, including syntax, parameters, return values, remarks, MSDN links, and practical examples. Compatibility: Works with AutoIt 3.3+ and relies on standard libraries (AutoItObject, WinAPI, Memory, Date). Use Cases Reading and writing large files without loading their entire content into memory. Handling in-memory binary data for applications such as network stream processing or serialized data manipulation. Supporting transactional streams for secure operations (e.g., via StgCreateDocfile). Integration with other COM interfaces requiring IStream. you need: AutoItObject.au3 Example: copy data between streams #include "IStream.au3" ; Example demonstrating the use of _StreamCopyToEx to copy data between streams Func Example_StreamCopyToEx() ; Create a source stream with the content "Strong" using _StreamCreateFromDataOnHGlobal ConsoleWrite("Creating source stream with 'Strong'..." & @CRLF) Local $iSrcSize,$aError Local $oSrcStream = _StreamCreateFromDataOnHGlobal("Strong", $iSrcSize, True) If @error Or Not IsObj($oSrcStream) Then ; Handle errors by displaying the HRESULT code and details from $tagIStreamErrorTable ConsoleWrite("Error: Failed to create source stream. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) $aError = _IStream_GetErrorInfo(@extended) If IsArray($aError) Then ConsoleWrite("Name: " & $aError[0] & @CRLF) ConsoleWrite("Description: " & $aError[1] & @CRLF) ConsoleWrite("Affected methods: " & $aError[2] & @CRLF) EndIf Return EndIf ConsoleWrite("Source stream created, size: " & $iSrcSize & " bytes" & @CRLF) ; Create a destination stream with the content "AutoIt is " using _StreamCreateFromDataOnHGlobal ConsoleWrite("Creating destination stream with 'AutoIt is '..." & @CRLF) Local $iDestSize Local $oDestStream = _StreamCreateFromDataOnHGlobal("AutoIt is ", $iDestSize, True) If @error Or Not IsObj($oDestStream) Then ; Handle errors for destination stream creation ConsoleWrite("Error: Failed to create destination stream. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) $aError = _IStream_GetErrorInfo(@extended) If IsArray($aError) Then ConsoleWrite("Name: " & $aError[0] & @CRLF) ConsoleWrite("Description: " & $aError[1] & @CRLF) ConsoleWrite("Affected methods: " & $aError[2] & @CRLF) EndIf ; Release the source stream and COM resources before exiting _StreamRelease($oSrcStream) Return EndIf ConsoleWrite("Destination stream created, size: " & $iDestSize & " bytes" & @CRLF) ; Copy the content from the source stream to the destination stream using _StreamCopyToEx ConsoleWrite("Copying 'Strong' to destination stream..." & @CRLF) Local $iBytesRead, $iBytesWritten If Not _StreamCopyToEx($oSrcStream, $oDestStream, $iSrcSize, $iBytesRead, $iBytesWritten) Then ; Handle errors during the copy operation ConsoleWrite("Error: _StreamCopyToEx failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) $aError = _IStream_GetErrorInfo(@extended) If IsArray($aError) Then ConsoleWrite("Name: " & $aError[0] & @CRLF) ConsoleWrite("Description: " & $aError[1] & @CRLF) ConsoleWrite("Affected methods: " & $aError[2] & @CRLF) EndIf ; Release both streams and COM resources before exiting _StreamRelease($oDestStream) _StreamRelease($oSrcStream) Return EndIf ConsoleWrite("Copied " & $iBytesRead & " bytes read, " & $iBytesWritten & " bytes written." & @CRLF) ; Read and display the content of the destination stream ConsoleWrite("Reading destination stream content..." & @CRLF) Local $iNewDestSize = _StreamGetSize($oDestStream) If @error Then ; Handle errors when retrieving the destination stream size ConsoleWrite("Error: Failed to get destination stream size. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) $aError = _IStream_GetErrorInfo(@extended) If IsArray($aError) Then ConsoleWrite("Name: " & $aError[0] & @CRLF) ConsoleWrite("Description: " & $aError[1] & @CRLF) ConsoleWrite("Affected methods: " & $aError[2] & @CRLF) EndIf ; Release both streams and COM resources before exiting _StreamRelease($oDestStream) _StreamRelease($oSrcStream) Return EndIf ConsoleWrite("Destination stream size after copy: " & $iNewDestSize & " bytes" & @CRLF) ; Position the stream pointer at the beginning for reading Local $pDestMem, $iDestRead _StreamSeek($oDestStream, 0, $STREAM_SEEK_SET) If @error Then ; Handle errors when seeking in the destination stream ConsoleWrite("Error: Failed to seek destination stream. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) $aError = _IStream_GetErrorInfo(@extended) If IsArray($aError) Then ConsoleWrite("Name: " & $aError[0] & @CRLF) ConsoleWrite("Description: " & $aError[1] & @CRLF) ConsoleWrite("Affected methods: " & $aError[2] & @CRLF) EndIf _StreamRelease($oDestStream) _StreamRelease($oSrcStream) Return EndIf ; Read the content of the destination stream _StreamRead($oDestStream, $iNewDestSize, $pDestMem, $iDestRead) If @error Then ; Handle errors when reading the destination stream ConsoleWrite("Error: Failed to read destination stream. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) $aError = _IStream_GetErrorInfo(@extended) If IsArray($aError) Then ConsoleWrite("Name: " & $aError[0] & @CRLF) ConsoleWrite("Description: " & $aError[1] & @CRLF) ConsoleWrite("Affected methods: " & $aError[2] & @CRLF) EndIf ; Free the memory buffer if allocated, then release streams and COM resources If $pDestMem Then _MemGlobalFree($pDestMem) _StreamRelease($oDestStream) _StreamRelease($oSrcStream) _WinAPI_CoUninitialize() Return EndIf ; Convert the read data to a string and display it Local $bufSize Local $bDestData = _WinAPI_GetBufferData($pDestMem, $bufSize) ConsoleWrite("Destination stream content: " & BinaryToString($bDestData, 4) & @CRLF) ; Free the memory buffer If $pDestMem Then _MemGlobalFree($pDestMem) ; Release both streams to prevent memory leaks _StreamRelease($oDestStream) _StreamRelease($oSrcStream) ConsoleWrite("COM uninitialized, resources freed." & @CRLF) EndFunc ;==>Example_StreamCopyToEx ; Run the example Example_StreamCopyToEx() example demonstrating multiple IStream interface methods #include "IStream.au3" ; Example demonstrating multiple IStream interface methods Func Example_IStream() ; Initialize the COM object model (required for COM API calls) _WinAPI_CoInitialize() ConsoleWrite("=== Creating Stream with SHCreateMemStream ===" & @CRLF) ; Create a memory stream with initial content "Hello, IStream UDF!" Local $sData = "Hello, IStream UDF!" Local $iSize = 0 Local $oStream = _StreamCreateFromData($sData, $iSize) If @error Then ; Handle stream creation error and display details ConsoleWrite("Error: Failed to create stream. @error = " & @error & @CRLF) _WinAPI_CoUninitialize() Return EndIf ConsoleWrite("Stream created successfully. Size: " & $iSize & " bytes" & @CRLF) ; Test IUnknown::QueryInterface to verify the IStream interface ConsoleWrite("Testing QueryInterface..." & @CRLF) Local $IID_IStream = "{0000000C-0000-0000-C000-000000000046}" Local $pQueriedStream = _StreamQueryInterface($oStream, $IID_IStream) If @error Then ; Handle QueryInterface error and release resources ConsoleWrite("Error: QueryInterface failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ConsoleWrite("QueryInterface succeeded." & @CRLF) ; Release the queried interface to prevent memory leaks DllCall("ole32.dll", "ulong", "Release", "ptr", $pQueriedStream) ; Test IStream::Write by appending additional data ConsoleWrite("Testing Write..." & @CRLF) Local $sNewData = " Additional data." ; 16 characters Local $iNewSize = 0 Local $pMemory = _StreamCreateMemoryBuffer($sNewData, $iNewSize) If @error Then ; Handle memory buffer creation error ConsoleWrite("Error: Failed to create memory buffer. @error = " & @error & @CRLF) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf Local $iWrittenSize = 0 ; Set the stream size to accommodate new data If Not _StreamSetSize($oStream, $iSize + $iNewSize) Then ConsoleWrite("Error: SetSize failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _WinAPI_FreeMemory($pMemory) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ; Move the stream pointer to the end for appending If Not _StreamSeek($oStream, $iSize, $STREAM_SEEK_SET) Then ConsoleWrite("Error: Seek failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _WinAPI_FreeMemory($pMemory) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ; Write the new data to the stream If Not _StreamWrite($oStream, $pMemory, $iNewSize, $iWrittenSize) Then ConsoleWrite("Error: Write failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _WinAPI_FreeMemory($pMemory) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ConsoleWrite("Wrote " & $iWrittenSize & " bytes." & @CRLF) ; Free the memory buffer _WinAPI_FreeMemory($pMemory) ; Test IStream::Seek to move the pointer to the beginning ConsoleWrite("Testing Seek..." & @CRLF) Local $iNewPosition = _StreamSeek($oStream, 0, $STREAM_SEEK_SET) If @error Then ConsoleWrite("Error: Seek failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ConsoleWrite("Stream pointer moved to: " & $iNewPosition & @CRLF) ; Test IStream::Read to retrieve the entire stream content ConsoleWrite("Testing Read..." & @CRLF) Local $pMemoryRead = 0, $iReadSize = 0 If Not _StreamRead($oStream, $iSize + $iNewSize, $pMemoryRead, $iReadSize) Then ConsoleWrite("Error: Read failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _WinAPI_FreeMemory($pMemoryRead) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf Local $bData = _WinAPI_GetBufferData($pMemoryRead, $iReadSize) ConsoleWrite("Read " & $iReadSize & " bytes: " & BinaryToString($bData) & @CRLF) _WinAPI_FreeMemory($pMemoryRead) ; Verify that the read data matches the expected content If $iReadSize <> $iSize + $iNewSize Or BinaryToString($bData) <> $sData & $sNewData Then ConsoleWrite("Error: Read data does not match expected: " & $sData & $sNewData & @CRLF) EndIf ; Test IStream::CopyTo by copying the stream to a new destination stream ConsoleWrite("Testing CopyTo..." & @CRLF) ; Create a destination stream Local $pDestStream = _WinAPI_CreateStreamOnHGlobal(0, True) If Not $pDestStream Then ConsoleWrite("Error: Failed to create destination stream." & @CRLF) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ; Move the source stream pointer to the beginning $iNewPosition = _StreamSeek($oStream, 0, $STREAM_SEEK_SET) If @error Then ConsoleWrite("Error: Seek failed on source stream. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) DllCall("ole32.dll", "ulong", "Release", "ptr", $pDestStream) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ; Copy the content to the destination stream Local $iBytesRead = 0, $iBytesWritten = 0 If Not _StreamCopyTo($oStream, $pDestStream, $iSize + $iNewSize, $iBytesRead, $iBytesWritten) Then ConsoleWrite("Error: CopyTo failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) DllCall("ole32.dll", "ulong", "Release", "ptr", $pDestStream) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ConsoleWrite("Copied " & $iBytesRead & " bytes read, " & $iBytesWritten & " bytes written." & @CRLF) ; Create an IStream object from the destination stream pointer Local $oDestStream = _AutoItObject_WrapperCreate($pDestStream, $tagIStream) If @error Then ConsoleWrite("Error: Failed to create destination stream object. @error = " & @error & @CRLF) DllCall("ole32.dll", "ulong", "Release", "ptr", $pDestStream) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ; Read and verify the destination stream content _StreamSeek($oDestStream, 0, $STREAM_SEEK_SET) Local $pDestMemory, $iDestReadSize If Not _StreamRead($oDestStream, $iSize + $iNewSize, $pDestMemory, $iDestReadSize) Then ConsoleWrite("Error: Reading destination stream failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _WinAPI_FreeMemory($pDestMemory) _StreamRelease($oDestStream) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf Local $bDestData = _WinAPI_GetBufferData($pDestMemory, $iDestReadSize) ConsoleWrite("Destination stream content: " & BinaryToString($bDestData, $SB_UTF8) & @CRLF) _WinAPI_FreeMemory($pDestMemory) ; Verify that the copied data matches the expected content ; Test IStream::Commit ConsoleWrite("Testing Commit..." & @CRLF) If Not _StreamCommit($oDestStream, $STGC_DEFAULT) Then ConsoleWrite("Error: Commit failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) Else ConsoleWrite("Commit succeeded." & @CRLF) EndIf ; Test IStream::Revert ConsoleWrite("Testing Revert..." & @CRLF) If Not _StreamRevert($oDestStream) Then ; Note that Revert may not be supported by memory streams ConsoleWrite("Note: Revert may not be supported. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) Else ConsoleWrite("Revert succeeded (unexpected for memory stream)." & @CRLF) EndIf ; Test IStream::LockRegion and UnlockRegion ConsoleWrite("Testing LockRegion..." & @CRLF) If Not _StreamLockRegion($oStream, 0, 10, 0) Then ; Note that LockRegion may not be supported by memory streams ConsoleWrite("Note: LockRegion may not be supported. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) __IStreamErrorInfo(@extended) Else ConsoleWrite("LockRegion succeeded." & @CRLF) ConsoleWrite("Testing UnlockRegion..." & @CRLF) If Not _StreamUnlockRegion($oStream, 0, 10, 0) Then ConsoleWrite("Error: UnlockRegion failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) Else ConsoleWrite("UnlockRegion succeeded." & @CRLF) EndIf EndIf ; Test IStream::Stat to retrieve stream metadata ConsoleWrite("Testing GetStat..." & @CRLF) Local $pStatFlag = 0 If Not _StreamGetStat($oStream, $pStatFlag) Then ConsoleWrite("Error: GetStat failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _StreamRelease($oDestStream) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ConsoleWrite("Displaying stream metadata:" & @CRLF) _StreamStatDisplay($pStatFlag) _WinAPI_CoTaskMemFree($pStatFlag) ; Test IStream::GetType and GetName ConsoleWrite("Testing GetType and GetName..." & @CRLF) Local $sType = _StreamGetType($oStream) If @error Then ConsoleWrite("Error: GetType failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) Else ConsoleWrite("Stream type: " & $sType & @CRLF) EndIf Local $sName = _StreamGetName($oStream) If @error Then ConsoleWrite("Error: GetName failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) Else ConsoleWrite("Stream name: " & $sName & @CRLF) EndIf ; Test IStream::Clone ConsoleWrite("Testing Clone..." & @CRLF) Local $pCloned Local $oCloneStream = _StreamClone($oStream, $pCloned) If @error Then ConsoleWrite("Error: Clone failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _StreamRelease($oDestStream) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ConsoleWrite("Clone stream created successfully." & @CRLF) _StreamRelease($oCloneStream) DllCall("ole32.dll", "ulong", "Release", "ptr", $pCloned) ; Clean up all resources _StreamRelease($oDestStream) _StreamRelease($oStream) _WinAPI_CoUninitialize() ConsoleWrite("All streams released and COM uninitialized." & @CRLF) EndFunc ;==>Example_IStream ; Run the example Example_IStream() The help file is included with the UDF IStream.zip New update Description: The IStream2 UDF (Interface Stream User Defined Function) is an AutoIt library designed to create, manipulate, and interact with IStream COM objects, implementing all methods of the IStream interface defined by Microsoft. This interface enables operations such as reading, writing, seeking, and copying on data streams, whether file-based or in-memory. Version 2 of this UDF has been optimized for native AutoIt usage, removing the dependency on AutoItObject.au3, making it lighter, self-contained, and more accessible.The UDF provides robust error handling through HRESULT codes, well-defined constants for COM flags (STGM, STGC, etc.), and comprehensive documentation for each function. It is ideal for developers looking to manipulate data streams in various contexts, such as file processing, memory management, or integration with structured storage systems. The previous version has been retained for compatibility reasons. This version 2 is designed to be fully compatible with any development using the IStorage interface, while avoiding data conflicts. IStream2.au3
    1 point
  2. MattyD

    WinRT - WinUI3

    my pleasure mate and thanks for the info. From some precursory reading, I think we might have to set a pallet for dark mode by setting the resources property of Microsoft.UI.Xaml.Application. But take that with a pinch of salt - I'll need to sus it out properly!
    1 point
  3. WildByDesign

    WinRT - WinUI3

    I appreciate the work that you are doing on this. It's interesting to follow your progress as well. I have to admit, I really like the look of that button. I had never really thought much of WinRT or WinUI3 before but it's got my attention now. One interesting thing: You can't see the button with the default Windows Dark theme. You can see the button with Windows Light theme and just about any other theme. But not default Dark theme for some reason. I suppose there must be more to the WinUI3 theming and theme detection but I don't understand it at all yet.
    1 point
  4. Am fixing a bunch of links ( not right now )... . Actually already did over a year ago, but got me a virus, reinstalled the PC, ..then work got heavy. Long story short, it's a mess that I'm working on untangling. This time I will document my steps so that they can be understood and shared, ..and !, avoid multiple people working on the same thing, without knowing who's doing what when. I'll open a thread called, hmm, "for the betterment of the help file in 2025", I think. Nope, we have this thread for that, dah. But an entry with a list of dead links. They are not that many and I thing I've got them all, ..I think. I'll compare what is now with what I fixed and list it in a post so that is publicly known. In any case, even tho I haven't updated that site in a year, I'll keep it updated with the fixes so that we can double check if the upcoming version fixed this or that. Today is Monday for me, ..I think by next Monday I'll that other site updated with the latest updates.
    1 point
  5. haha sure (bravely ran sir Robin!). But yeah, I'm happy enough to have a crack - and also to be swatted back. I just didn't want to be too presumptuous by putting something together. If you're fixing links though... its probably worth checking out a few more on that page. I haven't been through them all, but i know the garybeene.com ones under the "Advanced COM usage" section have also died of old age!
    1 point
  6. Just add _ScreenCapture_Capture that isn't a workaround. That would be the solution. You already have the ltwh as part of the highlight parameters.
    1 point
  7. Shall we do a copy-paste? 😁 ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: $tagIStreamErrorTable ; Description ...: 2D array containing possible HRESULT error codes for the IStream interface, along with their symbolic names and descriptions. ; Fields ........: HRESULT (hex) | Symbolic name | Description | Affected methods ; Author ........: Numeric1 ; Modified ......: 2025-07-27 ; Remarks .......: HRESULT codes starting with 0x8003 are specific to storage errors (STG_E_*). Use this array to translate HRESULT codes returned by IStream methods. ; Related .......: IStream UDF ; =============================================================================================================================== Global Const $tagIStreamErrorTable = [ _ ["0x80030001", "STG_E_INVALIDFUNCTION", "Function invalid for this stream type (e.g., Revert on a non-transactional stream).", "Revert, Commit, LockRegion, UnlockRegion"], _ ["0x80030002", "STG_E_FILENOTFOUND", "The specified file or stream does not exist.", "Stat"], _ ["0x80030008", "STG_E_TOOMANYOPENFILES", "Too many files or streams are open.", "Open, Create"], _ ["0x8003001D", "STG_E_INVALIDPOINTER", "Invalid pointer passed to the method.", "Read, Write, Seek, SetSize, CopyTo, Stat, Clone"], _ ["0x80030020", "STG_E_LOCKVIOLATION", "Lock violation (e.g., accessing a locked region).", "Read, Write, LockRegion, UnlockRegion"], _ ["0x80030021", "STG_E_FILEALREADYEXISTS", "The stream or file already exists.", "Create"], _ ["0x80030050", "STG_E_INVALIDNAME", "Invalid stream name.", "Stat"], _ ["0x80030057", "STG_E_INVALIDPARAMETER", "Invalid parameter passed to the method.", "Seek, CopyTo, Commit, LockRegion, UnlockRegion"], _ ["0x80030070", "STG_E_MEDIUMFULL", "The storage medium is full.", "Write, SetSize, CopyTo"], _ ["0x800300F0", "STG_E_READFAULT", "Error reading from the stream.", "Read, CopyTo"], _ ["0x800300FA", "STG_E_WRITEFAULT", "Error writing to the stream.", "Write, CopyTo, SetSize"], _ ["0x80030102", "STG_E_REVERTED", "The stream was reverted and is no longer valid.", "Read, Write, Seek"], _ ["0x80030103", "STG_E_NOTCURRENT", "The stream has been modified since the last operation.", "Commit, Revert"], _ ["0x80030104", "STG_E_CANTSAVE", "Unable to save changes to the stream.", "Commit"], _ ["0x8007000E", "E_OUTOFMEMORY", "Insufficient memory to perform the operation.", "Read, Write, SetSize, CopyTo, Clone"], _ ["0x80070057", "E_INVALIDARG", "One or more arguments are invalid.", "Read, Write, Seek, SetSize, CopyTo, Commit, LockRegion, UnlockRegion, Stat, Clone"], _ ["0x80004001", "E_NOTIMPL", "The method is not implemented for this stream type (e.g., LockRegion on a memory stream).", "LockRegion, UnlockRegion"], _ ["0x80004005", "E_FAIL", "Unspecified operation failure.", "All methods"], _ ["0x80030006", "STG_E_INSUFFICIENTMEMORY", "Insufficient memory for the operation (similar to E_OUTOFMEMORY).", "Read, Write, SetSize, CopyTo, Clone"] _ ] thanks
    1 point
  8. The example #3 in DllCall() has a "none" where "int" should go. And if the user cancel the "PickIconDlg GUI" there's no way to know. So I was thinking of change it to something like: #include <MsgBoxConstants.au3> ; Show the Windows PickIconDlg. Local $sFileName = @SystemDir & '\shell32.dll' ; Create a structure to store the icon index Local $tIconIndex = DllStructCreate("int") Local $tString = DllStructCreate("wchar[260]") Local $iStructsize = DllStructGetSize($tString) / 2 DllStructSetData($tString, 1, $sFileName) ; Run the PickIconDlg - '62' is the ordinal value for this function Local $aCall = DllCall("shell32.dll", "int", 62, _ "hwnd", 0, _ "struct*", $tString, _ "int", $iStructsize, _ "struct*", $tIconIndex) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Error", "DllCall error = " & @error) If Not $aCall[0] Then Exit MsgBox($MB_SYSTEMMODAL, "Info", "Cancelled by user.") $sFileName = DllStructGetData($tString, 1) Local $iIconIndex = DllStructGetData($tIconIndex, 1) ; Show the new filename and icon index MsgBox($MB_SYSTEMMODAL, "Info", "Last selected file: " & $sFileName & @CRLF & "Icon-Index: " & $iIconIndex) or use the one from @rasim at /topic/80978-icon-selector/. What say you ?
    1 point
  9. Hey, got it working on Win10. Never expected it. Found some code about forcing the creation of a WorkerW handle. Let's see if it does the job for your too. #include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> Opt("MustDeclareVars", True) HotKeySet("{ESC}", Terminate) Example() Func Example() Local $hProgman = WinGetHandle("[CLASS:Progman]") _SendMessage($hProgman, 0x052c) ; <<<<<< force the creation of a WorkerW handle under Progman Local $aList = WinList(), $hWorkerW For $i = 1 To $aList[0][0] If _WinAPI_GetParent($aList[$i][1]) = $hProgman And _WinAPI_GetClassName($aList[$i][1]) = "WorkerW" Then $hWorkerW = $aList[$i][1] ExitLoop EndIf Next ConsoleWrite("WorkerW " & $hWorkerW & @CRLF) Local $hGUI = GUICreate("Overlay", 400, 300, 10, 10, $WS_POPUP, $WS_EX_TOOLWINDOW) GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 400, 300) _WinAPI_SetParent($hGUI, $hWorkerW) _WinAPI_SetWindowLong($hGUI, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hGUI, $GWL_EXSTYLE), $WS_EX_LAYERED)) _WinAPI_SetLayeredWindowAttributes($hGUI, 0, 180) GUISetState(@SW_SHOWNOACTIVATE) While Sleep(100) WEnd EndFunc ;==>Example Func Terminate() Exit EndFunc ;==>Terminate
    1 point
  10. ;This script will calculate the Nth weekday of any month. Just replace the numbers for $Year, $Month, $Week, and $Weekday with numbers of your choice, ;Some lines are not really needed but are there to allow testing and proofing. It is based on Excel formula. #include <Date.au3> Global $tmp, $Year = "2019", $Month = "2", $Week = 2, $WeekDay = 4 Global $aNth = StringSplit("First ,Second ,Third ,Fourth ,Fifth ", ",") Func GetWeekDay($Week, $Year, $Month, $WeekDay) Local $LastDay = 8 - $WeekDay, $EndDay = $Week * 7 + 1 $Month = $Month > 10 ? $Month : "0" & $Month Local $iWday = _DateToDayOfWeek($YEAR, $Month, $LastDay) Return $YEAR & "/" & $Month & "/" & $EndDay - $iWday EndFunc MsgBox(0,'',$aNth[$Week] & _DateDayOfWeek($WeekDay) & " of " & _DateToMonth($Month) & _ " " & $Year & " is " & GetWeekDay($Week, $Year, $Month, $WeekDay) ) GetNthWeekDay.au3
    1 point
×
×
  • Create New...