Jump to content

Recommended Posts

Posted

Did you check it ??

  On 11/5/2015 at 9:14 AM, mLipok said:

I would do this with @error not with IsObj.

func _qv_field_GetPossibleValues($qv_documentobject,$field,$numberofreturns=100)
    Local  $oMyError_local = ObjEvent("AutoIt.Error","MyErrFunc_SECOND")
    Local $oField = $qv_documentobject.Fields($field)
    If @error Then MsgBox($MB_ICONERROR, 'VarGetType($oField ) = ' & VarGetType($oField ) & @CRLF & 'VALUE = '& $oField , _
        '@error = ' & @error & @CRLF & '@extended = ' & @extended)
    
    $values = $oField.GetPossibleValues($numberofreturns)
    local $array[$values.count + 1]
    $array[0] = $values.count
    for $i = 0 to $values.count - 1
        $array[$i+1] = $values.Item($i).Text
    Next
    return $array
EndFunc

Func MyErrFunc_SECOND()
    $HexNumber=hex($oMyError.number,8)
    MsgBox(0,"COM Error","We intercepted a COM Error ! - SKIT OCKSA!!!!"       & @CRLF  & @CRLF & _
        "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
        "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
        "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
        "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
        "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
        "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
        "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
        "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
    )
    SetError(1)  ; to check for after this function returns
    Exit
EndFunc

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
  On 11/9/2015 at 2:43 PM, mLipok said:

Did you check it ??

 

Yes. Same result:
"C:\Users\xxxxxxxxxx\Documents\autoit\Qlikview_COM\qlikview_test_error.au3" (47) : ==> The requested action with this object has failed.:
$values = $qv_documentobject.Fields($field).GetPossibleValues($numberofreturns)
$values = $qv_documentobject.Fields($field)^ ERROR

However, if i use this it works (@error is 0 and @exended is also 0). But it works. 
 

func _qv_field_GetPossibleValues($qv_documentobject,$field,$numberofreturns=100)

    Local  $oMyError_local = ObjEvent("AutoIt.Error","MyErrFunc_SECOND")
    Local $oField = $qv_documentobject.Fields($field)
    If IsObj($oField) = 0 Then
        MsgBox(0, 'VarGetType($oField ) = ' & VarGetType($oField ) & @CRLF & 'VALUE = '& $oField , '@error = ' & @error & @CRLF & '@extended = ' & @extended)
        Exit
    EndIf
    $values = $qv_documentobject.Fields($field).GetPossibleValues($numberofreturns)
    local $array[$values.count + 1]
    $array[0] = $values.count
    for $i = 0 to $values.count - 1
        $array[$i+1] = $values.Item($i).Text
    Next
    return $array

EndFunc

This is a workaround that works ok, but i would still like to know why my COM error handler cant cacth the error...

many thanks for the tip for the workaround!

Edited by Tjalve
Posted (edited)

I would also to know. :)
I think the only one member/person who can answer is  @Jon , maybe @trancexx, as I think this is internal AutoIt behavior with handling COM Errors.

btw.
As I remember the case was disscused before few times.

 

Edited by mLipok
wording

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 11/10/2015 at 9:01 AM, mLipok said:

I would also to know. :)
I think the only one member/person who can answer is  @Jon , maybe @trancexx, as I think this is internal AutoIt behavior with handling COM Errors.

btw.
As I remember the case was disscused before few times.

 

You might me right. Well i hope they will check this thread then. Thank you again for your assistance :)

Posted

I try to find the other examples over the forum.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

Here is other example:

I think I can make repro. I must to play around with this example.

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

I think this is it:

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oTest = Null

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

ConsoleWrite('+ ========================' & @CRLF)
; check if COM ERROR HANLDER Works
$oTest = $oIE.FireError
ConsoleWrite('! Test1 = ' & @error & @CRLF)
ConsoleWrite('+ ========================' & @CRLF)

$oTest = $oIE.document.forms.item(0).GetElementsByTagName("table").item()
ConsoleWrite('! Test2a = ' & @error & @CRLF)
ConsoleWrite('! Test2b = ' & VarGetType($oTest) & @CRLF)
ConsoleWrite('! Test2c = ' & IsObj($oTest) & @CRLF)
$oTest = $oIE.document.forms.item(0).GetElementsByTagName("table").item(0).rows.item(2).cells.item(0).GetElementsByTagName("input").item(0)
ConsoleWrite($oTest.outerhtml & @CRLF)
ConsoleWrite('+ ========================' & @CRLF)

; there is only one table this should return empty object
$oTest = $oIE.document.forms.item(0).GetElementsByTagName("table").item(1)
ConsoleWrite('! Test3a = ' & @error & @CRLF)
ConsoleWrite('! Test3b = ' & VarGetType($oTest) & @CRLF)
ConsoleWrite('! Test3c = ' & IsObj($oTest) & @CRLF)
ConsoleWrite('+ ========================' & @CRLF)

; and this will fail
$oTest = $oIE.document.forms.item(0).GetElementsByTagName("table").item(1).rows.item(2).cells.item(0).GetElementsByTagName("input").item(0)
ConsoleWrite($oTest.outerhtml & @CRLF)
ConsoleWrite('+ ========================' & @CRLF)

; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

 


I think OP when use this function:

func _qv_field_GetPossibleValues($qv_documentobject,$field,$numberofreturns=100)
    $values = $qv_documentobject.Fields($field).GetPossibleValues($numberofreturns)
    local $array[$values.count + 1]
    $array[0] = $values.count
    for $i = 0 to $values.count - 1
        $array[$i+1] = $values.Item($i).Text
    Next
    return $array
EndFunc

 

for example like this: 

Local $Return = _qv_field_GetPossibleValues($qv_documentobject,'Some non existing field name',100)

then this going to fail, 

as 

$qv_documentobject.Fields('Some non existing field name')

probably also returns Empty Object, and because of that, this following line:

$qv_documentobject.Fields('Some non existing field name').GetPossibleValues(100)

should fires error.

 

But maybe I'm wrong ?
mLipok


These are my thoughts:
For now I'm thinking is it COM Error handling related or Error handling at all.
If this is not related to COM Error handling , but to general handling errors in AutoIt, this basically means that the OP just presented poorly written script, because did not handle errors that may arise. At the same time it will changes my habit on writing scripts in AutoIt with the use of ActiveX objects, as in this case, mine scripts are also poorly written ;)

 

 

 

Edited by mLipok
some script changes - for clarity

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

When you want to report a bug then place a focus on the thing that you suspect is wrong and remove all other unnecessary code.

; Initialize COM error handler
$oErrorHandler = ObjEvent("AutoIt.Error", _ErrFunc)
Func _ErrFunc($oError)
    ConsoleWrite("!ERROR caught, YAY!" & @CRLF)
EndFunc


; Create shell object
$oObj = ObjCreate("shell.application")

;The following line should trigger COM error handler (at the last dot). If you get unexpected termination then it's a bug introduced by Jon.
$oObj.Windows().Item(666).bzzzzzzz

 

♡♡♡

.

eMyvnE

Posted

The purpose of my script was to demonstrate what could happen in the OP script.

Any way.
Thanks for your advice, and confirmation.

mLipok

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 4 years later...
Posted

For all interested:

https://www.autoitscript.com/trac/autoit/ticket/3167

Thanks to @jpm bug is fixed, one thing which we need to do is waiting for @Jon approoval and releasing new version.
Do not ask when this will be done.

The short answer is:
When @Jon will have a spare time to work on this.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Does this happen when you try to access a nested property that isn't valid? I was trying to do something similar last week and it was driving me crazy.

Func Main()
    
    Local $oOL = _OL_Open()

    Global $oMail = _OL_CurrentItem($oOL)

    $oMail.Close()
    
EndFunc

Func _OL_CurrentItem($oOL)

    If Not IsObj($oOL) Then Return SetError(1, 0, False)

    Local $oErr = ObjEvent("AutoIt.Error", "_ErrFunc");(False)
    If @error Then Return SetError(2, @error, False)
    #forceref $oErr
    
    Local $oItem = $oOL.ActiveWindow.CurrentItem
    If @error Then Return SetError(3, @error, False)

    Return $oItem

EndFunc

Func _ErrFunc($oError)
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

This (should) get the currently active email in Outlook if it's open in a separate window (ie: you double click on the email). If there is no window open, however, the COM error isn't caught.

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

  Reveal hidden contents
Posted

Yes.

this is it.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
×
×
  • Create New...