ken82m Posted November 25, 2008 Share Posted November 25, 2008 Twice I've had need to run OnAutoITExit even in the script died from a hard error.I try to take everything into account but I'm not perfect The only way I've found to do this is:1) Start the script and then RunWait itself with a switch to actually run the script.2) The original instance can run Func OnAutoItExit when the child process terminates.Does anyone know of a better way to do this that I'm missing?KennyHere's an example:MsgBox(0,"",$UndefinedVar) Func OnAutoItExit() MsgBox(0,"","Exiting") EndFunc "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains." Link to comment Share on other sites More sharing options...
dbzfanatic Posted November 25, 2008 Share Posted November 25, 2008 Try this: $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ;Straight from help Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
ken82m Posted November 25, 2008 Author Share Posted November 25, 2008 Thanks, never would have thought to look at that one I tried this but no joy$oMyError = ObjEvent("AutoIt.Error", "OnAutoItExit2") MsgBox(0,"",$UndefinedVar) Func OnAutoItExit2() MsgBox(0,"","Exiting") EndFuncKenny "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains." Link to comment Share on other sites More sharing options...
dbzfanatic Posted November 25, 2008 Share Posted November 25, 2008 Well this only catches COM errors. Is that what you're getting? Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
ken82m Posted November 25, 2008 Author Share Posted November 25, 2008 No just general errors on autoit fucntions. I was using a script I got from the forum that allows me to block user input except for specific keys, or just block the mouse or keyboard. The problem is if I get an error that causes the script to end immediately and it doesn't unlock user input. The only way I found around it was the above method which allows the original process to issue the unlock command no matter what happens. -Kenny "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains." Link to comment Share on other sites More sharing options...
Valik Posted November 25, 2008 Share Posted November 25, 2008 Fix your code, that's the right answer. Under no circumstance should a properly written script hard-error. Implementing a solution like this doesn't fix the underlying problem. It's a very bad thing to do. The alternative - and more correct version of what you are trying to do is spawn a second process which does nothing but block input and waits either for the parent script to close or for it to receive a signal from the parent to unblock input. In other words, decouple the event where you need guaranteed action from the main script so that things that affect the main script do not affect the guaranteed actions. Link to comment Share on other sites More sharing options...
dbzfanatic Posted November 25, 2008 Share Posted November 25, 2008 Oh you're still using that? I ghosted that thread a bit so I know what you're talking about. If you run the script from SciTe you should get the error output in the console and be able to see where it happens, then just do a bit of error checking and do something like: If @error <> 0 Then ;code to release lock on keys EndIf Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
ken82m Posted November 26, 2008 Author Share Posted November 26, 2008 Thanks guys. Valik- Your second suggestion is actually what I'm doing now, I guess I didn't do a very good job explaining it in my first post. As far as fixing the script your absolutely right. But the scripts are long and just used for some automation on my own machines and I guess I'm lazy lol. dbzfanatic- Thanks I'll give that a try One way or the other I have a way around it now was just wondering if there was another I may have been missing. Thanks, Kenny "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains." 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