Jump to content

AutoIt Error Handler and Debugger


jennico
 Share

Recommended Posts

Finally - No more ugly Error Messages while running scripts !

Posted Image

(This Picture is just the model for the UDF, taken from MadExcept)

Features:

- traps any error from your scripts into a customizable GUI

- works with .au3 and .exe

- if script is not compiled, you will get the option to debug the error line instantly

- written as a UDF, so you only need to #include <_ErrorHandler.au3> in your script

- helps writing a script by highlighting the error (currently only works with SciTe) and restarting it right away (saves some windows on the desktop)

- if you publish a buggy script, the error message is more professional, without ugly sound and offers the user the option to send you an automatized email (optional, has to be completed)

Script: _ErrorHandler.au3 (the UDF)

;#=#INDEX#==================================================================#
;#  Title .........: _Error Handler.au3                                     #
;#  Description....: AutoIt3 Error Handler & Debugger                       #
;#  Date ..........: 7.9.08                                                 #
;#  Authors .......: jennico (jennicoattminusonlinedotde)                   #
;#                   @MrCreatoR                                             #
;#                   MadExcept (GUI inspiration by mrRevoked)               # 
;#==========================================================================#

#include-once

_OnAutoItError()

;#=#Function#===============================================================#
;#  Title .........: _OnAutoItError()                                       #
;#  Description....: AutoIt3 Error Handler & Debugger GUI                   #
;#  Parameters.....: (None)                                                 #
;#  Date ..........: 7.9.08                                                 #
;#  Authors .......: jennico (jennicoattminusonlinedotde)                   #
;#                   @MrCreatoR                                             #
;#==========================================================================#

;   this function is made to be customized !

Func _OnAutoItError()
    If StringInStr($CmdLineRaw,"/AutoIt3ExecuteScript") Then Return
    Opt("TrayIconHide",1)
    ;   run a second instance
    $iPID=Run(@AutoItExe&' /ErrorStdOut /AutoIt3ExecuteScript "'&@ScriptFullPath&'"',@ScriptDir,0,6)
    ProcessWait($iPID)
    $sErrorMsg=""
    ;   trap the error message
    While 1
        $sErrorMsg&=StdoutRead($iPID)
        If @error Then ExitLoop
        Sleep(1)
    WEnd
    If $sErrorMsg="" Then Exit
    GUICreate(@ScriptName,385,90,Default,Default,-2134376448);BitOR($WS_CAPTION,$WS_POPUP,$WS_SYSMENU)
    GUISetBkColor(0xE0DFE2)
        GUICtrlSetBkColor(GUICtrlCreateLabel("",1,1,383,1),0x41689E)
        GUICtrlSetBkColor(GUICtrlCreateLabel("",1,88,383,1),0x41689E)
        GUICtrlSetBkColor(GUICtrlCreateLabel("",1,1,1,88),0x41689E)
        GUICtrlSetBkColor(GUICtrlCreateLabel("",383,1,1,88),0x41689E)
        GUICtrlCreateIcon("user32.dll",103,11,11,32,32)
        GUICtrlSetBkColor(GUICtrlCreateLabel("An error occurred in the application.",52,21,175,15),-2)
        GUICtrlSetBkColor(GUICtrlCreateLabel("",10,60,110,22),0x706E63)
            GUICtrlSetState(-1,128)
        $send=GUICtrlCreateLabel("   send bug report",28,64,92,15)
            GUICtrlSetBkColor(-1,-2)
            GUICtrlSetColor(-1,0xFFFFFF)
            GUICtrlSetCursor(-1,0)
        $sen=GUICtrlCreateIcon("explorer.exe",254,13,63,16,16)
            GUICtrlSetCursor(-1,0)
        GUICtrlSetBkColor(GUICtrlCreateLabel("",124,60,114,22),0xEFEEF2)
            GUICtrlSetState(-1,128)
        $show=GUICtrlCreateLabel("   show bug report",143,64,95,15)
            If @Compiled=0 Then GUICtrlSetData(-1,"    De-Bug Script")
            GUICtrlSetBkColor(-1,-2)
            GUICtrlSetCursor(-1,0)
        $sho=GUICtrlCreateIcon("shell32.dll",23,127,63,16,16)
            If @Compiled=0 Then GUICtrlSetImage(-1,"shell32.dll",-81)
            GUICtrlSetCursor(-1,0)
        GUICtrlSetBkColor(GUICtrlCreateLabel("",246,8,131,22),0xEFEEF2)
            GUICtrlSetState(-1,128)
        $cont=GUICtrlCreateLabel("   continue application",265,12,115,15)
            GUICtrlSetBkColor(-1,-2)
            GUICtrlSetCursor(-1,0)
        $con=GUICtrlCreateIcon("shell32.dll",290,249,11,16,16)
            GUICtrlSetCursor(-1,0)
        GUICtrlSetBkColor(GUICtrlCreateLabel("",246,34,131,22),0xEFEEF2)
            GUICtrlSetState(-1,128)
        $rest=GUICtrlCreateLabel("    restart application",265,38,115,15)
            GUICtrlSetBkColor(-1,-2)
            GUICtrlSetCursor(-1,0)
        $res=GUICtrlCreateIcon("shell32.dll",255,249,37,16,16)
            GUICtrlSetCursor(-1,0)
        GUICtrlSetBkColor(GUICtrlCreateLabel("",246,60,131,22),0xEFEEF2)
            GUICtrlSetState(-1,128)
        $close=GUICtrlCreateLabel("     close application",265,64,115,15)
            GUICtrlSetBkColor(-1,-2)
            GUICtrlSetCursor(-1,0)
        $clos=GUICtrlCreateIcon("shell32.dll",240,249,63,16,16)
            GUICtrlSetCursor(-1,0)
    GUISetState()
    WinSetOnTop(@ScriptName,"",1)
    SoundPlay(@WindowsDir&"\Media\chord.wav")
    Opt("TrayIconHide",0)
    Opt("TrayAutoPause",0)
    TraySetToolTip("AutoIt Error Handler and Debugger")
    ;   choose action to be taken
    Do
        $msg=GUIGetMsg()
        If $msg=$cont Or $msg=$con Then MsgBox(270400,"Continue Application", _
            "I am afraid, not possible with AutoIt !     "&@CRLF&@CRLF& _
            "( No GoTo command )      :-( ")
        If $msg=$send Or $msg=$sen Then MsgBox(270400,"Send Bug Report","Email successfully sent !     ")
            ;#include <INet.au3>    ;   use email
            ;_INetSmtpMail ( $s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress [,$s_Subject&_
            ;[,$as_Body [,$s_helo, [,$s_first [,$b_trace]]]]])
        If $msg=$show Or $msg=$sho Then
            If @Compiled=0 Then __Debug($sErrorMsg)
            If @Compiled Then MsgBox(270400,"Show Bug Report",$sErrorMsg&"    ")
        EndIf
    Until $msg=-3 Or $msg=$close Or $msg=$clos Or $msg=$rest Or $msg=$res
    If $msg=$rest Or $msg=$res Then Run(@AutoItExe&' "'&@ScriptFullPath&'"',@ScriptDir,0,6)
    Exit
EndFunc

;#=#Function#===============================================================#
;#  Title .........: __Debug ( $txt )                                       #
;#  Description....: Debug Function for _ErrorHandler.au3                   #
;#  Parameters.....: $txt = Error Message Text from StdoutRead              #
;#  Date ..........: 7.9.08                                                 #
;#  Authors .......: jennico (jennicoattminusonlinedotde)                   #
;#                   @MrCreatoR                                             #
;#==========================================================================#

Func __Debug($txt)
    WinSetState(@ScriptName,"",@SW_HIDE)
    $a=StringSplit($txt,@CRLF,1)
    $scitePath=RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\SciTE.exe","")
    Dim $b=StringSplit($a[1],") : ==> ",1),$number=StringMid($b[1],StringInStr($b[1],"(")+1)
    Dim $code="Error Code: "&@TAB&StringTrimRight($b[2],2),$line="Line: "&@TAB&$number&" => "&$a[3]
    Dim $file="File: "&@TAB&StringReplace($b[1]," ("&$number,""),$count=StringLen($code),$height=180
    If StringLen($file)>$count Then $count=StringLen($file)
    If StringLen($line)>$count Then $count=StringLen($line)
    If StringLen($a[2])>$count Then $count=StringLen($a[2])
    If $count*6>@DesktopWidth-50 Then Dim $count=(@DesktopWidth-50)/6,$height=240
    $pid=Run($scitePath&' "'&@ScriptFullPath&'" /goto:'&$number&","&StringLen($a[2])-1)
    $x=InputBox(" Please Correct this line:",$code&@CRLF&@CRLF&$file&@CRLF&@CRLF& _
        $line,StringTrimRight($a[2],1),"",$count*6,$height)
    WinSetState(@ScriptName,"",@SW_SHOW)
    If $x="" Or $x=StringTrimRight($a[2],1) Then Return
    $t=StringSplit(FileRead(@ScriptFullPath),@CRLF,1)
    $t[$number]=StringReplace($t[$number],StringTrimRight($a[2],1),$x)
    $open=FileOpen(@ScriptFullPath,2)
    For $i=1 to $t[0]
        FileWriteLine($open,$t[$i])
    Next
    FileClose($open)
    ControlSend(@ScriptDir,"","ToolbarWindow32","^R")
EndFuncoÝ÷ ØLZ^IÊâ¦Ñ+®Çjwez±1jjey«·jëh×6;#=#INDEX#==================================================================#
;#  Title .........: AutoIt3 Error Handler & Debugger Example Script        #
;#  Date ..........: 7.9.08                                                 #
;#  Author ........: jennico (jennicoattminusonlinedotde)                   #
;#==========================================================================#

#include <_ErrorHandler.au3>    ;   this is all you need !

GUICreate(" AutoIt Error Handler Example Script  ©  2008 by jennico")
    GUICtrlCreateLabel("This script is just an example."&@CRLF&@CRLF& _
        "It will produce a syntax error in",25,25,300,50)
    $label=GUICtrlCreateLabel("20",25,85,50,40)
        GUICtrlSetColor(-1,0xF20000)
        GUICtrlSetFont(-1,30,1000)
    GUICtrlCreateLabel("seconds"&@CRLF&@CRLF& _
        "and result in an INDIVIDUAL error message.",25,150,300,50)
    GUICtrlCreateLabel("If this script is not compiled, you will find a debug option." _
        ,25,220,300,40)
    GUICtrlCreateLabel("I hope you find it useful !"&@CRLF&@CRLF&"j.",25,260,300,80)
GUISetState()

For $i=19 To 0 Step -1
    Sleep(1000)
    GUICtrlSetData($label,$i)
Next

MsgBox(0,"",    ; this is meant to produce an error !

Do
    $msg=GUIGetMsg()
Until $msg=-3

this thread is a continuation of this one.

thanks to @MrCreatoR !

have fun

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

if you copy the obove scripts, there's a line break in the first one (UDF), which will cause an (unwanted) error.

the correct line is:

If $msg=$send Or $msg=$sen Then MsgBox(270400,"Send Bug Report","Email successfully sent !     ")

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

i cannot leave my hands from it:

Script: _ErrorHandler.au3 (UDF, v 1.2)

;#=#INDEX#==================================================================#
;#  Title .........: _Error Handler.au3  v 1.2                              #
;#  Description....: AutoIt3 Error Handler & Debugger                       #
;#  Date ..........: 7.9.08                                                 #
;#  Authors .......: jennico (jennicoattminusonlinedotde)                   #
;#                   @MrCreatoR                                             #
;#                   MadExcept (GUI inspiration by mrRevoked)               #
;#==========================================================================#

#include-once

Dim $s_msg,$s_icn[5],$s_lb1[5],$s_lb2[5],$s_old=1

_OnAutoItError()

;#=#Function#===============================================================#
;#  Name ..........: _OnAutoItError ( )                                     #
;#  Description....: AutoIt3 Error Handler & Debugger GUI                   #
;#  Parameters.....: (None)                                                 #
;#  Date ..........: 7.9.08                                                 #
;#  Authors .......: jennico (jennicoattminusonlinedotde)                   #
;#                   @MrCreatoR                                             #
;#                   MadExcept (GUI inspiration by mrRevoked)               #
;#==========================================================================#

;   this function is made to be customized !

Func _OnAutoItError()
    If StringInStr($CmdLineRaw,"/AutoIt3ExecuteScript") Then Return
    Opt("TrayIconHide",1)   ;   run a second instance
    $iPID=Run(@AutoItExe&' /ErrorStdOut /AutoIt3ExecuteScript "'&@ScriptFullPath&'"',@ScriptDir,0,6)
    Dim $sErrorMsg,$GUI=GUICreate(@ScriptName,385,90,Default,Default,-2134376448)
        GUISetBkColor(0xE0DFE2) ;BitOR($WS_CAPTION,$WS_POPUP,$WS_SYSMENU)
        GUICtrlCreateIcon("user32.dll",103,11,11,32,32)
        GUICtrlSetBkColor(GUICtrlCreateLabel("",1,1,383,1),0x41689E)
        GUICtrlSetBkColor(GUICtrlCreateLabel("",1,88,383,1),0x41689E)
        GUICtrlSetBkColor(GUICtrlCreateLabel("",1,1,1,88),0x41689E)
        GUICtrlSetBkColor(GUICtrlCreateLabel("",383,1,1,88),0x41689E)
        GUICtrlSetBkColor(GUICtrlCreateLabel("An error occurred in the application.",52,21,175,15),-2)
        $s_lb1[0]=GUICtrlCreateLabel("",10,60,110,22)
            GUICtrlSetBkColor(-1,0xEFEEF2)
            GUICtrlSetState(-1,128)
        $s_lb2[0]=GUICtrlCreateLabel("   send bug report",28,64,92,15)
            GUICtrlSetBkColor(-1,-2)
            GUICtrlSetCursor(-1,0)
        $s_icn[0]=GUICtrlCreateIcon("explorer.exe",254,13,63,16,16)
            GUICtrlSetCursor(-1,0)
        $s_lb1[1]=GUICtrlCreateLabel("",126,60,114,22)
            GUICtrlSetBkColor(-1,0x706E63)
            GUICtrlSetState(-1,128)
        $s_lb2[1]=GUICtrlCreateLabel("    De-Bug Script",145,64,95,15)
            If @Compiled Then GUICtrlSetData(-1,"   show bug report")
            GUICtrlSetColor(-1,0xFFFFFF)
            GUICtrlSetBkColor(-1,-2)
            GUICtrlSetCursor(-1,0)
        $s_icn[1]=GUICtrlCreateIcon("shell32.dll",-81,129,63,16,16)
            If @Compiled Then GUICtrlSetImage(-1,"shell32.dll",23)
            GUICtrlSetCursor(-1,0)
        $s_lb1[2]=GUICtrlCreateLabel("",246,8,131,22)
            GUICtrlSetBkColor(-1,0xEFEEF2)
            GUICtrlSetState(-1,128)
        $s_lb2[2]=GUICtrlCreateLabel("   continue application",265,12,115,15)
            GUICtrlSetBkColor(-1,-2)
            GUICtrlSetCursor(-1,0)
        $s_icn[2]=GUICtrlCreateIcon("shell32.dll",290,249,11,16,16)
            GUICtrlSetCursor(-1,0)
        $s_lb1[3]=GUICtrlCreateLabel("",246,34,131,22)
            GUICtrlSetBkColor(-1,0xEFEEF2)
            GUICtrlSetState(-1,128)
        $s_lb2[3]=GUICtrlCreateLabel("    restart application",265,38,115,15)
            GUICtrlSetBkColor(-1,-2)
            GUICtrlSetCursor(-1,0)
        $s_icn[3]=GUICtrlCreateIcon("shell32.dll",255,249,37,16,16)
            GUICtrlSetCursor(-1,0)
        $s_lb1[4]=GUICtrlCreateLabel("",246,60,131,22)
            GUICtrlSetBkColor(-1,0xEFEEF2)
            GUICtrlSetState(-1,128)
        $s_lb2[4]=GUICtrlCreateLabel("     close application",265,64,115,15)
            GUICtrlSetBkColor(-1,-2)
            GUICtrlSetCursor(-1,0)
        $s_icn[4]=GUICtrlCreateIcon("shell32.dll",240,249,63,16,16)
            GUICtrlSetCursor(-1,0)
    ProcessWait($iPID)
    While 1 ;   trap the error message
        $sErrorMsg&=StdoutRead($iPID)
        If @error Then ExitLoop
        Sleep(1)
    WEnd
    If $sErrorMsg="" Then Exit
    GUISetState()
    Opt("TrayIconHide",0)
    Opt("TrayAutoPause",0)
    WinSetOnTop(@ScriptName,"",1)
    SoundPlay(@WindowsDir&"\Media\chord.wav")
    TraySetToolTip(@ScriptName&@CRLF&"An error occurred in the application.")
    Do  ;   choose action to be taken
        Dim $s_msg=GUIGetMsg(),$mse=GUIGetCursorInfo($GUI)
        If @error=0 Then
            For $i=0 To 4
                If $i<>$s_old And ($mse[4]=$s_lb1[$i] Or $mse[4]=$s_lb2[$i] Or _
                    $mse[4]=$s_icn[$i]) Then __Select($i)
            Next
        EndIf
        If WinActive($GUI) And $s_msg=0 Then
            HotKeySet("{ENTER}","__Hotkey")
            HotKeySet("{RIGHT}","__Hotkey")
            HotKeySet("{LEFT}","__Hotkey")
            HotKeySet("{DOWN}","__Hotkey")
            HotKeySet("{TAB}","__Hotkey")
            HotKeySet("{UP}","__Hotkey")
        Else
            HotKeySet("{ENTER}")
            HotKeySet("{RIGHT}")
            HotKeySet("{LEFT}")
            HotKeySet("{DOWN}")
            HotKeySet("{TAB}")
            HotKeySet("{UP}")
        EndIf
        If $s_msg=$s_lb2[2] Or $s_msg=$s_icn[2] Then MsgBox(270400,"Continue Application", _
            "I am afraid, not possible with AutoIt !     "&@CRLF&@CRLF& _
            "( No GoTo command )      :-( ")
        If $s_msg=$s_lb2[0] Or $s_msg=$s_icn[0] Then MsgBox(270400,"Send Bug Report", _
            "Email successfully sent !     ")
            ;#include <INet.au3>    ;   use email
            ;_INetSmtpMail ( $s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress [,$s_Subject&_
            ;[,$as_Body [,$s_helo, [,$s_first [,$b_trace]]]]])
        If $s_msg=$s_lb2[1] Or $s_msg=$s_icn[1] Then
            If @Compiled=0 Then __Debug($sErrorMsg)
            If @Compiled Then MsgBox(270400,"Show Bug Report",$sErrorMsg&"    ")
        EndIf
    Until $s_msg=-3 Or $s_msg=$s_lb2[3] Or $s_msg=$s_icn[3] Or $s_msg=$s_lb2[4] Or $s_msg=$s_icn[4]
    If $s_msg=$s_lb2[3] Or $s_msg=$s_icn[3] Then Run(@AutoItExe&' "'&@ScriptFullPath& _
        '"',@ScriptDir,0,6)
    SoundPlay(@WindowsDir&"\Media\start.wav")
    Exit
EndFunc

;#=#Function#===============================================================#
;#  Name ..........: __Debug ( $txt )                                       #
;#  Description....: Debug Function for _ErrorHandler.au3                   #
;#  Parameters.....: $txt = Error Message Text from StdoutRead              #
;#  Date ..........: 7.9.08                                                 #
;#  Authors .......: jennico (jennicoattminusonlinedotde)                   #
;#==========================================================================#

Func __Debug($txt)
    WinSetState(@ScriptName,"",@SW_HIDE)
    $a=StringSplit($txt,@CRLF,1)
    Dim $b=StringSplit($a[1],") : ==> ",1),$number=StringMid($b[1],StringInStr($b[1],"(")+1)
    Dim $code="Error Code: "&@TAB&StringTrimRight($b[2],2),$line="Line: "&@TAB&$number&" => "&$a[3]
    Dim $file="File: "&@TAB&StringReplace($b[1]," ("&$number,""),$count=StringLen($code),$height=180
    If StringLen($file)>$count Then $count=StringLen($file)
    If StringLen($line)>$count Then $count=StringLen($line)
    If StringLen($a[2])>$count Then $count=StringLen($a[2])
    If $count*6>@DesktopWidth-50 Then Dim $count=(@DesktopWidth-50)/6,$height=240
    Run(RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\SciTE.exe","")& _
        ' "'&@ScriptFullPath&'" /goto:'&$number&","&StringLen($a[2])-1)
    $x=InputBox(" Please Correct this line:",$code&@CRLF&@CRLF&$file&@CRLF&@CRLF& _
        $line,StringTrimRight($a[2],1),"",$count*6,$height)
    WinSetState(@ScriptName,"",@SW_SHOW)
    If $x="" Or $x=StringTrimRight($a[2],1) Then Return
    $t=StringSplit(FileRead(@ScriptFullPath),@CRLF,1)
    $t[$number]=StringReplace($t[$number],StringTrimRight($a[2],1),$x)
    $open=FileOpen(@ScriptFullPath,2)
    For $i=1 to $t[0]
        FileWriteLine($open,$t[$i])
    Next
    FileClose($open)
    ControlSend(@ScriptDir,"","ToolbarWindow32","^R")
EndFunc

;#=#Function#===============================================================#
;#  Name ..........: __Select ( $i )                                        #
;#  Description....: Select Function for _ErrorHandler.au3                  #
;#  Parameters.....: $i = Element from Mouse Hover ID                       #
;#  Date ..........: 7.9.08                                                 #
;#  Authors .......: jennico (jennicoattminusonlinedotde)                   #
;#==========================================================================#

Func __Select($i)
    GUICtrlSetBkColor($s_lb1[$i],0x706E63)
    GUICtrlSetColor($s_lb2[$i],0xFFFFFF)
    GUICtrlSetBkColor($s_lb1[$s_old],0xEFEEF2)
    GUICtrlSetColor($s_lb2[$s_old],0)
    $s_old=$i
EndFunc

;#=#Function#===============================================================#
;#  Name ..........: __Hotkey ( )                                           #
;#  Description....: Hotkey Functions for _ErrorHandler.au3                 #
;#  Parameters.....: None                                                   #
;#  Date ..........: 7.9.08                                                 #
;#  Authors .......: jennico (jennicoattminusonlinedotde)                   #
;#==========================================================================#

Func __Hotkey()
    If @HotKeyPressed="{DOWN}" And $s_old>1 And $s_old<4 Then __Select($s_old+1)
    If @HotKeyPressed="{RIGHT}" And $s_old<2 Then __Select(1+3*($s_old=1))
    If @HotKeyPressed="{TAB}" Then __Select(($s_old+1)*($s_old<4))
    If @HotKeyPressed="{LEFT}" And $s_old Then __Select($s_old>1)
    If @HotKeyPressed="{UP}" And $s_old>2 Then __Select($s_old-1)
    If @HotKeyPressed="{ENTER}" Then $s_msg=$s_icn[$s_old]
EndFunc

now maybe the debugger needs to be enhanced.

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

Very clever idea jennico.

I think your example needs to be changed because it doesn't allow the script to be run with my version of SciTE so the error trapping cannot work. If I change

MsgBox(0,"", ; this is meant to produce an error !

to

MsgBox(0,"", $i[77]); this is meant to produce an error !

then the script will start and I can see the error trapping work.

As a suggestion, maybe updates could be made in the first post with a note about what has changed, rather than add updates in later posts because then it is much easier for people to keep track of them.

My own debugger lacks this feature so I will look at using your idea when I get some time. ;)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

hello martin, thank you !

but i do not understand. what part does not work for you ? the error trapping part or the debugging in scite ?

and how can the msgbox line change this behaviopr ?

a bit confused...

j.

edit2 : maybe i understand now. you mean that your AUTOIT, not ScITE version traps my example error before running the scipt. some errors are trapped before running (like missing endif and next). if this is so, okay, you have to hide a different error in the script.

you are using beta ? with my version (very old) it works fine.

btw: i tried your debugger but couldn't get it working, but i really didn't steal anything... i neither looked into the code ;)

i started a question in the support forum about manipulating SciTE from an autoit script, but didn't get any answer. if i knew more about that, there could be added a lot more debugging functions.

in the scite help file there are several "director" parameters, but i could not find out how to use them properly. maybe we could work together on that issue.

edit: i would not call the additiuons "update". they are just variations of the customizable error box, no improvement.

in doing so i also want to encourage the readers to publish their custom boxes, if they have ideas.

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

hello martin, thank you !

but i do not understand. what part does not work for you ? the error trapping part or the debugging in scite ?

and how can the msgbox line change this behaviopr ?

a bit confused...

j.

edit2 : maybe i understand now. you mean that your AUTOIT, not ScITE version traps my example error before running the scipt. some errors are trapped before running (like missing endif and next). if this is so, okay, you have to hide a different error in the script.

you are using beta ? with my version (very old) it works fine.

Yes you are correct I meant my AutoIt version. I tried with production version 3.2.12.1

btw: i tried your debugger but couldn't get it working, but i really didn't steal anything... i neither looked into the code ;)

Sorry you had no luck. It's possible the latest post has corrected an error because I have recently downloaded it and tried it on XP SP2 and Vista 64bit, but I it doesn't work on Vista 32 bit but I have no idea why not. When I have time I might try converting it to use SciTE rather than RazerM's editor.

As far as 'stealing' anything is concerned anything I show is there for the taking so 'steal' all you want :D (That's how I get lots of my code anyway.)

i started a question in the support forum about manipulating SciTE from an autoit script, but didn't get any answer. if i knew more about that, there could be added a lot more debugging functions.

in the scite help file there are several "director" parameters, but i could not find out how to use them properly. maybe we could work together on that issue.

There is an example script somewhere of using messages with SciTe. If I come across it I'll send you the link.

edit: i would not call the additiuons "update". they are just variations of the customizable error box, no improvement.

in doing so i also want to encourage the readers to publish their custom boxes, if they have ideas.

j.

Fair enough.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Hi,

it is not working with CUI!

E.g.:

#AutoIt3Wrapper_Change2CUI=y
#include <_ErrorHandler.au3>
ConsoleWrite("Hello CMD world!" & @CRLF)

No output into CMD this way! Please check (Danke ;) )

Thanks,

UEZ

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

No output into CMD this way

Right, the script itself reads the StdOut stream (on second run), so i don't think we can use it with CUI...

 

Spoiler

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

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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 UDF
 
AutoIt_Icon_small.pngExamples: 
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 Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

what is cui ? sorry ;) don't really know

if you need the output stream you can check the method i tried first ..... here or here

it works without stdread and instead reads the error messagebox and sends "enter" to it. you just have to rewrite the include file a little bit.

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

what is cui ?

It's Common User Interface, like command line prompt ;)

Here is my (changed) version to the subject, there is two UDF files in the archive. One is AutoItErrorHandler_UDF - uses StdOutRead. The second one is AutoItErrorHandler_UDF_NoStd - It's waiting for the standard Error MsgBox, and then quickly(!) closes it and display a custom dialog. I supose this one can work with CUI mode.

P.S

The bug report message is formated.

AutoItErrorHandler_v1.2.zip

 

Spoiler

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

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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 UDF
 
AutoIt_Icon_small.pngExamples: 
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 Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • 3 weeks later...

I thought this will exclude me of writing an internal debugging engine for my program. But when compiled, it gives the same errors that normal AutoIT compiled programs give. Isn't there a way that compiled executables can return the variable, for example, that was not declared and was making program to stop ? Anyway, this script is sweet :P

[size="2"]SFXMaker[/size] - The most complete switchless installer creator software[indent][/indent]
Link to comment
Share on other sites

  • 2 weeks later...

I wrote a script which take some files as cmdline parameters (i put the compiled script in sendto folder). when including the _errorhandling.au3, $cmdline[0] return 0. is this a bug? i use 3.2.12.0 version.

(please note that english is a foreign language for me and i am a newbie

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

  • Recently Browsing   0 members

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