Jump to content

ESC = Pause Script (As .exe)


qwee
 Share

Recommended Posts

Hi!

I've searched but couldn't find anything of value :unsure: Or it's just me that can't search for right things ^^

Well, need a code, so when I press ESC, the script will be paused, and when I press ESC again it'll be resumed! (Don't care if 1 button is for pause and 1 is for resume tbh)

Fast plz! :P

Link to comment
Share on other sites

As it is nearly time to go home... and I am feeling magnanimous...

HotKeySet("{ESC}", "_Terminate")
HotKeySet("{Pause}", "_Pause")

While 1
    Sleep(100) ; usually a good idea to put this in so you dont max your cpu
    ToolTip("Press ESC to quit")
    ;
    ; The stuff you want the script to do over and over again goes here
    ;
WEnd

Func _Terminate()
    Exit 0
EndFunc   ;==>_Terminate

Func _Pause()
    If Not IsDeclared("isPaused") Then Global $isPaused = False
    $isPaused = Not $isPaused
    While $isPaused
        Sleep(100)
    WEnd
EndFunc   ;==>_Pause

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

As it is nearly time to go home... and I am feeling magnanimous...

HotKeySet("{ESC}", "_Terminate")
HotKeySet("{Pause}", "_Pause")

While 1
    Sleep(100) ; usually a good idea to put this in so you dont max your cpu
    ToolTip("Press ESC to quit")
    ;
    ; The stuff you want the script to do over and over again goes here
    ;
WEnd

Func _Terminate()
    Exit 0
EndFunc   ;==>_Terminate

Func _Pause()
    If Not IsDeclared("isPaused") Then Global $isPaused = False
    $isPaused = Not $isPaused
    While $isPaused
        Sleep(100)
    WEnd
EndFunc   ;==>_Pause

Getting WEnd error. Got some "WHile"'s in the code!

Link to comment
Share on other sites

I was intended as a stand alone example... not to be cut and pasted in your code somewhere or vice versa...

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

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...