Jump to content

Recommended Posts

Posted (edited)

Real nice function to handle exceptions. Using 3.3.8.1 I ran into some issues.

1) I have the option must declare on true and had some errors (variable used without being declared):

$aCursorInfo, $sScriptPath, $iScriptLine, $sErrDesc

2) Though I use 1.7 (with the /OAER parameter) I still get unexpected number of parameters. When starting without setting parameters I get uncompiled 3 parameters and compiled 1 parameter. Can't these cli parameters be removed from the cmdLine array after registering by for example_arraySearch/_arrayDelete? (The problem with removing items is that cmdLine is a constant...)

3) I also would suggest that _OnAutoItErrorRegister would be split in two (developer visible) functions:

a. _OnAutoItErrorRegister([$sFunction = "" [, $vParams = "" [, $defaultCrashReporter = -1 [, $sErrorMsgFormat = -1 [, $bUseStdOutMethod = True]]]]])

b. _OnAutoItErrorReporter("Title","Mail Addres","Mail Server","Mail Server Port"[,"SSL"])

This has two advances. The developer don't need to change the UDF file to configure the reporter and a custom function can be used together with the default reporter (For example, before starting the reporter the database can be closed or a temp directory be deleted).

4) _OnAutoItErrorUnRegister would be also nice

Edited by skin27
  • 4 weeks later...
Posted

  Quote

1) I have the option must declare on true and had some errors (variable used without being declared)

Will fix it.

  Quote

2) Though I use 1.7 (with the /OAER parameter) I still get unexpected number of parameters. When starting without setting parameters I get uncompiled 3 parameters and compiled 1 parameter. Can't these cli parameters be removed from the cmdLine array after registering by for example_arraySearch/_arrayDelete? (The problem with removing items is that cmdLine is a constant...)

I will try to remove the usage of command line for the second run detection.

  Quote

This has two advances. The developer don't need to change the UDF file to configure the reporter and a custom function can be used together with the default reporter (For example, before starting the reporter the database can be closed or a temp directory be deleted).

You can do this already, just set the $sFunction parameter to your function (see Example 2).

  Quote

4) _OnAutoItErrorUnRegister would be also nice

Will add it.

Thanks for the suggestions.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted (edited)

Update...

  Quote

[1.8]

+ Added _OnAutoItErrorUnRegister (see Example 1). Note: If you are using _OnAutoItErrorUnRegister when $bUseStdOutMethod = True, then standard AutoIt error message will not be displayed.

* Removed the usage of command line to detect second script run.

* More stability in detecting AutoIt error message (when $bUseStdOutMethod = False).

* Fixed issue when main script (or other UDF) uses Opt('MustDeclareVars', 1).

Edited by MrCreatoR

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 3 months later...
Posted (edited)

Hello!

Seems like a great UDF; I'm gonna test it tomorrow..

Just a question:

How does the UDF affect my script regarding performance and resources allocations? I read that the UDF will start two instances of the actual AutoIt process (program).

Does this mean that my script may run slower, or use more server resources? For example, my program currently use ~60% of CPU power and ~600 Mb RAM without UDF - will my script run slower, or use ~1.2 Gb RAM with the UDF?

Thanks,

Edited by Xibalba
  • 8 months later...
Posted (edited)

Thank you for this very useful udf!

but your udf have few problems and i also have a new idea about the second process.

first, i will start with your bugs:

Bugs:

Bug 1:

1) Use the code below:

#include <Array.au3>
#include <OnAutoItErrorRegister.au3>
_OnAutoItErrorRegister()


If $CmdLine[0] > 0 Then
    _ArrayDisplay($CmdLine,"the parameters")
Else
    MsgBox(0,"","no parameters")
EndIf

2) compile the script

3) run the exe file with this parameter for example:

"parm1 parm2 parm3"

the ( " ) is very important to write for the bug.

The result you will get:

ilg35u.jpg

This Should NOT be the result!

the result should be this:

2h5qoht.jpg

this is because string

parm1 parm2 parm3

is between the ( " ) signal.

i have fixed the bug by changing in lines 171 and 148 the line:

$sRunLine &= ' ' & $CmdLine[$i]

to

$sRunLine &= ' ' & '"' & $CmdLine[$i] & '"'

this solved the problem.

 

Suggestions:

1) It would be good if I could choose the name of the second process which is loaded with script.

for example i want that the name of the second process will be: "my script name - bug reporter.exe" and the first process will be "my script name.exe"

This way it looks much better!

Edited by Guest
  • 1 month later...
Posted

Seems it have conflict with my self-update function, the .exe process did't exit after run(), the will be two same name exe process when add OnAutoItErrorRegister....

Func _Self_Update($newfile,$oldfile)
    Local $newfile_time=Number(FileGetTime($newfile,0,1))
    Local $oldfile_time=Number(FileGetTime($oldfile,0,1))
    Local $newfile_ver=FileGetVersion($newfile)
    Local $oldfile_ver=FileGetVersion($oldfile)
    Local $newfile_cp=FileGetShortName($newfile)
    Local $oldfile_cp=FileGetShortName($oldfile)
    If FileExists($newfile) And $newfile_time > $oldfile_time Then
        Local $if_update = MsgBox(1,"Auto-Update", StringReplace($exe_file_name,".exe","") & @CRLF & @CRLF & "New version available, please click OK to update!" & @CRLF & _
        @CRLF & "Current version: " & @TAB & $oldfile_ver & _
        @CRLF & "New version:" & @TAB & $newfile_ver )
        If $if_update = 2 Then Return
            FileDelete(@TempDir & 'rst.bat')
            FileWrite(@TempDir & 'rst.bat', 'ping 127.0.0.1 >nul' & @CRLF _
                                & 'copy /y ' &$newfile_cp &' ' & $oldfile_cp & @CRLF _
                                & $oldfile_cp & @CRLF _
                                & 'echo by pcbar')
            Run(@TempDir & 'rst.bat', "", @SW_HIDE)
            Exit
    EndIf
EndFunc

  • 2 weeks later...
Posted

Does this work with autoit 3.3.10.0? If I run either of the examples.au3 files it works, however if I compile the example the script does nothing yet the example process .exe is still running and taskmanager shows cpu is doing something with that process.

I have a ton of compiled scripts I would love to package this with.

~GD

  • 1 month later...
Posted

I have not had time to try fixing the problem, but it looks like the defect is in this function.  If you place a msgbox in here it loops forever, so it looks like it cannot grab a proper value for WinGetProcess?

It looks like there are a lot of changes in this release, so I have not analysized all of them.  Also, it seems like scripts run fine if ran from the editor vs. compiled.

 

Func __OnAutoItErrorRegister_WinGetHandleByPID($iPID, $sTitle = '[CLASS:AutoIt v3]')
Local $aWinList = WinList($sTitle)
 
For $i = 1 To UBound($aWinList)-1
;Hidden and belong to process in $iPID
If Not BitAND(WinGetState($aWinList[$i][1]), 2) And WinGetProcess($aWinList[$i][1]) = $iPID Then
Return $aWinList[$i][1]
EndIf
Next
 
Return 0
EndFunc
  • 4 weeks later...
Posted

Hey!! Thanks for awesome job!!!! It is very useful for me

I've reworked it a bit for myself: 

in Func _OnAutoItErrorRegister I've made this ( line 204 )

If $sErrorMsg = "" Then
Exit
Else
Local $ErrorLogfile = @ScriptDir & "\Autoit_Error_Handlings.txt"
Local $file = FileOpen ($ErrorLogfile, 1)
FileWrite($File, StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC) & " " & $sErrorMsg & @CRLF & @CRLF)
EndIf

So for I am interested in this file as developer. Also we can e-mail this whole file to developer instead of only error description.

Cya :)

  • 3 months later...
Posted (edited)

I see many subVersions of the main UDF described here.

Can anyone point me for the correct one? (the less buggy)

Just wanna a way to retry app when suddently breaks (it does too much times, more than expected)
I read about TryCatch blocks on that forum but didn't solve my problems.

Thank you

Edited by erm3nda

~ SELF SIGNED ~

How much warning points do i need to get my free spicy hammon?

Posted

I'd try to add _OnAutoItErrorRegister() on my script and now is not working.

The au3 file is running without changes, and the OnAutoIt runs properly. 

The compiled one just starts and freezes with no tray. 

how can i break the compiled script just by add one more function on it's default way?
​I'm stucked just on the AutoIT error handling :(

Regards.

~ SELF SIGNED ~

How much warning points do i need to get my free spicy hammon?

  • 4 weeks later...
Posted (edited)

Seems nice uncompiled

I don't see why when you run my app, and it crashes, you need my email password to send me a debug report.

Trying to Build my app drives my anitvirus (AVG) crazy and I can no longer BUILD with #include "OnAutoItErrorRegister.au3"

 
I didn't even make any other modifications, just added the include.
 
Removed #include, and AVG still goin Nutz, hope a restart will fix it.
 
EDIT: Restart = Nope, Now i'm Screwed :)
Edited by LeCarre
  • 1 year later...
Posted

Update...

  Quote

v1.9
+ Added error line detection for compiled script (to display actual line which caused the error).
    Script must be executed before compilation (after any change in it), or use '#AutoIt3Wrapper_Run_Before=%autoitdir%\AutoIt3.exe "%in%" /BC_Strip' in your main script.
    !!! Do NOT use Au3Stripper when compiling the main script.
+ Added second function call detection (to prevent multiple recursive execution).
* Fixed command line issue.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

Update...

 

  Quote

v2.0
* UDF rewritten (used methods from AutoItErrorTrap UDF).
  - Syntax changed, check function header for details.
* Dropped AutoIt 3.3.8.1 support.
+ Added last window screen capture feature. File can be sent as attachment when using "Send Bug Report" feature.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 3 weeks later...
Posted (edited)

Thx, Mr Creator.

There's a little bug though... the "To" word has become a reserved word in AutoItv3 as of version 3.3.12.0 (https://www.autoitscript.com/trac/autoit/ticket/2768)
Think it will be a little challenge to fix this one as you're using the CDO.Message COM object directly. Don't know whether there are aliases of some kind to work around this issue.

Edit: Think you have to revise your CDO.Message function to use the Recipient property or Recipients collection object instead.

Edited by hvandrie
Posted

Just use AutoIt 3.3.14.2

 

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

  • 9 months later...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...