Jump to content

Recommended Posts

Posted

Perfect, i'm just waiting for this future improvement!

Several improvements will be made in the UDF including line numbering!

Thanks for UDF!

Posted

What is the purpose of getting current script line (without the includes)?

If i am running the program as user, and it's crashed, it will show the full script source line number, so, for the developer (when the crash is reported via email) it's more than enough to find out where is the error.

 

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

Posted

One more thing...

The error handler should work with non compiled scripts, to allow debugging before compiling.

Can be done using StdOutRead instead of hooking crash message box.

 

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

Posted

@MrCreatoR

The includes are not supposed to have errors.

I suggest to add separate line number for includes.

Getting the full script line number is not efficient, you need to obfsucate it to get the right line number.

Br, FireFox.

Posted

@Mrcreator

Try this example (without compiling) using context menu in explorer window:

#include "_AutoItErrorTrap.au3"

; Default messages...
_AutoItErrorTrap()

_Example()

Func _Example()
    Local $iOption = MsgBox(262180, "Error detection test!", "Hi!" & @CRLF & @CRLF & "Let's try to catch the AutoIt error window?" & _
            @CRLF & @CRLF & "Answer [Yes] to generate an syntaxe error, [No] to exit...")
    Select
        Case $iOption = 6 ;Yes
            ; Sybtaxe error |LoL|!
            MsgBox(4096, "Erro!",)

        Case $iOption = 7 ;No
            Exit
    EndSelect
EndFunc   ;==>_Example
You will see that also works normally In the same way as compiled!

JS

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

Somewhere Out ThereJames Ingram

somewh10.png

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

Posted

What is the purpose of getting current script line (without the includes)?

If i am running the program as user, and it's crashed, it will show the full script source line number, so, for the developer (when the crash is reported via email) it's more than enough to find out where is the error.

If I have this script

#include <WinApi.au3>

$var = _WinApi_Somefunc()

MsgBox(0,0,$var[4444444]); error here

When that crashes, it will not return line #3

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted

The error handler should work with non compiled scripts, to allow debugging before compiling.

Can be done using StdOutRead instead of hooking crash message box.

To use StdOutRead we have to have another executable to monitor the error window, and in my UDF is not necessary!

JS

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

Somewhere Out ThereJames Ingram

somewh10.png

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

Posted

You will see that also works normally In the same way as compiled!

Yes, but what about running from SciTE?

When that crashes, it will not return line #3

Right, then you can use obfuscator and find the line :). Perhaps the UDF could have _AutoItErrorDebug function, to do the obfuscator stuff (just combine together the includes).

To use StdOutRead we have to have another executable to monitor the error window, and in my UDF is not necessary!

I am talking about reading the stream, not the window.

Anyway, the console output itself considered as a debug tool :), my mistake.

 

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

Posted

Right, then you can use obfuscator and find the line :). Perhaps the UDF could have _AutoItErrorDebug function, to do the obfuscator stuff (just combine together the includes).

That's one way to do it, but I've never been able to accurately get it :(

But if the exact line number/au3file/function were to pop up in a box, well

that can't harm anyone really can it :)

I'm still a little worried about the trade off for large scripts though.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted (edited)

About show original line number in post by FireFox

The same file with a few modifications:

ShowOriginalLineNumbers.au3 *New:

Compiled:

Posted Image

Non compiled:

Posted Image

Final structure of the example file:

Global $__iLineNumber=0
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_AU3Check=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include "_AutoItErrorTrap.au3"

;If Not @Compiled Then
;    MsgBox(4096, "Note:", "You need to compile first!")
;    Exit
;EndIf

; Default messages...
$__iLineNumber=14
_AutoItErrorTrap()

$__iLineNumber=16
_Example()

$__iLineNumber=18 & " - " & "Func _Example()"
Func _Example()
    $__iLineNumber=19 & " - " & "Func _Example()"
    Local $asArray[4] = ["JScript", "Jonatas", "AutoIt", "Brasil"]
    $__iLineNumber=20 & " - " & "Func _Example()"
    Local $iOption = MsgBox(262180, "Error detection test!", "Hi!" & @CRLF & @CRLF & "Let's try to catch the AutoIt error window?" & _
            @CRLF & @CRLF & "Answer [Yes] to generate an array error, [No] to exit...")
    $__iLineNumber=22 & " - " & "Func _Example()"
    Select
        $__iLineNumber=23 & " - " & "Func _Example()"
        Case $iOption = 6 ;Yes
            ; Error in array value!
            $__iLineNumber=25 & " - " & "Func _Example()"
            MsgBox(4096, "Erro!", $asArray[5])

        $__iLineNumber=27 & " - " & "Func _Example()"
        Case $iOption = 7 ;No
            $__iLineNumber=28 & " - " & "Func _Example()"
            Exit
    $__iLineNumber=29 & " - " & "Func _Example()"
    EndSelect
$__iLineNumber=30 & " - " & "Func _Example()"
EndFunc   ;==>_Example

Any suggestions to add?

JS

Edited by JScript

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

Somewhere Out ThereJames Ingram

somewh10.png

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

Posted

Once again, very nice !

You should add more statements to skip, like end statements (EndSelect/EndSwitch, EndIf, Next, WEnd, ...), also some things detected by Au3Check.

You can suggest the user to choose the error level reporter like in php. (more the level is low, and less you write line numbers)

Anyway, better GUI; keep it up :)

Posted (edited)

Thanks a lot, very good. I agree with the request from firefox.

The button submit doesn't work? Why don't disable it?

I'm curious, what is "Last screen" seen in your latest images attached?

Edit : find below which information are important to fix a bug in a application. Of course, it's my opinion. Feel free to use what you want!

#include-once
#include 

Func ErrorInformation($var = "")
Local $tempVar = "", $PIDMemory, $PIDIO

$tempVar &= "Software : " & @AutoItExe
$tempVar &= @CRLF & "PID : " & @AutoItPID

$PIDMemory = ProcessGetStats(-1,0)
if not @error then $tempVar &= " Memory infos : " & $PIDMemory[0] & " - " & $PIDMemory[1]
$PIDIO = ProcessGetStats(-1,1)
if not @error then

$tempVar &= @CRLF & "Process IO infos : "

for $i= 0 to 5
$tempVar &= $PIDIO[$i]

if $i < 5 then $tempVar &= " - "

next
endif

_Crypt_Startup()
$tempVar &= @CRLF & "Checksum : " & _Crypt_HashFile(@AutoItExe,$CALG_MD5)
_Crypt_Shutdown()
$tempVar &= @CRLF & "Size : " & Round(FileGetSize(@AutoItExe)/1024,3) & " ko"
$tempVar &= @CRLF & "Modified date : " & FileGetTime (@AutoItExe,0,1)
$tempVar &= @CRLF & "Version : " & FileGetVersion (@AutoItExe)
$tempVar &= @CRLF & "OS : " & @OSVersion & " " & @OSServicePack & " " & @OSArch & " build " & @OSBuild & " " & @OSLang
$tempVar &= @CRLF & "Computer : " & @ComputerName & " - " & @UserName

Return $tempVar & @CRLF & @CRLF & "Error : " & @CRLF & $var

EndFunc

Edited by ricky03
Posted

@FireFox

Done:

#include <File.au3>

Local $sScriptPath = FileOpenDialog("select au3", @ScriptDir, "AutoIt3 Script (*.au3)", 3)
If @error Then Exit -1
If FileExists($sScriptPath & "_Debug.au3") Then
    FileDelete($sScriptPath & "_Debug.au3")
EndIf

Local $aLines, $sOutPut = "Global $__iLineNumber=0" & @CRLF
Local $blSkipNextLine = False
Local $iLine = 1, $sCurrentLine, $sFunc = "", $sIndent = ""

_FileReadToArray($sScriptPath, $aLines)

While $iLine <= $aLines[0]
    $sCurrentLine = $aLines[$iLine]
    $sLineStripWS = StringStripWS($aLines[$iLine], 3)

    If StringInStr($sLineStripWS, "EndFunc", 0, 1, 1, 7) Then
        $sFunc = ""
    EndIf

    If StringInStr($sLineStripWS, "#", 0, 1, 1, 1) Or StringInStr($sLineStripWS, ";", 0, 1, 1, 1) Or _
        StringInStr($sLineStripWS, "Select", 0, 1, 1, 6) Or StringInStr($sLineStripWS, "Switch", 0, 1, 1, 6) Or _
        StringInStr($sLineStripWS, "EndSelect", 0, 1, 1, 9) Or StringInStr($sLineStripWS, "EndSwitch", 0, 1, 1, 9) Or _
        StringInStr($sLineStripWS, "EndIf", 0, 1, 1, 5) Or StringInStr($sLineStripWS, "Next", 0, 1, 1, 4) Or _
        StringInStr($sLineStripWS, "WEnd", 0, 1, 1, 4) Or StringInStr($sLineStripWS, "Exit", 0, 1, 1, 4) Or _
        StringInStr($sLineStripWS, "EndFunc", 0, 1, 1, 7) Or StringLen($sLineStripWS) = 0 Then
        $sOutPut &= $sCurrentLine & @CRLF
        $iLine += 1
        ContinueLoop
    EndIf

    If StringInStr($sLineStripWS, "Func", 0, 1, 1, 4) Then
        $sFunc = $sCurrentLine
    EndIf

    If $blSkipNextLine Then
        $blSkipNextLine = False
    Else
        $sIndent = ""
        While StringIsSpace(StringLeft($sCurrentLine, StringLen($sIndent) + 1))
            $sIndent = StringLeft($sCurrentLine, StringLen($sIndent) + 1)
        WEnd
        ;$sOutPut &= "$__iLineNumber=" & $iLine & " & ': " & StringReplace($sCurrentLine, "'", '"') & "'" & @CRLF
        ;If $sFunc Then
            ;$sOutPut &= $sIndent & "$__iLineNumber=" & $iLine & ' & " - " & "' & $sFunc & '"' & @CRLF
            $sOutPut &= $sIndent & "$__iLineNumber=" & $iLine & ' & " - " & ' & "'" & _TruncatePath(StringReplace($sLineStripWS, "'", '"'), 300) & "'" & @CRLF
        ;Else
        ;    $sOutPut &= $sIndent & "$__iLineNumber=" & $iLine & @CRLF
        ;EndIf
    EndIf

    $sOutPut &= $sCurrentLine & @CRLF

    If StringRight($sCurrentLine, 2) = " _" Then
        $blSkipNextLine = True
    EndIf

    $iLine += 1
WEnd

FileWrite($sScriptPath & "_Debug.au3", $sOutPut)

Func _TruncatePath($sPath, $iValue)
    Local $sRet = DllCall("Shlwapi.dll", "BOOL", "PathCompactPath", "int", 0, "str", $sPath, "uint", $iValue)
    Return $sRet[2]
EndFunc   ;==>_TruncatePath

I added the following line to have at least the first 300 characters corresponding to the original line of the program!

_TruncatePath(StringReplace($sLineStripWS, "'", '"'), 300)

The result is this:

Posted Image

The button submit doesn't work? Why don't disable it?

Have patience, is still in progress...

I'm curious, what is "Last screen" seen in your latest images attached?

Are more new stuff, wait!

Edit : find below which information are important to fix a bug in a application. Of course, it's my opinion. Feel free to use what you want!

Thank you!

JS

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

Somewhere Out ThereJames Ingram

somewh10.png

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

Posted (edited)

Fixes:

  • 0.10.2312.2600b
  • 23/10/2012 -> *Added support to display the original line numbers in the scripts compiled! Thanks to @FireFox for this tip!

    $hAET_GETERROR = StringRegExpReplace($hAET_GETERROR, "d+[0-9]", Eval("__iLineNumber") & @CRLF)

    *Additional information suggested by @ricky03, thank you!

    *Some bugs were fixed...

    The file ShowOriginalLineNumbers.au3 was added in zip file.

Reagrds,

João Carlos.

Edited by JScript

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

Somewhere Out ThereJames Ingram

somewh10.png

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

Posted

Hello,

new idea for new feature, on your ShowOriginalLineNumbers modify also our included files with the lines, but only for example the functions to don't increase a lot of lines?

Thanks again!

Posted

on your ShowOriginalLineNumbers modify also our included files with the lines

In this case it would be better to create a new folder with the script files, BUT if you have external files (images, dlls) it's a problem.

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