Sign in to follow this  
Followers 0
ken82m

OnAutoItExit even with hard error?

8 posts in this topic

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?

Kenny

Here's an example:

MsgBox(0,"",$UndefinedVar)

Func OnAutoItExit()
    MsgBox(0,"","Exiting")
EndFunc

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "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."

Share this post


Link to post
Share on other sites



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")
EndFunc

Kenny


My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "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."

Share this post


Link to post
Share on other sites

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


My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "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."

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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


My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "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."

Share this post


Link to post
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
Sign in to follow this  
Followers 0