LightningBit

"\Include\WinAPIGdi.au3" (2480) : ==> Variable must be of type "Object"

6 posts in this topic

#1 ·  Posted (edited)

Hi,

I've a script, using WinAPIGdi, checking info on font files

for some files, I get the error

"C:\DEV\AutoIt3\Include\WinAPIGdi.au3" (2480) : ==> Variable must be of type "Object".:

and then the script stops.

Is there a way I can either "catch" that error, and let my script continue with the next file

or improve something in the WinAPIGdi script?

 

I've searched the forums on error handling, but couldn't immediately find something related tho errors like these which are hardstopping the script

 

P.S. : I'm an AutoIT script newbie.....

 

snippet from WinAPIGdi, line 2480 from the error is this one:

 $sResult = $tResult.szTTFName

 

; #FUNCTION# ====================================================================================================================
; Author ........: funkey
; Modified ......: UEZ, jpm
; ===============================================================================================================================
Func _WinAPI_GetFontMemoryResourceInfo($pMemory, $iFlag = 1)
    Local Const $tagTT_OFFSET_TABLE = "USHORT uMajorVersion;USHORT uMinorVersion;USHORT uNumOfTables;USHORT uSearchRange;USHORT uEntrySelector;USHORT uRangeShift"
    Local Const $tagTT_TABLE_DIRECTORY = "char szTag[4];ULONG uCheckSum;ULONG uOffset;ULONG uLength"
    Local Const $tagTT_NAME_TABLE_HEADER = "USHORT uFSelector;USHORT uNRCount;USHORT uStorageOffset"
    Local Const $tagTT_NAME_RECORD = "USHORT uPlatformID;USHORT uEncodingID;USHORT uLanguageID;USHORT uNameID;USHORT uStringLength;USHORT uStringOffset"

    Local $tTTOffsetTable = DllStructCreate($tagTT_OFFSET_TABLE, $pMemory)
    Local $iNumOfTables = _WinAPI_SwapWord(DllStructGetData($tTTOffsetTable, "uNumOfTables"))

    ;check is this is a true type font and the version is 1.0
    If Not (_WinAPI_SwapWord(DllStructGetData($tTTOffsetTable, "uMajorVersion")) = 1 And _WinAPI_SwapWord(DllStructGetData($tTTOffsetTable, "uMinorVersion")) = 0) Then Return SetError(1, 0, "")

    Local $iTblDirSize = DllStructGetSize(DllStructCreate($tagTT_TABLE_DIRECTORY))
    Local $bFound = False, $iOffset, $tTblDir
    For $i = 0 To $iNumOfTables - 1
        $tTblDir = DllStructCreate($tagTT_TABLE_DIRECTORY, $pMemory + DllStructGetSize($tTTOffsetTable) + $i * $iTblDirSize)
        If StringLeft(DllStructGetData($tTblDir, "szTag"), 4) = "name" Then
            $bFound = True
            $iOffset = _WinAPI_SwapDWord(DllStructGetData($tTblDir, "uOffset"))
            ExitLoop
        EndIf
    Next

    If Not $bFound Then Return SetError(2, 0, "")

    Local $tNTHeader = DllStructCreate($tagTT_NAME_TABLE_HEADER, $pMemory + $iOffset)
    Local $iNTHeaderSize = DllStructGetSize($tNTHeader)
    Local $iNRCount = _WinAPI_SwapWord(DllStructGetData($tNTHeader, "uNRCount"))
    Local $iStorageOffset = _WinAPI_SwapWord(DllStructGetData($tNTHeader, "uStorageOffset"))

    Local $iTTRecordSize = DllStructGetSize(DllStructCreate($tagTT_NAME_RECORD))
    Local $tResult, $sResult, $iStringLength, $iStringOffset, $iEncodingID, $tTTRecord
    For $i = 0 To $iNRCount - 1
        $tTTRecord = DllStructCreate($tagTT_NAME_RECORD, $pMemory + $iOffset + $iNTHeaderSize + $i * $iTTRecordSize)

        If _WinAPI_SwapWord($tTTRecord.uNameID) = $iFlag Then ;1 says that this is font name. 0 for example determines copyright info
            $iStringLength = _WinAPI_SwapWord(DllStructGetData($tTTRecord, "uStringLength"))
            $iStringOffset = _WinAPI_SwapWord(DllStructGetData($tTTRecord, "uStringOffset"))
            $iEncodingID = _WinAPI_SwapWord(DllStructGetData($tTTRecord, "uEncodingID"))

            Local $sWchar = "char"
            If $iEncodingID = 1 Then
                $sWchar = "word"
                $iStringLength = $iStringLength / 2
            EndIf
            $tResult = DllStructCreate($sWchar & " szTTFName[" & $iStringLength & "]", $pMemory + $iOffset + $iStringOffset + $iStorageOffset)

            If $iEncodingID = 1 Then
                $sResult = ""
                For $j = 1 To $iStringLength
                    $sResult &= ChrW(_WinAPI_SwapWord(DllStructGetData($tResult, 1, $j)))
                Next
            Else
                $sResult = $tResult.szTTFName

            EndIf

            If StringLen($sResult) > 0 Then ExitLoop
        EndIf
    Next

    Return $sResult
EndFunc   ;==>_WinAPI_GetFontMemoryResourceInfo


 

the function in my script:

Func FontGetInfoFromFile($sFile, $n, $sElement)

    Local $s = _WinAPI_GetFontResourceInfo($sFile, Default, $n)
    If Not @error And $s Then ConsoleWrite($sElement & " = " & $s & @CRLF)
    If @error Then ConsoleWrite ("ERROR!!!")

EndFunc   ;==>FontGetInfoFromFile

 

and _WinAPI_GetFontResourceInfo uses _WinAPI_GetFontMemoryResourceInfo as you know

 

any help or hints are welcome

 

 

Babylon5.ttf

Bahamas.ttf

Edited by LightningBit
attached 2 example fonts which are giving the problem

Share this post


Link to post
Share on other sites



Can you provide the font file that I can reproduce the error please?

 

THX.


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi,

 

I attached 2 example fonts with the problem to my Original post

 

here is my "test" script"

 

#Include <Array.au3>
#Include <File.au3>
#Include <WinAPIEx.au3>
#include <GUIConstantsEx.au3>
#Include <FontConstants.au3>
#include <GDIPlus.au3>
#include <WinAPIGdi.au3>
#include <WinAPIMisc.au3>


Opt('MustDeclareVars', 1)

; Variable Declaration

Global $FileList = _FileListToArray("C:\DEV\TEST\FONTS\", '*.ttf', 1, True)
Global $FontList[UBound($FileList) - 1][2]
Global $sFile = ""
Global $sFont = ""

; Functions

Func FontGetInfoFromFile($sFile, $n, $sElement)
    Local $s = _WinAPI_GetFontResourceInfo($sFile, Default, $n)
    If Not @error And $s Then ConsoleWrite($sElement & " = " & $s & @CRLF)
    If @error Then ConsoleWrite ("ERROR!!!")
EndFunc   ;==>FontGetInfoFromFile

;Main Application

For $i = 1 To $FileList[0]
    $sFile = $FileList[$i]
    $sFont = _WinAPI_GetFontResourceInfo($sFile, 1)
    If Not $sFont Then
        Exit
    Else
        ConsoleWrite("Debug : Found a font!" & $sFile & @LF)
    EndIf
    ConsoleWrite("Debug : Getting the data .... " & @LF)
    FontGetInfoFromFile($sFile, 0, "Copyright")
    FontGetInfoFromFile($sFile, 1, "Font Family name")
    FontGetInfoFromFile($sFile, 2, "Font SubFamily name")
    FontGetInfoFromFile($sFile, 3, "Unique font identifier")
    FontGetInfoFromFile($sFile, 4, "Font full name")
    FontGetInfoFromFile($sFile, 5, "Version string")
    FontGetInfoFromFile($sFile, 6, "Postscript name")
    FontGetInfoFromFile($sFile, 7, "Trademark")
    FontGetInfoFromFile($sFile, 8, "Manufacturer Name")
    FontGetInfoFromFile($sFile, 9, "Designer")
    FontGetInfoFromFile($sFile, 10, "Description")
    FontGetInfoFromFile($sFile, 11, "URL Vendor")
    FontGetInfoFromFile($sFile, 16, "Preferred Family (Windows only)")
    FontGetInfoFromFile($sFile, 17, "Preferred SubFamily (Windows only)")
    FontGetInfoFromFile($sFile, 18, "Compatible Full (Mac OS only)")
    FontGetInfoFromFile($sFile, 19, "Sample text")
    FontGetInfoFromFile($sFile, 20, "PostScript CID findfont name")
    FontGetInfoFromFile($sFile, 256, "Font-specific names")
    ConsoleWrite("Debug : Done getting the data .... " & @LF & @CRLF)
    ConsoleWrite(_WinAPI_GetLastError & @LF)
Next

 

 

Edited by LightningBit

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

This is a problem with _WinAPI_GetFontMemoryResourceInfo function that is not handling errors which occurs when $iStringLength is 0.

Should be fixed in next release.

 

Thanks.

 

Workaround:

; #FUNCTION# ====================================================================================================================
; Author ........: funkey
; Modified ......: UEZ
; ===============================================================================================================================
Func _WinAPI_GetFontResourceInfo($sFont, $bForce = False, $iFlag = Default)
    If $iFlag = Default Then
        If $bForce Then
            If Not _WinAPI_AddFontResourceEx($sFont, $FR_NOT_ENUM) Then Return SetError(@error + 20, @extended, '')
        EndIf

        Local $iError = 0
        Local $aRet = DllCall('gdi32.dll', 'bool', 'GetFontResourceInfoW', 'wstr', $sFont, 'dword*', 4096, 'wstr', '', 'dword', 0x01)
        If @error Or Not $aRet[0] Then $iError = @error + 10

        If $bForce Then
            _WinAPI_RemoveFontResourceEx($sFont, $FR_NOT_ENUM)
        EndIf
        If $iError Then Return SetError($iError, 0, '')

        Return $aRet[3]
    Else
        If Not FileExists($sFont) Then
            $sFont = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Fonts") & "\" & $sFont
            If Not FileExists($sFont) Then Return SetError(31, 0, "")
        EndIf
        Local Const $hFile = _WinAPI_CreateFile($sFont, 2, 2, 2)
        If Not $hFile Then Return SetError(32, _WinAPI_GetLastError(), "")
        Local Const $iFile = FileGetSize($sFont)
        Local Const $tBuffer = DllStructCreate("byte[" & $iFile + 1 & "]")
        Local Const $pFile = DllStructGetPtr($tBuffer)
        Local $iRead
        _WinAPI_ReadFile($hFile, $pFile, $iFile, $iRead)
        _WinAPI_CloseHandle($hFile)
        Local $sTTFName = _WinAPI_GetFontMemoryResourceInfo($pFile, $iFlag)
        If @error Then
            If @error = 1 Then
                $sTTFName = _WinAPI_GetFontResourceInfo($sFont, True)
                Return SetError(@error, @extended, $sTTFName)
            EndIf
            Return SetError(33, @error, "")
        EndIf
        Return $sTTFName
    EndIf
EndFunc   ;==>_WinAPI_GetFontResourceInfo

; #FUNCTION# ====================================================================================================================
; Author ........: funkey
; Modified ......: UEZ, jpm
; ===============================================================================================================================
Func _WinAPI_GetFontMemoryResourceInfo($pMemory, $iFlag = 1)
    Local Const $tagTT_OFFSET_TABLE = "USHORT uMajorVersion;USHORT uMinorVersion;USHORT uNumOfTables;USHORT uSearchRange;USHORT uEntrySelector;USHORT uRangeShift"
    Local Const $tagTT_TABLE_DIRECTORY = "char szTag[4];ULONG uCheckSum;ULONG uOffset;ULONG uLength"
    Local Const $tagTT_NAME_TABLE_HEADER = "USHORT uFSelector;USHORT uNRCount;USHORT uStorageOffset"
    Local Const $tagTT_NAME_RECORD = "USHORT uPlatformID;USHORT uEncodingID;USHORT uLanguageID;USHORT uNameID;USHORT uStringLength;USHORT uStringOffset"

    Local $tTTOffsetTable = DllStructCreate($tagTT_OFFSET_TABLE, $pMemory)
    Local $iNumOfTables = _WinAPI_SwapWord(DllStructGetData($tTTOffsetTable, "uNumOfTables"))

    ;check is this is a true type font and the version is 1.0
    If Not (_WinAPI_SwapWord(DllStructGetData($tTTOffsetTable, "uMajorVersion")) = 1 And _
            _WinAPI_SwapWord(DllStructGetData($tTTOffsetTable, "uMinorVersion")) = 0) Then Return SetError(1, 0, "")

    Local $iTblDirSize = DllStructGetSize(DllStructCreate($tagTT_TABLE_DIRECTORY))
    Local $bFound = False, $iOffset, $tTblDir
    For $i = 0 To $iNumOfTables - 1
        $tTblDir = DllStructCreate($tagTT_TABLE_DIRECTORY, $pMemory + DllStructGetSize($tTTOffsetTable) + $i * $iTblDirSize)
        If StringLeft(DllStructGetData($tTblDir, "szTag"), 4) = "name" Then
            $bFound = True
            $iOffset = _WinAPI_SwapDWord(DllStructGetData($tTblDir, "uOffset"))
            ExitLoop
        EndIf
    Next

    If Not $bFound Then Return SetError(2, 0, "")

    Local $tNTHeader = DllStructCreate($tagTT_NAME_TABLE_HEADER, $pMemory + $iOffset)
    Local $iNTHeaderSize = DllStructGetSize($tNTHeader)
    Local $iNRCount = _WinAPI_SwapWord(DllStructGetData($tNTHeader, "uNRCount"))
    Local $iStorageOffset = _WinAPI_SwapWord(DllStructGetData($tNTHeader, "uStorageOffset"))

    Local $iTTRecordSize = DllStructGetSize(DllStructCreate($tagTT_NAME_RECORD))
    Local $tResult, $sResult, $iStringLength = 0, $iStringOffset, $iEncodingID, $tTTRecord, $iError = 0
    For $i = 0 To $iNRCount - 1
        $tTTRecord = DllStructCreate($tagTT_NAME_RECORD, $pMemory + $iOffset + $iNTHeaderSize + $i * $iTTRecordSize)
        If @error Then ContinueLoop

        If _WinAPI_SwapWord($tTTRecord.uNameID) = $iFlag Then ;1 says that this is font name. 0 for example determines copyright info
            $iStringLength = _WinAPI_SwapWord(DllStructGetData($tTTRecord, "uStringLength"))
            $iStringOffset = _WinAPI_SwapWord(DllStructGetData($tTTRecord, "uStringOffset"))
            $iEncodingID = _WinAPI_SwapWord(DllStructGetData($tTTRecord, "uEncodingID"))

            Local $sWchar = "char"
            If $iEncodingID = 1 Then
                $sWchar = "word"
                $iStringLength /= 2
            EndIf
            If Not $iStringLength Then
                $sResult = ""
                ContinueLoop
            EndIf

            $tResult = DllStructCreate($sWchar & " szTTFName[" & $iStringLength & "]", $pMemory + $iOffset + $iStringOffset + $iStorageOffset)

            If $iEncodingID = 1 Then
                $sResult = ""
                For $j = 1 To $iStringLength
                    $sResult &= ChrW(_WinAPI_SwapWord(DllStructGetData($tResult, 1, $j)))
                Next
            Else
                $sResult = $tResult.szTTFName
            EndIf

            If StringLen($sResult) > 0 Then ExitLoop
        EndIf
    Next
    Return $sResult
EndFunc   ;==>_WinAPI_GetFontMemoryResourceInfo

 

Edited by UEZ
Added workaround

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Hi,

Thanks for looking into it

the error is gone, but is it possible that it now exits the script completely (without error) when it comes across a font with an issue?

when I ran the script, it just stopped after 24 fonts (here are over 4000 in the folder)

I'll try to get more data the next few days

 

--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
 Testing total number of fonts : 4799
Debug : Found a font!C:\DEV\TEST\FONTS\AbductionIV.ttf
Debug : Getting the data .... 1
Font Family name = Abduction IV
Font SubFamily name = Regular
Debug : Done getting the data .... 

Debug : Found a font!C:\DEV\TEST\FONTS\Abe Regular.ttf
Debug : Getting the data .... 2
Font Family name = Abe
Font SubFamily name = Regular
Debug : Done getting the data .... 

+>23:22:38 AutoIt3.exe ended.rc:0
+>23:22:38 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 2.065

 

Olivier

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I found the problem

 

I had this piece of code in my script

 

$sFont = _WinAPI_GetFontResourceInfo($sFile, 1)
If Not $sFont Then
  Exit
 Else
  ConsoleWrite("Debug : Found a good font!" & $sFile & @LF)
 EndIf

 

this caused the script to exit with some fonts, although the font itself seemed fine

I took it out and even the fonts on which the script did the exit, can be processed ok, so case closed for now I guess

 

The complete testscript:

#Include <Array.au3>
#Include <File.au3>
#Include <WinAPIEx.au3>
#include <GUIConstantsEx.au3>
#Include <FontConstants.au3>
#include <GDIPlus.au3>
#include <WinAPIGdi.au3>
#include <WinAPIMisc.au3>


Opt('MustDeclareVars', 1)

; Variable Declaration



Global $FileList = _FileListToArray("C:\DEV\TEST\FONTS\", '*.ttf', 1, True)
Global $FontList[UBound($FileList) - 1][2]
Global $sFile = ""
Global $sFont = ""

; Functions



Func FontGetInfoFromFile($sFile, $n, $sElement)
    Local $s = _WinAPI_GetFontResourceInfo($sFile, Default, $n)
    If Not @error And $s Then ConsoleWrite($sElement & " = " & $s & @CRLF)
    If @error Then ConsoleWrite ("ERROR!!!")
EndFunc   ;==>FontGetInfoFromFile



;Main Application

ConsoleWrite(" Testing filelist : " & UBound($FileList) & @LF)

For $i = 1 To $FileList[0]
    $sFile = $FileList[$i]
    $sFont = _WinAPI_GetFontResourceInfo($sFile, 1)
    If Not $sFont Then
        Exit
    Else
        ConsoleWrite("Debug : Found a good font!" & $sFile & @LF)
    EndIf

    ConsoleWrite("Debug : Getting the data .... " & $i & @LF)
    FontGetInfoFromFile($sFile, 0, "Copyright")
    FontGetInfoFromFile($sFile, 1, "Font Family name")
    FontGetInfoFromFile($sFile, 2, "Font SubFamily name")
    FontGetInfoFromFile($sFile, 3, "Unique font identifier")
    FontGetInfoFromFile($sFile, 4, "Font full name")
    FontGetInfoFromFile($sFile, 5, "Version string")
    FontGetInfoFromFile($sFile, 6, "Postscript name")
    FontGetInfoFromFile($sFile, 7, "Trademark")
    FontGetInfoFromFile($sFile, 8, "Manufacturer Name")
    FontGetInfoFromFile($sFile, 9, "Designer")
    FontGetInfoFromFile($sFile, 10, "Description")
    FontGetInfoFromFile($sFile, 11, "URL Vendor")
    FontGetInfoFromFile($sFile, 16, "Preferred Family (Windows only)")
    FontGetInfoFromFile($sFile, 17, "Preferred SubFamily (Windows only)")
    FontGetInfoFromFile($sFile, 18, "Compatible Full (Mac OS only)")
    FontGetInfoFromFile($sFile, 19, "Sample text")
    FontGetInfoFromFile($sFile, 20, "PostScript CID findfont name")
    FontGetInfoFromFile($sFile, 256, "Font-specific names")
    ConsoleWrite("Debug : Done getting the data .... " & @LF & @CRLF)
    ConsoleWrite(_WinAPI_GetLastError & @LF)
Next

 

Edited by LightningBit

Share this post


Link to post
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

  • Similar Content

    • tremolux66
      By tremolux66
      I use a monospace font for editing AutoIt scripts in SciTE (currently, CourierNew 9pt). Regardless of what font size I set in the configuration, when I start SciTE to resume editing the script text is one size smaller than I specified. When I type Ctrl+<numpad-slash> the text changes to the desired size. The same is true of the output pane, and I have to reset the size for both areas every time I start SciTE.
      IIRC, I've made few other changes to the configuration (e.g., changed the search highlight color and disabled Tidy), so this behavior seems odd. About SciTE says it's version 3.6.0 (Aug. 4, 2015).
      Any idea how to fix this?
    • Simpel
      By Simpel
      Hi,
      since some days I become this error message exiting my app:

      Eventviewer shows following data:
      Name der fehlerhaften Anwendung: autoit3.exe, Version: 3.3.14.2, Zeitstempel: 0x55fc1979 Name des fehlerhaften Moduls: ntdll.dll, Version: 6.1.7601.23864, Zeitstempel: 0x595fa490 Ausnahmecode: 0xc000000d Fehleroffset: 0x000987e0 I stripped my code from 1500 lines down to 70:
      #include <GUIConstants.au3> Global $g_sPathToPDF = ; path to some pdf file to show Opt("GUIOnEventMode", 1) ; default ist 0 ; 1 bedeutet, daß bei Klick direkt die darunterbeschriebene Funktion ausgeführt wird Global $g_hGUI_MAIN ; Haupt-GUI Global $g_hDummy_Main ; Dummy um Fokus in der Haupt-GUI unsichtbar zu setzen Global $g_hGUI_Pruefen ; GUI zum Prüfen aller PDF Global $g_hGUI_PDF ; GUI PDF-Ansicht der ausgewählten PDF Global $g_hPDF ; ActiveX control welches das PDF enthält Global $g_oAcrobatReader ; AcrobatReaderObjekt in dem die PDF gezeigt werden _GUI_Main() GUISetOnEvent ($GUI_EVENT_CLOSE, "_Exit_Main" , $g_hGUI_MAIN) While 1 Sleep(1) WEnd Exit Func _GUI_Main() ; GUI-MAIN $g_hGUI_MAIN = GUICreate("MAIN", 390, 390, 763, 372) GUISetFont(12) GUICtrlCreateButton("NEXT", 20, 20, 350, 55, $BS_DEFPUSHBUTTON) ; Default-Knopf GUICtrlSetOnEvent(-1, "_GUI_Pruefen") GUISetState(@SW_SHOW, $g_hGUI_MAIN) ; GUI anzeigen EndFunc Func _GUI_Pruefen() ; GUI zum Prüfen der PDF GUISetState(@SW_HIDE, $g_hGUI_MAIN) ; MAIN-GUI ausblenden Opt("GUIOnEventMode", 0) ; wieder auf Default gesetzt $g_hGUI_Pruefen = GUICreate("RIGHT", 490,950, 1057, 91, -1, $WS_EX_APPWINDOW, $g_hGUI_MAIN) _AcrobatShow($g_sPathToPDF, "", 367, 91, 674, 950, $g_hGUI_Pruefen) ; PDF-GUI erstellen GUISetState(@SW_SHOW, $g_hGUI_Pruefen) ; GUI-Prüfen anzeigen Local $msg While 1 $msg = GuiGetMsg() ; Aktion mit der GUI registrieren Switch $msg ; je nach Aktion mit der GUI Case $GUI_EVENT_CLOSE ; X gedrückt $g_oAcrobatReader = "" ; zerstöre das Objekt AcrobatReader GUIDelete($g_hGUI_PDF) ; lösche die GUI-PDF GUIDelete($g_hGUI_Pruefen) ; lösche die GUI-Prüfen Opt("GUIOnEventMode", 1) ; Default 0 GUISetState(@SW_SHOW, $g_hGUI_MAIN) ; MAIN-GUI wieder zeigen Return EndSwitch WEnd EndFunc Func _Exit_Main() ; ausführen, wenn die MAIN-GUI schließt ConsoleWrite("EXIT" & @CRLF) Exit EndFunc Func _AcrobatShow($sFile, $sTitle = "PDF ", $iLeft = 50, $iTop = 0, $iWidth = 1000, $iHeight = 700, $hWnd = "") ; GUI-PDF erstellen If FileExists($sFile) Then ; wenn das PDF existiert $g_oAcrobatReader = ObjCreate("AcroPDF.PDF.1") $g_oAcrobatReader.src = $sFile ; Quelle ist das File $g_oAcrobatReader.SetLayoutMode("SinglePage") ; default "SinglePage" $g_oAcrobatReader.SetPageMode("none") ; default "none" $g_oAcrobatReader.SetShowToolbar(0) ; Tool-Bar nicht zeigen 0 $g_oAcrobatReader.SetShowScrollbars(0) ; Scroll-Balken nicht zeigen 0 $g_oAcrobatReader.SetView("fit") ; "fit" falls wer eigene Einstellungen im Reader gespeichert hat $g_hGUI_PDF = GUICreate($sTitle, $iWidth, $iHeight, $iLeft, $iTop, -1, -1, $hWnd) ; GUI als Child zu GUI-PRUEFEN erstellen - es soll nicht aktiviert werden $g_hPDF = GUICtrlCreateObj($g_oAcrobatReader, 0, 0, $iWidth, $iHeight) ; Objekt für das PDF erstellen GUICtrlSetStyle($g_hPDF, $WS_VISIBLE) ; PDF anzeigen GUISetState(@SW_SHOW, $g_hGUI_PDF) ; GUI-PDF anzeigen Else MsgBox(0, 'ERROR', "No PDF found.") EndIf EndFunc Do following steps to prove:
      - start app
      - click "next" on main gui
      - wait minimum 5 seconds (until the arrows left and right on "gui left" disappear)
      - close gui left or right
      - close main gui
      - look on console written "EXIT" the last code line before exit
      - now windows error message above appears
      The funny thing is if I don't wait the 5 seconds (before the half transparent arrows disappear) closing the gui then I will get no win error message.
      If I comment _AcrobatShow() out then the error never appears. So it seemed to be an acrobat reader issue. Every week at work there are a lot of updates, but there is no chance to know which one. But since one update this error happens.
      Any solutions? Regards, Conrad
    • genius257
      By genius257
      I've made a library, based on AutoItObject UDF with the goal of implementing getter and setter functionality and make it possible to define new object properties in as few steps as possible.
      Thank you to @trancexx for getting me on the right track, and all users in Hooking into the IDispatch interface for the code to get me going.
      If I've forgotten to add credit, please let me know
      Example:
      #include "AutoItObject_Internal.au3" $myCar = IDispatch() $myCar.make = 'Ford' $myCar.model = 'Mustang' $myCar.year = 1969 $myCar.__defineGetter('DisplayCar', DisplayCar) Func DisplayCar($oThis) Return 'A Beautiful ' & $oThis.parent.year & ' ' & $oThis.parent.make & ' ' & $oThis.parent.model EndFunc MsgBox(0, "", $myCar.DisplayCar) More examples: https://github.com/genius257/AutoIt-projects/tree/master/AutoItObject Internal/Examples
      Version: 1.0.3
      AutoItObject_Internal.au3
      Documentation:
       

      Edit2 (19th March 2017):
      First of all, sorry about the lack of updates on this project. I always start too many projects and end up ignoring old projects, if I run into problems ^^'.
      So I've started moving my AutoIt scripts to GitHub. I will still post the most recent script version here.
    • argumentum
      By argumentum
      UDF to intercept the error window of AutoIt, showing more details about the error, including ability to save and send by email!
    • SkysLastChance
      By SkysLastChance
      I get this error, Whenever I try to find a date. Does anyone have any idea why? I saw some post from 2015, However I would imagine this is fixed by now. @water
      >"J:\Temporary Files\XXXXXXXXX\AutoIt\AutoIt\AutoIt\SciTe\..\autoit3.exe" /ErrorStdOut "C:\Users\XXXXXX\Desktop\Call Report Automation.au3"     "J:\Temporary Files\XXXXXXXX\AutoIt\AutoIt\AutoIt\Include\Excel.au3" (656) : ==> The requested action with this object has failed.: $aResult[$iIndex][1] = $oMatch.Name.Name $aResult[$iIndex][1] = $oMatch^ ERROR >Exit code: 1    Time: 5.791 #include <Excel.au3> Global $sExcelFile1 = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "(*.xlsm)") Global $sExcelFile2 = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "Excel Sheet (*.xlsx;*.xls)|All (*.*)") If FileExists($sExcelFile2) Then Global $oExcel2 = _Excel_Open () $oExcel2 = _Excel_BookOpen($oExcel2,$sExcelFile2) EndIF If FileExists($sExcelFile1) Then Global $oExcel1 = _Excel_Open () $oExcel1 = _Excel_BookOpen($oExcel1,$sExcelFile1,Default,Default,"2007") EndIF $oRead = _Excel_RangeRead ($oExcel2,Default,"A2",3) _Excel_RangeWrite ($oExcel1,"Calls Handled",$oRead,"BY7") Sleep (1000) _Excel_RangeFind ($oExcel1,$oRead,"E4:FD92") MsgBox (0,"Test",$oRead) UPDATE:
      If I take out this line it works. By works I mean I don't get the error. :/  However, I need it. I am just confused.
      _Excel_RangeWrite ($oExcel1,"Calls Handled",$oRead,"BY7")  
      UPDATE 2: I also get this error when trying to use the helpfile examples. I have version 3.3.14.2
      \AutoIt\AutoIt\AutoIt\Include\Excel.au3" (670) : ==> The requested action with this object has failed.: $oSheet = $oWorkbook.Sheets($iIndexSheets) $oSheet = $oWorkbook^ ERROR >Exit code: 1 Time: 0.8931