Jump to content

_ScreenCapture_CaptureWnd() in v3.3.14.3 is not creating the capture file


TheXman
 Share

Recommended Posts

The _ScreenCapture_CaptureWnd() logic may have an issue in v3.3.14.3.  I was testing scripts using v3.3.14.3 and saw that the scripts' screen captures weren't getting created.  I immediately ran the scripts using v3.3.14.2 and the screen captures were being created as expected. The _ScreenCapture_CaptureWnd() function, in v3.3.14.3, returns @error = -2. 

Can anyone else confirm that they are seeing the same issue?

Below is a slightly modified version of the function's help file's _ScreenCapture_CaptureWnd() example that should allow you to recreate the issue.

 

#include <Constants.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Screen Capture", 400, 300)
    GUISetState(@SW_SHOW)
    Sleep(250)

    ; Capture window
    _ScreenCapture_CaptureWnd(@TempDir & "\GDIPlus_Image.jpg", $hGUI)
    If @error Then
        MsgBox($MB_ICONERROR, "", _
            "_ScreenCapture_CaptureWnd() failed." & @CRLF & @CRLF & _
            "@error = " & @error _
        )
        Exit 1
    EndIf

    ShellExecute(@TempDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example

 

Edited by TheXman
Corrected the @error code from 2 to -2
Link to comment
Share on other sites

  • Moderators

TheXman,

I have found the cause of the error - deep in the GDIPlus library - and I know how to fix it. But before I do, I need to talk to the GDI gurus to see if changing this single line will impact anything else in the library.

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

Link to comment
Share on other sites

  • Moderators

The XMan,

The culprit actually appears to be the the _WinAPI_WideCharToMultiByte function, so the problem might be wider than just the GDIPlus library and many thanks for the bug report which has highlighted this problem. We are now investigating why this function no longer returns what other dependent functions are obviously expecting.

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

@Melba23,

Has there been any progress in resolving the root cause of this issue?  Will the notification of a fix be posted back here, to the sticky post related to 3.3.14.3 fixes, or somewhere else?

I've been holding off on doing any further testing of 3.3.14.3 since what you believe to be the issue is such a low-level issue and may have wider ramifications.

Thanks,
TheXman

Link to comment
Share on other sites

  • Moderators

TheXman,

We have some working code and I will post the amended WinAPIConv library soon in the "3.3.14.3. Fixes" thread.

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

Link to comment
Share on other sites

Current version

Func _WinAPI_WideCharToMultiByte($vUnicode, $iCodePage = 0, $bRetString = True)

    ; some code
    
    Local $tMultiByte = DllStructCreate("byte[" & $aResult[0] & "]")

    ; some code

EndFunc   ;==>_WinAPI_WideCharToMultiByte

Must be changed to

Func _WinAPI_WideCharToMultiByte($vUnicode, $iCodePage = 0, $bRetString = True)

    ; some code
    
    Local $tMultiByte = DllStructCreate("char[" & $aResult[0] & "]")

    ; some code

EndFunc   ;==>_WinAPI_WideCharToMultiByte

because it returns Binary, not String as documented.

Link to comment
Share on other sites

  • Moderators

Hi,

Fixed here:

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

Also GDIPlus.au3 contains some unecessary string conversions in _GDIPlus_GetEncoders and _GDIPlus_GetDecoders. To correct it:

1. Remove #include "WinAPIConv.au3" from top of GDIPlus.au3. This is no longer needed.

2. Replace _GDIPlus_GetEncoders with the following:

Func _GDIPlus_Encoders()
    Local $iCount = _GDIPlus_EncodersGetCount()
    Local $iSize = _GDIPlus_EncodersGetSize()
    Local $tBuffer = DllStructCreate("byte[" & $iSize & "]")
    Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageEncoders", "uint", $iCount, "uint", $iSize, "struct*", $tBuffer)
    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] Then Return SetError(10, $aResult[0], 0)

    Local $pBuffer = DllStructGetPtr($tBuffer)
    Local $tCodec, $aInfo[$iCount + 1][14]
    $aInfo[0][0] = $iCount
    For $iI = 1 To $iCount
        $tCodec = DllStructCreate($tagGDIPIMAGECODECINFO, $pBuffer)
        $aInfo[$iI][1] = _WinAPI_StringFromGUID(DllStructGetPtr($tCodec, "CLSID"))
        $aInfo[$iI][2] = _WinAPI_StringFromGUID(DllStructGetPtr($tCodec, "FormatID"))
        $aInfo[$iI][3] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "CodecName")), 1 )
        $aInfo[$iI][4] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "DllName")), 1 )
        $aInfo[$iI][5] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "FormatDesc")), 1 )
        $aInfo[$iI][6] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "FileExt")), 1 )
        $aInfo[$iI][7] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "MimeType")), 1 )
        $aInfo[$iI][8] = DllStructGetData($tCodec, "Flags")
        $aInfo[$iI][9] = DllStructGetData($tCodec, "Version")
        $aInfo[$iI][10] = DllStructGetData($tCodec, "SigCount")
        $aInfo[$iI][11] = DllStructGetData($tCodec, "SigSize")
        $aInfo[$iI][12] = DllStructGetData($tCodec, "SigPattern")
        $aInfo[$iI][13] = DllStructGetData($tCodec, "SigMask")
        $pBuffer += DllStructGetSize($tCodec)
    Next
    Return $aInfo
EndFunc   ;==>_GDIPlus_Encoders

3. Replace _GDIPlus_GetDecoders:

Func _GDIPlus_Decoders()
    Local $iCount = _GDIPlus_DecodersGetCount()
    Local $iSize = _GDIPlus_DecodersGetSize()
    Local $tBuffer = DllStructCreate("byte[" & $iSize & "]")
    Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageDecoders", "uint", $iCount, "uint", $iSize, "struct*", $tBuffer)
    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] Then Return SetError(10, $aResult[0], 0)

    Local $pBuffer = DllStructGetPtr($tBuffer)
    Local $tCodec, $aInfo[$iCount + 1][14]
    $aInfo[0][0] = $iCount
    For $iI = 1 To $iCount
        $tCodec = DllStructCreate($tagGDIPIMAGECODECINFO, $pBuffer)
        $aInfo[$iI][1] = _WinAPI_StringFromGUID(DllStructGetPtr($tCodec, "CLSID"))
        $aInfo[$iI][2] = _WinAPI_StringFromGUID(DllStructGetPtr($tCodec, "FormatID"))
        $aInfo[$iI][3] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "CodecName")), 1 )
        $aInfo[$iI][4] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "DllName")), 1 )
        $aInfo[$iI][5] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "FormatDesc")), 1 )
        $aInfo[$iI][6] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "FileExt")), 1 )
        $aInfo[$iI][7] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "MimeType")), 1 )
        $aInfo[$iI][8] = DllStructGetData($tCodec, "Flags")
        $aInfo[$iI][9] = DllStructGetData($tCodec, "Version")
        $aInfo[$iI][10] = DllStructGetData($tCodec, "SigCount")
        $aInfo[$iI][11] = DllStructGetData($tCodec, "SigSize")
        $aInfo[$iI][12] = DllStructGetData($tCodec, "SigPattern")
        $aInfo[$iI][13] = DllStructGetData($tCodec, "SigMask")
        $pBuffer += DllStructGetSize($tCodec)
    Next
    Return $aInfo
EndFunc   ;==>_GDIPlus_Decoders

Full file attached.

GDIPlus.zip

Link to comment
Share on other sites

  • Moderators

Imp,

The place to bring that up is as a "Feature Request" in Trac - open a ticket if you feel it is worth doing and the Devs will consider it.

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

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

×
×
  • Create New...