TheFluffyOne Posted February 12, 2009 Share Posted February 12, 2009 I've got a bunch of scripts that get run on end-user machines, and if a condition occurs that I didn't think to handle (ahem) the user gets a dialog on their screen telling them there was an AutoIt error -- not desirable! Having had a dig around, I've found the OnExitFunc option, which sounded like it might allow me to hide the error message, however it either doesn't work that way or I'm not using it correctly: Opt("OnExitFunc", "myExitFunction") callInvalidFunction() Func myExitFunction() ConsoleWriteError("An error occurred: " & @error) EndFunc I appreciate that the ConsoleWriteError is pretty useless here; it's just a placeholder for some more sensible code to output debug information to a file. The problem is that when I compile this to an EXE it doesn't seem to make a difference. I still get a dialog on the screen advising me of the error. Do I have the right function, or is there another way to do this? Link to comment Share on other sites More sharing options...
FireFox Posted February 12, 2009 Share Posted February 12, 2009 @TheFluffyOne OnAutoitExit function is only called when autoit exit, its not for prevent from autoit errors... Before, there were Opt('RunErrorsFatal', 0) but now you cant disable fatal error messages (I think), so you will have to make script without errors Cheers, FireFox. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 12, 2009 Developers Share Posted February 12, 2009 Before, there were Opt('RunErrorsFatal', 0) but now you cant disable fatal error messages (I think), so you will have to make script without errors Not a valid statement!This options was only to catch Run() errors .. nothing more ..nothing less .. which is obsolete with the new implementation.There is no autoit3 option to suppress the error other then proper coding or shelling the compiled script with parameter /ErrorStdOut which will redirect the error information to STDOUT.Jos pixelsearch 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
tanno Posted February 12, 2009 Share Posted February 12, 2009 I've got a bunch of scripts that get run on end-user machines, and if a condition occurs that I didn't think to handle (ahem) the user gets a dialog on their screen telling them there was an AutoIt error -- not desirable! Having had a dig around, I've found the OnExitFunc option, which sounded like it might allow me to hide the error message, however it either doesn't work that way or I'm not using it correctly: Opt("OnExitFunc", "myExitFunction") callInvalidFunction() Func myExitFunction() ConsoleWriteError("An error occurred: " & @error) EndFunc I appreciate that the ConsoleWriteError is pretty useless here; it's just a placeholder for some more sensible code to output debug information to a file. The problem is that when I compile this to an EXE it doesn't seem to make a difference. I still get a dialog on the screen advising me of the error. Do I have the right function, or is there another way to do this? You should try a function ObjEvent("Autoit.error", myerrorfunction). This catch the exception an handle it with myerrorfunciont. http://www.autoitscript.com/autoit3/docs/f...ns/ObjEvent.htm Saludos. Link to comment Share on other sites More sharing options...
FireFox Posted February 12, 2009 Share Posted February 12, 2009 @Jos Thanks for correcting me It would be better to make option for ignore options and if fatal error occurs then redirect to function for exit like user want... Cheers, FireFox. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 12, 2009 Developers Share Posted February 12, 2009 You should try a function ObjEvent("Autoit.error", myerrorfunction). This catch the exception an handle it with myerrorfunciont.http://www.autoitscript.com/autoit3/docs/f...ns/ObjEvent.htmSaludos.Did it work for you? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Authenticity Posted February 12, 2009 Share Posted February 12, 2009 Yeah... this function is only COM error event handler. It will not catch this within the handler function but if compiled it'll produce the unwanted MsgBox you want to avoid but it's much better than watching your stack flowed...: Dim $rrr = Recursive(0) MsgBox(0x40, 'Title', $rrr) Func Recursive($i) If $i = 5000 Then Return $i Return $i+Recursive($i+1) EndFunc Link to comment Share on other sites More sharing options...
TheFluffyOne Posted February 19, 2009 Author Share Posted February 19, 2009 Many thanks to everyone for the replies, and sorry for not acknowledging them sooner -- I really must turn on watching of my own posts Link to comment Share on other sites More sharing options...
jvanegmond Posted February 19, 2009 Share Posted February 19, 2009 Write better code. ;;; DONT!!!!!!!!!!!!!! $IpInput = InputBox("", "Enter your IP address") $aSplit = StringSplit($IpInput,".") MsgBox(0,"","Your ip is: " & $aSplit[1] & "." & $aSplit[2] & "." & $aSplit[3] & "." & $aSplit[4]) ; DO!!!!!!!!! $IpInput = InputBox("", "Enter your IP address") If @error Then Exit $aSplit = StringSplit($IpInput,".") If Not @error And $aSplit[0] == 4 Then MsgBox(0,"","Your ip is: " & $aSplit[1] & "." & $aSplit[2] & "." & $aSplit[3] & "." & $aSplit[4]) EndIf github.com/jvanegmond Link to comment Share on other sites More sharing options...
b1naryatr0phy Posted February 20, 2009 Share Posted February 20, 2009 (edited) Write better code.Dude seriously? Jesus if ya ain't gonna try to help someone out then don't even reply manYea FluffyOne, try what tanno suggested: ObjEvent("AutoIt.Error", "myerrorfunction") I was getting a Line -1: error and it fixed the problem for me. Edited February 20, 2009 by b1naryatr0phy Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 20, 2009 Share Posted February 20, 2009 (edited) Dude seriously? Jesus if ya ain't gonna try to help someone out then don't even reply manYea FluffyOne, try what tanno suggested: ObjEvent("AutoIt.Error", "myerrorfunction") I was getting a Line -1: error and it fixed the problem for me.Dude, what the hell?? Manadar is right, you don't swipe your errors under rug and hope they disappear, you write better code so there isn't any errors. Edited February 20, 2009 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
b1naryatr0phy Posted February 20, 2009 Share Posted February 20, 2009 (edited) Dude, what the hell?? Manadar is right, you don't swipe your errors under rug and hope they disappear, you write better code so there isn't any errors.I agree completely, but people go to forums for help, not to get mocked. What the hell is wrong with this forum anyway good lord. Maybe some of yall need to get off the pedestal your on and stop acting like your better than anyone who is still learning.Dont get me wrong, there are some extremely helpful people here, but i emphasize some Edited February 20, 2009 by b1naryatr0phy Link to comment Share on other sites More sharing options...
jvanegmond Posted February 20, 2009 Share Posted February 20, 2009 (edited) Sorry, b1naryatr0phy. Sometimes it is hard to determine the cause of the error, often because of misinformation, information lacking or a language barrier and it is hard to give a reply that makes sense at all times. For your information, I am trying to help out. I have shown how to capture errors in AutoIt using @error and shown a case in which it is very useful. Edited February 20, 2009 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now