Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

OnAutoItErrorRegister - Handle AutoIt critical errors


  • Please log in to reply
34 replies to this topic

#21 JScript

JScript

    I'm back ... I miss, why not!

  • Active Members
  • PipPipPipPipPipPip
  • 1,218 posts

Posted 15 September 2012 - 01:51 PM

The program is open twice because is the only way to detect the error!

JS
http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)
Spoiler

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!       








#22 skin27

skin27

    Wayfarer

  • Active Members
  • Pip
  • 62 posts

Posted 20 September 2012 - 07:43 AM

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, 20 September 2012 - 10:11 AM.


#23 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 18 October 2012 - 01:39 PM

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

Will fix it.

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.

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).

4) _OnAutoItErrorUnRegister would be also nice

Will add it.

Thanks for the suggestions.
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#24 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 18 October 2012 - 02:36 PM

Update...

[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, 18 October 2012 - 02:43 PM.

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#25 skin27

skin27

    Wayfarer

  • Active Members
  • Pip
  • 62 posts

Posted 18 October 2012 - 07:36 PM

Thnx for the update, very much appreciated

#26 Xibalba

Xibalba

    Wayfarer

  • Active Members
  • Pip
  • 74 posts

Posted 14 February 2013 - 03:56 PM

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, 15 February 2013 - 11:11 PM.


#27 gil900

gil900

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 749 posts

Posted 01 November 2013 - 11:04 PM

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 gil900, 23 November 2013 - 01:20 PM.

Please correct my English in this post. I want to learn how to write correctly in English


#28 saget

saget

    Seeker

  • Active Members
  • 10 posts

Posted 18 December 2013 - 07:40 AM

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



#29 GoogleDude

GoogleDude

    Polymath

  • Active Members
  • PipPipPipPip
  • 216 posts

Posted 27 December 2013 - 10:27 AM

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



#30 GoogleDude

GoogleDude

    Polymath

  • Active Members
  • PipPipPipPip
  • 216 posts

Posted 28 December 2013 - 09:49 PM

Does anyone recommend a good Error Handler that works with AutoIt 3.3.10?



#31 duijver

duijver

    Seeker

  • Normal Members
  • 7 posts

Posted 22 February 2014 - 04:32 PM

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


#32 Spaces

Spaces

    Seeker

  • Normal Members
  • 2 posts

Posted 21 March 2014 - 02:50 PM

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 :)



#33 erm3nda

erm3nda

    Seeker

  • Active Members
  • 19 posts

Posted 22 June 2014 - 03:16 PM

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, 22 June 2014 - 04:30 PM.

~ SELF SIGNED ~

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


#34 erm3nda

erm3nda

    Seeker

  • Active Members
  • 19 posts

Posted 22 June 2014 - 04:35 PM

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?


#35 LeCarre

LeCarre

    Seeker

  • Active Members
  • 23 posts

Posted 18 July 2014 - 06:56 PM

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, 18 July 2014 - 07:08 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users