Jump to content

Is it possible to have an Interupt()


Recommended Posts

I am wondering how (or if it's possible) to have a command interupt my script at any time.

For instance I have a script that begins to copy a directory to another place... which can take a long time. If I want to cancel it by clicking the "X" on the top of the window my gui does not close because it is in the middle of a command (or loop). It waits till it's turn then it exits.

What's a good trick to create some sort of interupt?

Thanks!

Link to comment
Share on other sites

I am wondering how (or if it's possible) to have a command interupt my script at any time.

For instance I have a script that begins to copy a directory to another place... which can take a long time. If I want to cancel it by clicking the "X" on the top of the window my gui does not close because it is in the middle of a command (or loop). It waits till it's turn then it exits.

What's a good trick to create some sort of interupt?

Thanks!

HI,

did you try HotKeySet() ?

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hmmm.. maybe it is something wrong with my code.

The weird thing is... If I call my script from a batch file and I try to close my gui... it will close like I want it to.

But if I just open my gui by opening the exe file itself and I try to close it in the same spot... it doesn't close. Very weird.

Thanks for the ideas.

Link to comment
Share on other sites

Hmmm.. maybe it is something wrong with my code.

The weird thing is... If I call my script from a batch file and I try to close my gui... it will close like I want it to.

But if I just open my gui by opening the exe file itself and I try to close it in the same spot... it doesn't close. Very weird.

Thanks for the ideas.

Hi,

what about posting your code, so we can help you.

So loong,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • Moderators

Hmmm.. maybe it is something wrong with my code.

The weird thing is... If I call my script from a batch file and I try to close my gui... it will close like I want it to.

But if I just open my gui by opening the exe file itself and I try to close it in the same spot... it doesn't close. Very weird.

Thanks for the ideas.

Are you using Opt('OnExitFunc', 'FuncName') by any chance?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Actually yes I did use OnExit func. Would that have something to do with it?

I did fix the problem though. Instead of having

While 1
    Sleep(10)
Wend

and a button that would call a CopyNow() to show copy progress...

I changed it to something like:

While 1
    Sleep(10)
    If $CopyProcess = ("GO") Then
    $CopyProcess = ("")
    CopyNow()
WEnd

I added a new simple func:

Func StartCopy()
    $CopyProcess = "GO"
EndFunc

I also changed the button to call StartCopy() instead of CopyNow().

Now it works the way I wanted it too. :)

I want to thank Paul_365 for his code... that showed me how to do this. :mellow:

Thanks Everyone! :)

Edited by Proph
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...