Sign in to follow this  
Followers 0
saurabh2k26

Force Stop a running Autoit script

5 posts in this topic

Hello

I made a script to open my application(app1.exe) and then perform many operations over it. It works very well.

:)

One day, while running my script, i accidentally closed my application and then, all the mouse click events in my script operated on my desktop and did random things like opening any shortcut from my desktop etc.

I felt so helpless about about to do.

Is there any method to force stop a running script. Note: i play my script my directly clicking on test.au3, ie i don't run using SciTE.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Something like this:

HotKeySet("{Esc}", "ExitScript")
Func ExitScript()
    Exit
EndFunc

Press escape, and the script will Exit.

That's the answer to your specific question, but the real fix would be to use control* functions, so if the window is not present, it will not perform the click.  Same with ControlSend, or ControlSetText vs Send.

ControlClick
ControlSend
ControlSetText
WinGetHandle
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Thanks a lot

:)

One more question.

Can i do Stop and then again run my script from the point where i stopped.

Like in above example, Esc to stop script and then i need F1 to continue script from where is stopped.

Also error handling for case where i didnt press ESC and pressed F1 on already running script, should not have any effect and F1 should be ignored.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Error handling is indeed what you need. If you exit the script, it is of course not naturally going to "pick up where you left off". If you would like to be able to pick it up at a specific function, you would have to code that in. For example, if you have three functions (Private1, Private2, Private3) and want to start at Private22, you can do something like this:

If $CmdLine[1] = "/Private1" Then Private1()
If $CmdLine[1] = "/Private2" Then Private2()
If $CmdLine[1] = "/Private3" Then Private3()


Func Private1()
    MsgBox(0, "Private1", "Private1")
EndFunc

Func Private2()
    MsgBox(0, "Private2", "Private2")
EndFunc

Func Private3()
    MsgBox(0, "Private3", "Private3")
EndFunc

At the command line, you would then run <scriptname>.exe /Private2

Edited by JLogan3o13
1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

The helpfile sample for HotKeySet shows how to 'pause' a script, and resume it.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

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