![Photo](https://secure.gravatar.com/avatar/8131a9fdfb1c742251f10bb8a1c47918?s=100&d=%2F%2Fwww.autohotkey.com%2Fboard%2Fpublic%2Fstyle_images%2Fortem%2Fprofile%2Fdefault_large.png)
AHK debugging: How to know current line number being execute
Is there a way to do that? Or anything close to that for debugging? I am using this AHK script to automate some windows explorer related task. But sometimes it gets stuck in between and I have no idea where the script gets stuck. If I knew the current line number being executed, it would be great. Using Msgbox after each line is not possible and very inefficient.
Could someone please help me with this?
Also, I am new to AHK scripting so I would be grateful if you could explain with a short example if possible.
Thanks
Sunny
![AHK debugging: How to know current line number being execute: post #1](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
A_LineNumber
The number of the currently executing line within the script (or one of its #Include files). This line number will match the one shown by ListLines; it can be useful for error reporting such as this example: MsgBox Could not write to log file (line number %A_LineNumber%).Since a compiled script has merged all its #Include files into one big script, its line numbering may be different than when it is run in non-compiled mode.
#SingleInstance, force a=10 b=20 c=30 msgbox %A_LineNumber% a=11 b=22 c=33 msgbox %A_LineNumber% ExitApp
![AHK debugging: How to know current line number being execute: post #2](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Please bear with me and my English which is so bad at times that even I don't understand myself
![AHK debugging: How to know current line number being execute: post #3](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
![AHK debugging: How to know current line number being execute: post #4](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Please bear with me and my English which is so bad at times that even I don't understand myself
The problem is that if I knew where all to put Msgbox, then it would be fine to use this function.
But is there any where to see, while execution of the script, which line number is being executed. Since, i don't know where it would hang, i cannot predict putting Msgbox and so is there anything that tells me on run-time, which line number of being executed?
I was looking at the 'Pause' command. When the tool I am automating using AHK, hangs, I could Pause the script. But then after that, is there a way to figure out which line number has the script been paused at?
This, i suppose would be the nearest possible solution to getting line numbers at run-time (i.e. if that is not possible)
Thanks
![AHK debugging: How to know current line number being execute: post #5](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
http://www.autohotke...s/ListLines.htm
although what i suspect you're asking for is a trace facility. Generally those are built into IDE's when a program is run from there. What happens in a trace facility is that each line is essentially captured before it's run and displayed on a debugging monitor screen. Facilities for tracing generally also have breakpointing as well so when a program hits a specific line number or subroutine it stops. May i recommend a debugger called DbgView for checking program flow. you can find it here
http://technet.micro...ernals/bb896647
it has trace facilities and the ability to show variables as well as other useful debugging tools. It's free and it's safe.
one other thing. you will need to run the debugger before the script starts and somewhere, generally at the beginning of the area you want to check, you can add the AutoHotkey command OutputDebug
http://www.autohotke...OutputDebug.htm
to capture specific script events as they occur
![AHK debugging: How to know current line number being execute: post #6](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter KeyLooperDemo Key Spammer TinyClickRecorder GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
<!-- m -->http://l.autohotkey....ipts.htm#idebug<!-- m -->
or you could try this debug log function by Rapte_Of_Suzaku
<!-- m -->http://www.autohotke... ... =debug log<!-- m -->
![AHK debugging: How to know current line number being execute: post #7](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
![AHK debugging: How to know current line number being execute: post #8](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Sign up for free! http://db.tt/9Hrieqj
try { inst := ComObjCreate(a_surely_non_existent_COM_object) ; <---- Put here } catch e { MsgBox, 16,, % "Exception thrown!`n`nwhat: " e.what "`nfile: " e.file . "`nline: " e.line "`nmessage: " e.message "`nextra: " e.extra }
![AHK debugging: How to know current line number being execute: post #9](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Please bear with me and my English which is so bad at times that even I don't understand myself